Keep APT list directory
/var/lib/apt/lists
was deleted because Ansible APT module use mtime
of this directory even when this directory is empty. However Cache.update
method from Python APT module - which is called by Ansible APT module - expects this directory to exist.
Fix this error:
Failed to lock apt for exclusive operation
The full traceback is:
File "ansible_apt_payload.zip/ansible/modules/packaging/os/apt.py", line 1098, in main
File "/usr/lib/python3/dist-packages/apt/cache.py", line 567, in update
with _WrappedLock(apt_pkg.config.find_dir("Dir::State::Lists")):
File "/usr/lib/python3/dist-packages/apt/cache.py", line 93, in __enter__
(self._path, e))