The Ansible Playbook
Playbooks are the Bread and Butter of Ansible. They tell Ansible exactly what to do, like a recipe or instruction manual.
A simple inventory file. Make sure to update hostname/IP addresses to match your environment.
[servers] node1 ansible_host=10.1.1.51 node2 ansible_host=10.1.1.52 node3 ansible_host=10.1.1.53
Here is the playbook from the video.
Explanation of each of the parameters in the playbook is at the 30-second mark of the video.
--- - name: Playbook to install software become: true hosts: all tasks: - name: ensure docker is installed. apt: name: docker.io state: present update_cache: true - name: ensure docker is installed. apt: name: apache2 state: present update_cache: true
Running the Playbook
To run the playbook, run the ansible-playbook command.
ansible-playbook -i hosts -K playbook1.yml