Hi,

I can see this behaviour with following gems

github: haste
rubygems: ops_build

opsci:~ $ sudo gem list

*** LOCAL GEMS ***


TASK: [common-server | Install Haste client binary] 
***************************
<opsci.rsd.com> ESTABLISH CONNECTION FOR USER: rsd
<opsci.rsd.com> REMOTE_MODULE gem name=haste state=latest
<opsci.rsd.com> EXEC ssh -C -tt -q -o ControlPersist=15m -F 
/Users/haad/.ansible/ssh_config -o 
ControlPath="/Users/haad/.ansible/cp/ansible-ssh-%h-%p-%r" -o 
StrictHostKeyChecking=no -o Port=22 -o 
IdentityFile="/Users/haad/.ssh/id_rsa" -o KbdInteractiveAuthentication=no 
-o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
-o PasswordAuthentication=no -o User=rsd -o ConnectTimeout=19 opsci.rsd.com 
/bin/sh -c 'mkdir -p 
$HOME/.ansible/tmp/ansible-tmp-1423500136.86-230822911136757 && chmod a+rx 
$HOME/.ansible/tmp/ansible-tmp-1423500136.86-230822911136757 && echo 
$HOME/.ansible/tmp/ansible-tmp-1423500136.86-230822911136757'
<opsci.rsd.com> PUT 
/var/folders/yq/_h9bmb6x1qxb7p4_w5xhkgx80000gn/T/tmp1sQb3z TO 
/home/rsd/.ansible/tmp/ansible-tmp-1423500136.86-230822911136757/gem
<opsci.rsd.com> EXEC ssh -C -tt -q -o ControlPersist=15m -F 
/Users/haad/.ansible/ssh_config -o 
ControlPath="/Users/haad/.ansible/cp/ansible-ssh-%h-%p-%r" -o 
StrictHostKeyChecking=no -o Port=22 -o 
IdentityFile="/Users/haad/.ssh/id_rsa" -o KbdInteractiveAuthentication=no 
-o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
-o PasswordAuthentication=no -o User=rsd -o ConnectTimeout=19 opsci.rsd.com 
/bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, 
key=bqhjegrwqcfakjiubogaofvswknlictj] password: " -u root /bin/sh -c 
'"'"'echo SUDO-SUCCESS-bqhjegrwqcfakjiubogaofvswknlictj; LANG=C LC_CTYPE=C 
/usr/bin/python 
/home/rsd/.ansible/tmp/ansible-tmp-1423500136.86-230822911136757/gem; rm 
-rf /home/rsd/.ansible/tmp/ansible-tmp-1423500136.86-230822911136757/ 
>/dev/null 2>&1'"'"''
ok: [opsci-server] => {"changed": false, "name": "haste", "state": 
"latest", "version": "0.2.1"}

On Tuesday, November 19, 2013 at 7:17:21 PM UTC+1, Adam Williams wrote:
>
> 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
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a3ddf315-ae47-45d5-a603-c167d4700d06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to