I am running Ansible using “brew install --HEAD ansible”, which currently prints it’s version as “ansible 1.4”.
Here is my task:
- name: install ruby gem bundler
gem: name=bundler state=present version=1.3.5 user_install=no
sudo: true
When I run, it states that there is no change - bundler appears to the gem module to be installed??, though it is not.
I went further and tried the following:
ansible utilities -v --sudo -i development -m gem -a ‘name=bundler state=present version=1.3.5 user_install=no’
192.168.10.24 | success >> {
“changed”: false,
“name”: “bundler”,
“state”: “present”,
“version”: “1.3.5”
}
Seemingly the same behavior. If I run without --sudo:
ansible utilities -v -i development -m gem -a ‘name=bundler state=present version=1.3.5 user_install=no’
192.168.10.24 | FAILED >> {
“cmd”: [
“/usr/bin/gem”,
“install”,
“–version”,
“1.3.5”,
“–include-dependencies”,
“–no-user-install”,
“–no-rdoc”,
“–no-ri”,
“bundler”
],
“failed”: true,
“msg”: “ERROR: While executing gem … (Gem::FilePermissionError)\n You don’t have write permissions into the /var/lib/gems/1.9.1 directory.”,
“rc”: 1,
“stderr”: “ERROR: While executing gem … (Gem::FilePermissionError)\n You don’t have write permissions into the /var/lib/gems/1.9.1 directory.\n”,
“stdout”: “INFO: gem install -y
is now default and will be removed\nINFO: use --ignore-dependencies to install only the gems you list\n”
}
I made the effort of running the “gem” module manually on the target host by setting ANSIBLE_KEEP_REMOTE_FILES=true and then running “sudo /usr/bin/python /home/vagrant/.ansible/tmp/ansible-1384877605.76-187131457818350/gem”. That worked great by installing bundler.
I have also made an attempt to discover what the “gem” python script is doing in the filesystem during a playbook run and during a manual run, as described, by using auditd. You can see the output over here: https://gist.github.com/aiwilliams/a86bf5d3deee57f2c72d. Seems to me they’re both working with the same directories, but otherwise I didn’t get much indication why it behaves differently when executed by ansible-playbook.
It’s got to be an environment thing, I would have though, but it seems that the bash environment is the same and I’ve verified that the gem environment is the same.
Any clues what might be going on?
Thanks, Adam