Ansible Playbooks

The Ansible Playbook

About Playbooks

Playbooks are the Bread and Butter of Ansible. They tell Ansible exactly what to do, like a recipe or instruction manual.

The Code

Inventory File

A simple inventory file. Make sure to update hostname/IP addresses to match your environment.

node1 ansible_host=
node2 ansible_host=
node3 ansible_host=


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

  - name: ensure docker is installed.
      state: present
      update_cache: true
  - name: ensure docker is installed.
      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