Ansible

IT and Infrastructure automation

Setup

Install the EPEL repository and Ansible (or just Ansible directly)

$ sudo yum install -y epel-release
$ sudo yum install -y ansible

In its simplest form, Ansible works by workstations controlled by a control host. On both, you will need a consistent ansible user:

$ sudo useradd ansible
$ sudo passwd ansible # set a password for the user

Configure a shared key that will allow the user to log in from the control host to the workstation without password prompts:

# On the control host
$ sudo su - ansible
$ ssh-keygen
$ ssh-copy-id <workstation> # provide your ansible password here
$ logout

Configure the ansible user on the workstation host so that the ansible control host user can sudo without a password:

$ sudo visudo
# At the bottom of the file add:
ansible ALL=(ALL) NOPASSWD: ALL

Inventory

The inventory is just a list of hosts available to you in a file called inventory. Inventories will look like this:

Playbooks

Ansible playbooks are configuration files that define what you're doing to your workstation nodes in simple YAML or JSON. The following is a good playbook model for installing git on the workstation:

Execute

Execute the playbook with:

Pings

Check health of a node by pinging it (you can redirect or tail output to a log):

Last updated

Was this helpful?