I am trying to upgrade all our (ubuntu) servers with the following playbook:
tasks:
-
name: apt-get update
apt: update_cache=yes
-
name: apt-get dist-upgrade
apt: upgrade=dist dpkg_options=‘force-confold,force-confdef’
-
name: reboot
command: ‘/sbin/reboot’
This fails like so:
TASK: [apt-get dist-upgrade] **************************************************
<10.0.20.4> REMOTE_MODULE apt upgrade=dist dpkg_options=‘force-confold,force-confdef’
<10.0.20.67> REMOTE_MODULE apt upgrade=dist dpkg_options=‘force-confold,force-confdef’
failed: [10.0.20.4] => {“cmd”: [“DEBIAN_FRONTEND=noninteractive”, “DEBIAN_PRIORITY=critical”, “/usr/bin/apt-get”, “-y”, “-o”, “Dpkg::Options::=–force-confold”, “-o”, “Dpkg::Options::=–force-confdef”, “dist-upgrade”], “failed”: true, “rc”: 2}
msg: [Errno 2] No such file or directory
The command runs fine if I run it as root on the machine itself:
‘DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical /usr/bin/apt-get -y -o Dpkg::Options::=–force-confold -o Dpkg::Options::=–force-confdef dist-upgrade’
Using that command line in a ansible ‘command’ or ‘shell’ statement instead of the apt command produces exactly the same error.
Any ideas?
cheers
Jens-Christian
For starters, what version of Ansible is this?
Thanks!
as stated in the subject: It is ansible 1.5.4
cheers
jc
Are you using any of the appropriate flags for sudo?
I’m wondering because it almost sounds like a permissions issue and you say it runs when you run it as root…
What command line are you using to run the actual playbook?
Adam
Found it.
This command wasn’t being run through the shell, on line 277 is the main problem.
We could pass “use_unsafe_shell=True” here, but that’s not ideal. Better would be to set the various environment options directly and then call the command not using the shell.
Please make sure there is a github ticket on this one, the fix is pretty straightforward and I’d like to get this included in our upcoming 1.6, which is due in a couple of weeks.
note: I’ll file the ticket on this one, don’t want it lost
Could you do an md5sum on the module? It should be located at /usr/share/ansible/packaging/apt and should match the following:
$ md5sum /usr/share/ansible/packaging/apt
7b3796da213ba4a5affab8413e7579d2 /usr/share/ansible/packaging/apt
You might also want to grab the module for that release from https://github.com/ansible/ansible/blob/release1.5.4/library/packaging/apt and diff them if the MD5’s don’t match.
The reason I ask is because the command shown in your output has leading environment variables set (ie. DEBIAN_FRONTEND=noninteractive), but as far as I can tell from the code in 1.5.4 that had been removed by that point.
Thanks!