Junior — Middle
How to connect the Ansible role into a Playbook script?
sobes.tech AI
Answer from AI
To include a role in an Ansible Playbook, the keyword roles is used. In the playbook section where tasks are described for hosts, a list of roles to be applied is added.
Example of including the common role:
- hosts: all
roles:
- common
If you need to pass parameters to a role, you can use a dictionary:
- hosts: all
roles:
- role: common
vars:
some_variable: value
Thus, roles allow structuring and reusing configurations in Ansible.