I am having some issues when running ansible against target running unattende-upgrades.
Sometimes run failed with this error :
TASK [figlet : Install figlet] *************************************************
fatal: [server01]: FAILED! => {"cache_update_time": 1772446127, "cache_updated": false, "changed": false, "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" install 'figlet=2.2.5-3+b1'' failed: E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 5374 (unattended-upgr)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?\n", "rc": 100, "stderr": "E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 5374 (unattended-upgr)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?\n", "stderr_lines": ["E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 5374 (unattended-upgr)", "E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?"], "stdout": "", "stdout_lines": []}
When this happen I just need to re-run the playbook and it works. Now I want to make my playbook bulletproof to this error. After reading documentation, the cleanest way seems to use the module_defaults to increase lock_timeout for ansible.builtin.apt
Your post title says you’re using ansible.builtin.package, but the code you shared has a default for ansible.builtin.apt. Those are different modules, and as such, the defaults applied to one won’t apply to the other.
Could you share the code from the role that’s actually doing the package updates?
@romgo there was a bug with module_defaults not being recognized as it went by the task action, not the module executed, please check with the latest version of ansible, if it still does not work, open a bug report new issue