blob: 2b905e9eb583a578140e7ff792edfa18a1684913 [file] [log] [blame]
Biser Milanov70bd8662023-12-11 16:28:21 +02001- 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)
Biser Milanovf95a3d12023-12-14 14:18:47 +02006 - name: Disable apt periodic updates
7 become: yes
8 ansible.builtin.lineinfile:
9 path: /etc/apt/apt.conf.d/888disable-periodic
10 line: "{{ item }}"
11 state: present
12 create: yes
13 loop:
14 - APT::Periodic::Update-Package-Lists "0";
15 - APT::Periodic::Unattended-Upgrade "0";
16
Biser Milanovfa64e292023-12-14 15:15:19 +020017 - name: Stop and disable units related to automatic, unattended upgrades
Biser Milanov52da3972023-12-12 15:20:57 +020018 become: true
19 ignore_errors: true
Biser Milanovfa64e292023-12-14 15:15:19 +020020 ansible.builtin.command: systemctl disable --now {{ item }}
21 loop:
22 - unattended-upgrades
23 - apt-daily.service
24 - apt-daily.timer
25 - apt-daily-upgrade.timer
26 - apt-daily-upgrade.service
Biser Milanov0e2feae2023-12-13 16:44:06 +020027
28 - name: Wait for the lock to get freed
29 become: true
Biser Milanovbc82cda2023-12-13 17:20:49 +020030 ignore_errors: true
31 ansible.builtin.shell: fuser /var/lib/dpkg/lock-frontend
32 register: out
Biser Milanov0e2feae2023-12-13 16:44:06 +020033 retries: 3600
34 delay: 1
Biser Milanovbc82cda2023-12-13 17:20:49 +020035 until: out.rc == 1