blob: 2b905e9eb583a578140e7ff792edfa18a1684913 [file] [log] [blame]
- hosts: all
tasks:
# Unattended-upgrades sometimes do not complete in time and other parts of the setup that use
# `apt` fail with a variation of:
# E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 7929 (unattended-upgr)
- name: Disable apt periodic updates
become: yes
ansible.builtin.lineinfile:
path: /etc/apt/apt.conf.d/888disable-periodic
line: "{{ item }}"
state: present
create: yes
loop:
- APT::Periodic::Update-Package-Lists "0";
- APT::Periodic::Unattended-Upgrade "0";
- name: Stop and disable units related to automatic, unattended upgrades
become: true
ignore_errors: true
ansible.builtin.command: systemctl disable --now {{ item }}
loop:
- unattended-upgrades
- apt-daily.service
- apt-daily.timer
- apt-daily-upgrade.timer
- apt-daily-upgrade.service
- name: Wait for the lock to get freed
become: true
ignore_errors: true
ansible.builtin.shell: fuser /var/lib/dpkg/lock-frontend
register: out
retries: 3600
delay: 1
until: out.rc == 1