Tutorial by Examples

Ansible uses the concept of roles to better allow modular code and avoid repeating yourself. A role is simply a folder structure that Ansible knows where to load vars files, tasks and handlers from. An example might look something like this: apache/ ├── defaults │   └── main.yml ├── files │   ...
Roles also enable you to define other roles as a dependency by creating a meta/main.yml file with a dependencies block: dependencies: - role: common It's also possible to pass a value to a parameter/variable in the dependent role: dependencies: - { role: common, some_parameter: 3 } Or ...
We can easily separate distribution specific tasks and variables into different dedicated .yml files. Ansible helps us to automatically identify the target hosts distribution via {{ ansible_distribution }} and {{ ansible_distribution_version }}, so we just have to name the distribution dedicated .y...

Page 1 of 1