upgrading apt packages, getting stderr: /bin/sh: apt-get: command not found

1,199 views
Skip to first unread message

Gallagher Polyn

unread,
Apr 28, 2014, 11:11:01 PM4/28/14
to ansible...@googlegroups.com
Hi,

Having just provisioned a Digital Ocean droplet, in my next pre_task, I proceed to attempt to upgrade apt packages:

apt: upgrade=full update_cache=yes

...using this command form...

ansible-playbook -i hosts basic.yml -vvvv

...I obtain the following error:

failed: [127.0.0.1] => {"cmd": "apt-get update && apt-get install python-apt -y -q", "failed": true, "rc": 127}
stderr: /bin/sh: apt-get: command not found
msg: /bin/sh: apt-get: command not found
 
Shelling into the newly-provisioned droplet as root, however, I am able to execute apt-get update normally.

Any thoughts?

Thanks,

Gallagher

Ralph

unread,
Apr 29, 2014, 3:15:43 AM4/29/14
to ansible...@googlegroups.com
Hi,

my two cents would be:
  1. Make sure you use absolute paths when invoking the "apt-get update" and "apt-get install" commands (whereis apt-get helps here...)
  2. Make sure you use the "shell" module instead of the "command" module since the shell module allows redirection and pipe and that kind of stuff
Cheers
Ralph

Michael DeHaan

unread,
Apr 29, 2014, 8:37:16 AM4/29/14
to ansible...@googlegroups.com
Hi Ralph,

He's using the apt module not shelling out to apt directly.

The basic initial questions are "what versions of Ansible are you using" and "what is the OS version you are using".

We can go from there.

Thanks!


--
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/88233a37-8962-4ac1-b626-497825be6599%40googlegroups.com.

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

Ralph

unread,
Apr 29, 2014, 8:52:00 AM4/29/14
to ansible...@googlegroups.com
...ahh sorry, my mistake. My eyes sort of went straight to the error. I should've grabbed a coffee before answering...

Gallagher Polyn

unread,
Apr 29, 2014, 11:56:39 AM4/29/14
to ansible...@googlegroups.com
...I obtain the following error:

failed: [127.0.0.1] => {"cmd": "apt-get update && apt-get install python-apt -y -q", "failed": true, "rc": 127}
stderr: /bin/sh: apt-get: command not found
msg: /bin/sh: apt-get: command not found

Resolution: I had failed to use the add_host module and the command was failing because it was being run on the wrong machine, namely, localhost.

Hopeful Request: Can someone please point to an example of Digital Ocean provisioning plus configuration with Ansible? (I've seen examples of one or the other, not both.)

Thanks,

G
 
Reply all
Reply to author
Forward
0 new messages