Ansible --connection=local

Having a bit of an issues with a Packer/Ansible/Vagrant build pipeline. I have been using Ansible for a while and can happily provision my dev VMs via Ansible.

I have hooked Packer in the the pipeline and now with the same Ansible scripts in local mode I am getting failures on conditional checks, apache_module disallowed.

This is an example of what fails:

  • name: Set Ruby 1.9.3 as default on Ubuntu 12.0.4
    sudo: yes
    shell: “{{item}}”
    with_items:
  • ‘cd /etc/alternatives && sudo ln -sf /usr/bin/ruby1.9.3 ruby’
  • ‘cd /etc/alternatives && sudo ln -sf /usr/bin/gem1.9.3 gem’
  • ‘cd /etc/alternatives && sudo ln -sf /usr/bin/irb1.9.3 irb’
  • ‘cd /etc/alternatives && sudo ln -sf /usr/bin/ri1.9.3 ri’
    when: ansible_distribution_version | version_compare(‘12.04’, ‘=’)
    tags: common

The error I am getting is:

TASK: [common | Set Ruby 1.9.3 as default on Ubuntu 12.0.4] *******************
fatal: [127.0.0.1] => error while evaluating conditional: ansible_distribution_version | version_compare(‘12.04’, ‘=’)

The base iso is Ubuntu 12.04.

I am sure it is something simple but for the life of me this has me stumped.

S

What’s the output of “ansible --version” ?

Hi - ansible 1.7.2

My bad - on the Ubuntu VM, the version is 1.4.4+dfsg-1~ubuntu12.04.1. On my OSx box, 1.7.2.

Numpty mistake!

Probably don’t get this enough, thank you for Ansible. It has literally changed my life and how I think about IT.

A collective “you are welcome!” from behalf of everyone that works on this. It’s much appreciated.

I am wondering if maybe fact gathering is disabled, possibly as a default in ansible.cfg, or there is a “gather_facts: False” in the play turning it off.

That might explain the absense of the version info.

My other question if that’s not the case would be what is the OS inside the image you are building?