Ansible

Retrying Server Builds with Ansible

A common problem with building multiple servers in the cloud is an intermittent failure in one build that can stop your entire deployment process. With the right retry logic you can avoid this problem with Ansible.

I’m using until to check the output from the rax module. Using the length Jinja2 filter, I can check if the correct number of instances have been created. This should retry the task 3 times with a delay of 5 seconds between attempts.

Testing CloudFormation Templates with Ansible

There are many variations and combinations of AWS products and services that lend the platform to great flexibility and customization. We work hard to evaluate these combinations and put forth a collection of best practices for our customers to follow. One of these best practices is the use of CloudFormation templates. My team maintains a series of standard CloudFormation templates for our customers to use. Part of that maintenance includes updating those templates and testing them for functionality.

Ansible's Rackspace Dynamic Inventory Plugin

Installing

Installing inventory plugins isn’t intuitive, and the documentation available on this process isn’t immediately clear. The instructions found on this page Ansible Documentation can be adapted for the Rackspace plugin.

It boils down to this for the Rackspace plugin:

  1. Grab the latest version of rax.py from the plugins/inventory folder on GitHub. Raw GitHub Link
  2. Place this file on your Ansible master. The location doesn’t matter that much, but convention says to put it in /etc/ansible/rax.py.
  3. Make this script executable by issuing chmod +x /etc/ansible/rax.py.
  4. As the user that runs Ansible, create the following file at ~/.rackspace_cloud_credentials: (Be sure to replace the appropriate values with your Rackspace username and apikey.)
[rackspace_cloud]
username = my_username
api_key = 01234567890abcdef

Target the rax.py script in your ansible run: ansible -i /etc/ansible/rax.py webserver -m ping