Facts Broken EC2 hostname Changed Format

93 views
Skip to first unread message

Demetri Mouratis

unread,
Apr 2, 2014, 6:54:53 PM4/2/14
to ansible...@googlegroups.com
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] *****************************************
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:

---

# amp playbook for ubuntu

- name: Amp

  user: ubuntu

  sudo: True

  tags: amp

  hosts: all

  roles:

    - base

    - amp

    - iverson

    - vagrant

  vars_files:

    - vars/{{ ansible_distribution }}.yml



# cat vars/Ubuntu.yml 


ntp_service_name: ntp


ssh_service_name: ssh


mongodb_service_name: mongodb


tomcat_user: tomcat7


rc_local_path: /etc/rc.local


ansible is version 1.5.4.

OS is Ubuntu 12.04.

On the command line, ansible 127.0.0.1 -m setup gives a full fact output including:

"ansible_distribution": "Ubuntu",

Whenever I run ansible-playbook, however, the facts seem to not work correctly.

What's the most reliable way to invoke ansible-playbook against localhost given that the system's hostname is a moving target? How would ansible on the command line correctly determine facts while ansible-playbook does not?

Thanks.

Demetri Mouratis

unread,
Apr 2, 2014, 7:12:58 PM4/2/14
to ansible...@googlegroups.com
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.

Demetri Mouratis

unread,
Apr 2, 2014, 8:12:14 PM4/2/14
to ansible...@googlegroups.com

Michael DeHaan

unread,
Apr 3, 2014, 6:09:39 PM4/3/14
to ansible...@googlegroups.com
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)



On Wed, Apr 2, 2014 at 8:12 PM, Demetri Mouratis <dmou...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/860bb215-871c-475f-8309-86da899c7e99%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages