Biser Milanov | 70bd866 | 2023-12-11 16:28:21 +0200 | [diff] [blame] | 1 | - hosts: all |
| 2 | tasks: |
| 3 | # Unattended-upgrades sometimes do not complete in time and other parts of the setup that use |
| 4 | # `apt` fail with a variation of: |
| 5 | # E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 7929 (unattended-upgr) |
| 6 | - name: Stop and disable the service unattended-upgrades |
Biser Milanov | 52da397 | 2023-12-12 15:20:57 +0200 | [diff] [blame] | 7 | become: true |
| 8 | ignore_errors: true |
Biser Milanov | 0e2feae | 2023-12-13 16:44:06 +0200 | [diff] [blame^] | 9 | ansible.builtin.command: systemctl disable --now unattended-upgrades |
| 10 | |
| 11 | - name: Wait for the lock to get freed |
| 12 | become: true |
| 13 | ansible.builtin.stat: |
| 14 | path: /var/lib/dpkg/lock-frontend |
| 15 | register: fstat |
| 16 | retries: 3600 |
| 17 | delay: 1 |
| 18 | until: not fstat.stat.exists |