In the first part of Automating with Ansible we had a look at how you can utilize Ansibles inventory-file and the ping module to communicate with the different machines in your environment. This time we’ll have a look of how to utilize Ansibles Playbooks to leave the command line and automate our IT even further
Ansible utilizes the concept of playbooks to organize and execute tasks for us. A playbook is a simple yml-file with tasks (instructions). Let’s have a look at work/playbooks/touchfile.yml in the repository:
The first thing we do in our playbook is to define which hosts the playbook should target. As seen above, we aim to execute this playbook on all of our hosts.
On the next line we define our first task. The task