Facts Broken EC2 hostname Changed Format

I have been using Peter Sankauskas’s excellent netflixoss-ansible repo successfully for the past few months. Starting sometime yesterday, the ansible-playbook invocations started failing with the following error:

TASK: [base | Copy rc.local template] *****************************************e
127.0.0.1] => One or more undefined variables: ‘rc_local_path’ is undefined

I’m wrapping the whole build process in packer called by Jenkins, again which has been working a treat.

Packer does the following to invoke ansible:

sudo ansible-playbook /usr/local/netflixoss-ansible/playbooks/amp-iverson.yml --connection=local

So, I manually created a packer-builder ec2 node from a private AMI. When I logged in, I noticed the EC2 hostname had changed form form ip-w-x-y-z to domU-AA-BB-CC-DD-EE-FF.

e.g.:

domU-12-31-39-06-32-80

Suspicious.

This in turn may have caused some problems for the inventory file which I had been using, which looked like:

sudo sh -c ‘echo "127.0.0.1 ansible_connection=local vm=0" > /etc/ansible/hosts’

I cannot seem to get the following play to work successfully:

  • name: Copy rc.local template

copy: src={{ ansible_distribution }}/rc.local dest={{ rc_local_path }} owner=root group=root mode=0755

The vars are setup out of the top level playbook as such:

As is always the case, once I wrote out the problem I quickly found the solution.

Downgrading to ansible 1.5.3 from https://launchpad.net/~rquillo/+archive/ansible fixes the issue. On the initial ansible play, I now see output from playbook saying it correctly interpolated the vars:

PLAY [Amp] ********************************************************************

GATHERING FACTS ***************************************************************

ok: [domU-12-31-39-06-32-80]

domU-12-31-39-06-32-80: importing /usr/local/netflixoss-ansible/playbooks/vars/Ubuntu.yml

Carry on.

Bug report: https://github.com/ansible/ansible/issues/6832

We’ve already replied to this one with a workaround for those that need it.

(The development branch also does not have this problem anymore)