According to the Ansible docs, a Playbook is:
...the basis for a really simple configuration management and multi-machine deployment system, unlike any that
It's a terminology/semantic question. It can be subjective, even though there is a baseline definition.
My view is as follows:
Any configuration management/deployment system has:
source data
- data used to create target host's configurationtarget data
- data used to identify target hostsconfig changes
- list/set of rules/actions we apply with source data
over target host based on target data
source data
- is the various places we can put data - group_vars
, playbook
vars, role
vars, etc., These places affect precedence (if a variable named the same is re-defined in different locations, there are very specific rules of what would be the value of the variable during ansible
/ansible-playbook
executiontarget data
- is the inventory (And, It's also possible to define inventory/hostgroup variables inside inventory!)config changes
- ansible has 4 levels of abstraction for it:
role
s/task
s/tasklists (and special tasks like handlers
)From 'software' aspect - role should be generic enough to be reused.
Also in some (rather big) organizations, 'roles' are shipped by group A, while used in playbooks maintained by group B.
All the above allows grouping of similar configurations - into a role
.
grouping related subsystems/components into one playbook
.
Also, worth mentioning, 1 YAML item in a playbook (including hosts:
and either or tasks
, pre_tasks
, post_tasks
, roles
) is called a play
Yes, it is confusing at first.
You usually connect your source data
to your role's semantics, so when you see that role setup_db
is applied in a play onto related hostgroup (e.g. db_hosts
)
But a play
can be running over a union of several hostgroups.
It's just a matter of convention vs flexibility.
Please write me back whether this added to the confusion, or clarified. Thanks.