import_role

Collection: builtin

Full Name: import_role

Aliases: ansible.builtin.import_role

Synopsis

Statically import a role’s tasks at parse time

Parameters

NameTypeRequiredDefaultDescription
namestringyesThe name of the role to import
tasks_fromstringFile to load from a role’s tasks/ directory
vars_fromstringFile to load from a role’s vars/ directory
defaults_fromstringFile to load from a role’s defaults/ directory
handlers_fromstringFile to load from a role’s handlers/ directory
allow_duplicatesbooltrueAllow a role to be used more than once
rolespec_validatebooltrueValidate the role’s argument spec
publicbooltrueWhether role variables and defaults are exposed to play

Example

- name: Import the common hardening role
  import_role:
    name: hardening
    tasks_from: baseline.yml