Unattended upgrades breaks re-runs of the Ansible playbook that depend on `apt`
This happens sometimes in CI when you change packages installed with apt
failed: [860-high-node-cpu-usage-by-k3s-and-iptables-procs] (item=iptables) => changed=false
ansible_loop_var: item
item: iptables
msg: |-
'apt-get remove 'iptables'' failed: E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
rc: 100
stderr: |-
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
stderr_lines: <omitted>
stdout: ''
stdout_lines: <omitted>
failed: [860-high-node-cpu-usage-by-k3s-and-iptables-procs] (item=nftables) => changed=false
ansible_loop_var: item
item: nftables
msg: |-
'apt-get remove 'nftables'' failed: E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
rc: 100
stderr: |-
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
stderr_lines: <omitted>
stdout: ''
stdout_lines: <omitted>
failed: [860-high-node-cpu-usage-by-k3s-and-iptables-procs] (item=netfilter-persistent) => changed=false
ansible_loop_var: item
item: netfilter-persistent
msg: |-
'apt-get remove 'netfilter-persistent'' failed: E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
rc: 100
stderr: |-
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
stderr_lines: <omitted>
stdout: ''
stdout_lines: <omitted>
It seems to happen because unattended-upgrades
takes the lock, but I don't remember exactly how I got to that conclusion (I researched this problem a few weeks ago)
Possible solutions:
- Reduce how often unattended-upgrades runs, so this happens less
- Disable unattended-upgrades at the beginning of the playbook and re-enable it at the end