Fixed unattended upgrades and configure time for updates/upgrades

Previously only unattended updates (i.e. apt update) was working. Unattended
upgrades (i.e. apt upgrade) are disabled by default and needed to be enabled
with a config file.
This commit is contained in:
Julian 2022-01-07 17:17:56 +01:00
parent d5a9e6bd05
commit 075823ffb5
No known key found for this signature in database
GPG key ID: 2F811E2338EE029B
5 changed files with 64 additions and 2 deletions

View file

@ -9,20 +9,52 @@
tags:
- update
- name: install unattended-upgrades
- name: install unattended upgrades
apt:
name: unattended-upgrades
purge: yes
state: "{% if update.unattended %}present{% else %}absent{% endif %}"
- name: configure unattended-upgrades
- name: configure unattended upgrades
when: update.unattended
ansible.builtin.copy:
src: "50unattended-upgrades"
dest: "/etc/apt/apt.conf.d/50unattended-upgrades"
owner: root
group: root
mode: 0644
- name: overwrite apt-daily.timer
when: update.unattended
ansible.builtin.template:
src: "apt-daily.timer.j2"
dest: "/etc/systemd/system/apt-daily.timer"
owner: root
group: root
mode: 0644
notify:
- restart apt-daily.timer
- name: overwrite apt-daily-upgrade.timer
when: update.unattended
ansible.builtin.template:
src: "apt-daily-upgrade.timer.j2"
dest: "/etc/systemd/system/apt-daily-upgrade.timer"
owner: root
group: root
mode: 0644
notify:
- restart apt-daily-upgrade.timer
- name: enable auto upgrades
when: update.unattended
ansible.builtin.copy:
src: "/usr/share/unattended-upgrades/20auto-upgrades"
dest: "/etc/apt/apt.conf.d/20auto-upgrades"
owner: root
group: root
mode: 0644
remote_src: yes
- name: clean
command: apt-get clean