Skip to main content

Tag: Ansible

Ansible APT module randomly fails

While using Ansible to automate the system updates on my personal servers, I ran into an issue where the apt module randomly failed with the error: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false, "msg": "Failed to lock apt for exclusive operation: Failed to lock directory /var/lib/apt/lists/: E:Could not get lock /var/lib/apt/lists/lock."} Apparently it has something to do with the Unattended Upgrades service. Since this is something I want to keep enabled, the workaround is to set some retries on the task that uses the apt module.