Ansible Playbooks
An Ansible Playbook is a configuration file used by Ansible. You can think of it as a Vagrantfile for Vagrant. It uses the YAML (Yet Another Markup Language) markup language as the syntax and is easily readable:
--- - hosts: all sudo: yes tasks: - name: ensure nginx is at the latest version apt: name=nginx state=latest - name: start nginx service: name: nginx state: started
Let's look at the example playbook we created in the previous section, shown here in the above code block, and dissect it to get a better understanding of what it all means:
- The first line is always three dashes to signify the beginning of the file.
- We must then define which hosts this applies to. These can often be defined in the Ansible inventory file by setting a value such as [db] and supplying an IP address for that node.
- We then set the
sudo
value toyes
as we require sudo/root privileges to install Nginx on the...