Last active Feb 13, 2017

Ansible

Ansible is a tool to automate platform changes such as deploying new app code or ensure services are installed. The Ansible application runs on both your local machine and you're remote server. There is not need for a central master - like Puppet.

A local version of the playbook is used to update your remote servers. Playbooks are similar to a Puppet Manifest.

All communication between local and remote are handled though ssh. So make sure you can ssh into your remote server from where you are.

Super simple! I declare what user and ssh key we'll use when contacting the remote server. I've also named this host configuration myserver. I could have more entries for other servers in this stack. Like mywebserver, myapiserver, etc. Each would have thier own ip addres.

Finally, here is a really simple test to see that your local Ansible can reach out and contact the remote server. From the command line:

$ ansible --inventory=./hosts myserver --module-name=ping

This tells Ansible to use the local hosts file and to use the module ping. You should get a response back to the console similar to this:

12.34.56.79 | SUCCESS => {
"changed": false,
"ping": "pong"
}

💥

I had a few errors when I tried to get this working the first time around. My entire issue stemmed from the fact that I didn't indicate the correct ssh key.

Here, another example, I want to make sure git is installed on my remote server. Here is how that would look:

Like my sources say, Ansible is idempotent. You can run that last command as often as you want. Once git is installed, it will alays be installed. Ansible won't try to re-install it each time. Ansible stores a fact sheet on the remote sever. It knows what's running and installed.

Next up: Playbooks! This will allow us to specify several items in a single file instead of individually on the command line. It will ensure all of our services are installed and the lastest version of our application is deployed and running.