Setting up ubuntu linux for ansible development

Using ansible on ubuntu for the first time

The first task I was shown when following ansible tutorials was editing the hosts file. I ran into a few issues though, hence this post. The solutions I found that helped are documented below:

Install ansible

sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible

Backups the hosts file

sudo mv /etc/ansible/hosts /etc/ansible/hosts.backup

Edit the hosts  file.

sudo nano hosts

Add your environments and ip addresses, eg:

[local]
127.0.0.1

Get ssh working, and test it can connect to your listed servers

add-username-to-transactions
sudo apt-get install openssh-server

Then test it is working and started:

sudo service ssh start

Run the ansible ping command

ansible all -m ping

Errors

If you get these errors:

Error: Permission denied

Two solutions,

Run the following command with -k

ansible all -m ping -k

This will trigger the password request

OR

Force ask password through the ansible config file:

sudo nano /etc/ansible/ansible.cfg
uncomment:
ask_pass = True

This will also trigger the password request, but by default without needing the -k option.

Then insert your password. You should now get your pong result without the error.