Ansible: Post-Install Setup

Inventory hosts file

After you've installed Ansible, then you'll want Ansible to know which servers to connect to and manage.

Ansible's inventory hosts file is used to list and group your servers. Its default location is /etc/ansible/hosts.

If you want to have your Ansible hosts file in another location, then you can set this environment variable:

> export ANSIBLE_HOSTS=/root/ansible_hosts

Or you can specify the Ansible hosts location when running commands with the --inventory-file= (or -i) flag:

> ansible all --inventory-file=/root/ansible_hosts -m ping

For more on the inventory hosts file, see:

Set up connectivity to the servers

For this example, I'll assume you have servers with the hostnames and When doing your own install, replace those hostnames with your own.

Your /etc/ansible/hosts file would look like this:

You want to be able to connect to your servers without having to enter a password every time. If you don't already have ssh key authentication set up to your children nodes, then do the following...

Generate the ssh key on the master node:

root@master:~# ssh-keygen -t rsa -C ""

Then copy your public key to the servers with ssh-copy-id:

root@master:~# ssh-copy-id
root@master:~# ssh-copy-id

Now you can test the connectivity:

root@master:~# ansible all -m ping | success >> {
    "changed": false, 
    "ping": "pong"
} | success >> {
    "changed": false, 
    "ping": "pong"


Now you're ready to actually manage your servers with Ansible's playbooks:

Get the latest updates via email.

High Velocity Ops Newsletter

Spam-free, one-click unsubscribe