APT module is failing with sudo on Mac 10.9.X control machine

155 views
Skip to first unread message

Kaji Bikash

unread,
May 29, 2014, 3:10:28 PM5/29/14
to ansible...@googlegroups.com
For last 2 days, i have been struggling with a rather puzzling issue. I have installed/uninstalled ansible multiple times suspecting it might be the issue with the installation itself. But all in vain. I tried multiple versions of ansible already in ubuntu but no issue as such. Please help

~/a/p/statserver git:master ❯❯❯ cat hosts                                                                                                  
192.168.33.12 ansible_ssh_port=22
~/a/p/statserver git:master ❯❯❯ cat test.yml                                                                                              
---
- hosts: all
  sudo
: True
  user
: vagrant
  sudo_user
: vagrant
  port
: 22
  tasks
:
     
- name: Test apt
        apt
: update_cache=yes
~/a/p/statserver git:master ❯❯❯ ansible -i hosts -a 'apt-get install htop' all -u vagrant                                                  
192.168.33.12 | FAILED | rc=100 >>
E
: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E
: Unable to lock the administration directory (/var/lib/dpkg/), are you root?


~/a/p/statserver git:master ❯❯❯ ansible -i hosts -a 'apt-get install htop' all -u vagrant -s                                            
192.168.33.12 | success | rc=0 >>
Reading package lists...
Building dependency tree...
Reading state information...
htop
is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 160 not upgraded.

So it looks good. But when i do via playbook , it all fails with "msg: Failed to lock apt for exclusive operation"

~/a/p/statserver git:master ❯❯❯ ansible-playbook -i hosts test.yml -vvv                                                                    


PLAY
[all] ********************************************************************


GATHERING FACTS
***************************************************************
<192.168.33.12> ESTABLISH CONNECTION FOR USER: vagrant
<192.168.33.12> REMOTE_MODULE setup
<192.168.33.12> EXEC ['ssh', '-C', '-tt', '-q', '-o', 'ForwardAgent=yes', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '192.168.33.12', "/bin/sh -c 'mkdir -p /tmp/ansible-tmp-1401390504.11-150057298374102 && chmod a+rx /tmp/ansible-tmp-1401390504.11-150057298374102 && echo /tmp/ansible-tmp-1401390504.11-150057298374102'"]
<192.168.33.12> PUT /var/folders/fv/gpzlv1jd3bd3s6sw57q0smr00000gn/T/tmpbcpfOS TO /tmp/ansible-tmp-1401390504.11-150057298374102/setup
<192.168.33.12> EXEC ['ssh', '-C', '-tt', '-q', '-o', 'ForwardAgent=yes', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '192.168.33.12', "/bin/sh -c 'chmod a+r /tmp/ansible-tmp-1401390504.11-150057298374102/setup'"]
<192.168.33.12> EXEC ['ssh', '-C', '-tt', '-q', '-o', 'ForwardAgent=yes', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '192.168.33.12', u"/bin/sh -c 'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /tmp/ansible-tmp-1401390504.11-150057298374102/setup; rm -rf /tmp/ansible-tmp-1401390504.11-150057298374102/ >/dev/null 2>&1'"]
<192.168.33.12> EXEC ['ssh', '-C', '-tt', '-q', '-o', 'ForwardAgent=yes', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '192.168.33.12', "/bin/sh -c 'rm -rf /tmp/ansible-tmp-1401390504.11-150057298374102/ >/dev/null 2>&1'"]
ok
: [192.168.33.12]


TASK
: [Test apt] **************************************************************
<192.168.33.12> ESTABLISH CONNECTION FOR USER: vagrant
<192.168.33.12> REMOTE_MODULE apt update_cache=yes
<192.168.33.12> EXEC ['ssh', '-C', '-tt', '-q', '-o', 'ForwardAgent=yes', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '192.168.33.12', "/bin/sh -c 'mkdir -p /tmp/ansible-tmp-1401390504.64-61942463115394 && chmod a+rx /tmp/ansible-tmp-1401390504.64-61942463115394 && echo /tmp/ansible-tmp-1401390504.64-61942463115394'"]
<192.168.33.12> PUT /var/folders/fv/gpzlv1jd3bd3s6sw57q0smr00000gn/T/tmpQeaBWx TO /tmp/ansible-tmp-1401390504.64-61942463115394/apt
<192.168.33.12> EXEC ['ssh', '-C', '-tt', '-q', '-o', 'ForwardAgent=yes', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '192.168.33.12', "/bin/sh -c 'chmod a+r /tmp/ansible-tmp-1401390504.64-61942463115394/apt'"]
<192.168.33.12> EXEC ['ssh', '-C', '-tt', '-q', '-o', 'ForwardAgent=yes', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '192.168.33.12', u"/bin/sh -c 'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /tmp/ansible-tmp-1401390504.64-61942463115394/apt'"]
<192.168.33.12> EXEC ['ssh', '-C', '-tt', '-q', '-o', 'ForwardAgent=yes', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '192.168.33.12', "/bin/sh -c 'rm -rf /tmp/ansible-tmp-1401390504.64-61942463115394/ >/dev/null 2>&1'"]
failed
: [192.168.33.12] => {"failed": true}
msg
: Failed to lock apt for exclusive operation


FATAL
: all hosts have already failed -- aborting


PLAY RECAP
********************************************************************
           to
retry, use: --limit @/Users/kaji/test.retry


192.168.33.12              : ok=1    changed=0    unreachable=0    failed=1


Thanks in advance

--
Kaji

Frédéric Badel

unread,
May 29, 2014, 3:23:26 PM5/29/14
to ansible...@googlegroups.com
IMHO “sudo_user: vagrant” means that you’re running “sudo -u vagrant …”, therefore you’re not running this command as root.
Try to remove the “sudo_user:” from your playbook.

Cheers,

Fred



--
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/c16b3225-f6d6-4926-9b2c-b0039b85d072%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kaji Bikash

unread,
May 29, 2014, 3:30:15 PM5/29/14
to ansible...@googlegroups.com
:) yeah that did it. How could I have missed it !!! Thanks for the clarification.


--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/JG-f1fBHCck/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages