According to the Ansible docs, a Playbook is:
...the basis for a really simple configuration management and multi-machine deployment system, unlike any that already exist, and one that is very well suited to deploying complex applications.
And, again, according to those same docs, a Role are:
...ways of automatically loading certain vars_files, tasks, and handlers based on a known file structure. Grouping content by roles also allows easy sharing of roles with other users.
However the distinction between these and their different use cases is not immediately obvious to me. For instance, if I configure my /etc/ansible/hosts
file to look like:
[databases]
mydb01.example.org
mydb02.example.org
[mail_servers]
mymail01.example.org
mymail_dr.example.org
...then what is this "[databases]
" entry...a role? Or the name of a playbook YAML file somewhere? Or something else?!?
If someone could explain to me the differences on these, my understanding of Ansible would be greatly enhance!
- Playbook vs Role vs
[databases]
and similar entries in/etc/ansible/hosts
- If Playbooks are defined inside of YAML files, then where are Roles defined?
- Aside from the
ansible.cfg
living on the Ansible server, how do I add/configure Ansible with available Playbooks/Roles? For instance, when I runansible-playbook someplaybook.yaml
, how does Ansible know where to find that playbook?
tasks
do stuff.playbooks
organize and launch tasks.roles
organize bunches of tasks, handlers, etc that perform a particular function. Someplaybook
is needed to launch therole
(s). What would you call a collection ofroles
andplaybooks
? Say for example one that manages the configuration of all the hosts at your site? – fbicknel