geerlingguy / ansible-role-php-versions

Ansible Role - PHP Versions
https://galaxy.ansible.com/geerlingguy/php-versions/
MIT License
98 stars 73 forks source link

'Could not get lock' error in Purge PHP version packages step #29

Closed albert-gonzalez closed 6 years ago

albert-gonzalez commented 6 years ago

Hi!

I have some strange behaviour with the role. Sometimes works well and sometimes gives this error executing the Purge PHP version packages step:

failed: [default] (item=[u'php5.6-common', u'php7.0-common', u'php7.2-common', u'php7.3-common']) => {"changed": false, "item": ["php5.6-common", "php7.0-common", "php7.2-common", "php7.3-common"], "msg": "'apt-get remove 'php7.0-common' 'php7.2-common'' failed: E: Could not get 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", "rc": 100, "stderr": "E: Could not get 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_lines": ["E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)", "E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?"], "stdout": "", "stdout_lines": []}

Some info about the environment:

Maybe this error is related to issue #24

Thanks for your great work!

geerlingguy commented 6 years ago

@albert-gonzalez - Usually that error message means that either something that was running an apt-get operation failed mid-stream, or something else is still using apt-get currently. For example, if you start an Ansible playbook run that does a lot of package install/uninstall/purge/etc., then cancel out of it or it drops the connection, then you start another one, it can have this happen.

If you SSH into the server directly and run apt-get install -y [some package] it would have the same error message. Use ps aux to see what apt operations are currently running, then you have to wait for them to finish.