1. Playbooks
It is the core of ansible
It contain instructions to configure the nodes
They are written in YAML, a language used to describe data
Structure
1. Name
We have the name of play like play1 and play 2
2. Host
It is the target of the play
3. Tasks
Each play has a list of tasks which contain following sections
name
Each element in the list of tasks is given a name like "install apache" and "start apache"
set of instructions
The name is followed by instructions to execute the task
Other Params
become
used to escalate privleges to specific user to execute tasks. become_user parameter is required to specify the user. remote_user
is another way to escalate privleges
vars
used to define variables to be used later on in playbook
notfiy
used to refer handlers
gather_facts
used to gather files or keys which can be used in different playbook
Sample Playbook 1
Sample Playbook 2
Sample Playbook 3
Sample Playbook 4
In Ansible, handlers are typically used to start, reload, restart, and stop services
Last updated