0

I get this series of errors when trying to do a service install using the apt module with Ansible on an Ubuntu 14.x box.

On most of the other Ubuntu 14.x boxes it works fine.

There's a handful that it doesn't run on.

The relevant area of the playbook in tasks main yaml:

name: Install the required packages for keyczar
apt: name={{ keyczar_name }} state=installed

The definition in vars main and debian yaml:

keyczar_name: python-keyczar

Prior to the run, the lock file /var/lib/dpkg/lock does not exist. After the failed run, it does exist. Manually removing it with rm and rerunning does nothing. The equivalent CLI being run is apt-get install python-keyczar -y which if run manually works. This concerns me because it is the first time I have seen a package get rejected when run under Ansible but works fine when installing manually. Makes no sense.

The specific error is:

fatal: [qaevt5.channel-corp.com]: FAILED! => {"cache_update_time": 0, "cache_updated": false, "changed": false, "failed": true, "msg": "'/usr/bin/ap\ t-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" --simulate install 'python-keyczar'' failed: E: Could not ge\ t lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)\nE: Unable to lock the administration directory (/var/lib/dpkg/), is another\ process using it?\n", "stderr": "E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)\nE: Unable to lock the admi\ nistration directory (/var/lib/dpkg/), is another process using it?\n", "stdout": "", "stdout_lines": []}

fuser and lsof show no other processes holding the lock.

After the apt-get install python-keyczar -y is run manually, and the ansible run rerun, fine no problem. Package "ok".

The above lock file has other associated files post-manual run.

ls -l /var/cache/apt/archives/lock /var/lib/apt/lists/lock /var/lib/dpkg/lock
-rw-r----- 1 root root 0 Aug  5  2015 /var/cache/apt/archives/lock
-rw-r----- 1 root root 0 Mar 30 00:03 /var/lib/apt/lists/lock
-rw-r----- 1 root root 0 Mar 30 15:13 /var/lib/dpkg/lock

I am going to do the manual run on the half-dozen boxes where this is happening on. The other several dozen had no such issue. Of course, until this is clarified, it has to be manually done which really defeats the purpose.

0

I'm having the same issue. If you're ansible script is written well, and can be sure that no process is locking apt, then you can make sure that the lock doesn't exists before running the apt module.

You can do this with the file model with become: true state=absent on the lock file.

This is a horrible work around, but i blame ubuntu :P I encounter no such problems with Arch Linux

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.