include_role
include_role module
Include and execute all tasks from a specified role. This allows you to reuse role functionality within a playbook.
Examples
- name: Include webserver role
include_role:
name: webserver
- name: Include role with variables
include_role:
name: database
vars:
db_name: myapp
db_user: appuser
- name: Conditionally include role
include_role:
name: ssl_certificates
when: enable_ssl | bool
Note: The role must be available in the roles directory or in the Ansible roles path.
Module Capabilities
- Has Revert: false
- Provides Variables: None
Inputs
Parameter | Type | Description | Required | Default | Choices |
---|---|---|---|---|---|
name | string | Name of the role to include and execute. | false |
Outputs
No outputs.