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: http://docs.ansible.com/intro_inventory.html

Set up connectivity to the servers

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

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

child1.dev
child2.dev

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 "[email protected]"

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

root@master:~# ssh-copy-id [email protected]
root@master:~# ssh-copy-id [email protected]

Now you can test the connectivity:

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

child2.dev | success >> {
    "changed": false, 
    "ping": "pong"
}

Next...

Now you're ready to actually manage your servers with Ansible's playbooks: http://docs.ansible.com/playbooks_intro.html




Get the latest updates via email:

Spam-free, one-click unsubscribe