Let’s configure our first playbook!

First and foremost Ansible requires ssh on the devices to be configured I have linked connection here on how to do that.

Ansible can be installed on the following platforms:

Red Hat, Debian, CentOS, macOS, any of the BSDs. Windows is not supported currently.

Bare in mind you also need Python 2.7 or above installed.

Once you have installed Ansible it will create the following default directories of installation:

Note – (I have elevated my user level to root so that I won’t have to input the sudo command all the time – It would not be a good idea to do this in production for security purposes however.)

cd /etc/ansible

Within  this directory you will see two files listed:

ansible.cfg and the hosts file


These are the default files that are installed for ansible, you will note a lot of it is commented out, these are some options available and can be used as a template guide.


Within the hosts files we can see the formatting as well, this gives you a basic understanding of the layout.


We will however create our own directory and within it create our own ansible.cfg and hosts files

So let’s go ahead and create a new directory:

Step 1:

Create a new file directory to store our ansible files, in this example I have create a folder called Ansible_Automation


Step 2:

Create the ansible.cfg and the hosts files


Within the file type the below configuration


Next we will configure our hosts file


Within the file type the bellow configuration


In my example I have just used two ios devices , however you can populate this with hundreds of devices, you can see the possibility of automation scales at work. (Something that takes time configuring hundreds of devices can literally take you minutes)

Step 3:

Create our playbook!

All we need to do is create a file with a .yml extension (Yaml – Yet another markup Language)

In my case I called it (myfirstplay.yml)

What this basic playbook will do is to run the command : show version on our switch and display the content.

Generally you would not want to pass any credentials through the playbook however in this case we are doing it as an example to speed up the process. (Remember our details in our ssh setup)


Within the file type the below configuration


Now that we have configured it, it’s time to run it!

Step 4:

Let us run our first playbook by typing the below:



This completes our first basic tutorial on how to setup a playbook in ansible