To demonstrate how playbooks works, the following example will showcase a small playbook that also makes use of the variables we configured earlier:
- hosts: mon1 osd1
tasks:
- name: Echo Variables
debug: msg="I am a {{ a_variable }}"
And now run the playbook. Notice that the command to run a playbook differs from running ad hoc Ansible commands:
$ ansible-playbook /etc/ansible/playbook.yml
The output shows the playbook being executed on both mon1 and osd1 as they are in groups, which are children of the parent group, Ceph. Also note how the output of the two servers is different as they pick up the variables that you set earlier in the group_vars directory.
Finally, the last couple of lines show the overall run status of the playbook run. You can now destroy your Vagrant environment again, ready for the next section:
Vagrant destroy --force...