From f596071f493237e3426f62cf53db01a477185a27 Mon Sep 17 00:00:00 2001 From: Jeltz Date: Sat, 26 Feb 2022 19:20:30 +0100 Subject: [PATCH] Cleanup apt_common --- playbooks/base.yml | 3 ++- roles/apt_common/tasks/main.yml | 4 ++++ roles/apt_common/templates/20auto-upgrades.j2 | 2 +- roles/apt_common/templates/50unattended-upgrades.j2 | 8 +++++--- roles/basesecurity/tasks/main.yml | 10 +--------- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/playbooks/base.yml b/playbooks/base.yml index 0ff21e7..18923f6 100755 --- a/playbooks/base.yml +++ b/playbooks/base.yml @@ -1,11 +1,11 @@ #!/usr/bin/env ansible-playbook --- -# Put a common configuration on all servers - hosts: all,!unifi vars: locales_default: en_US.UTF-8 locales_additional: - fr_FR.UTF-8 + apt_upgrade_email_address: monitoring.aurore@lists.crans.org roles: - debian_common - apt_common @@ -13,3 +13,4 @@ - basesecurity - logrotate - update_motd +... diff --git a/roles/apt_common/tasks/main.yml b/roles/apt_common/tasks/main.yml index 2cefc2a..32cb222 100644 --- a/roles/apt_common/tasks/main.yml +++ b/roles/apt_common/tasks/main.yml @@ -12,4 +12,8 @@ loop: - 20auto-upgrades - 50unattended-upgrades + +- name: Install debsums + apt: + name: debsums ... diff --git a/roles/apt_common/templates/20auto-upgrades.j2 b/roles/apt_common/templates/20auto-upgrades.j2 index a1ba39e..5c38f40 100644 --- a/roles/apt_common/templates/20auto-upgrades.j2 +++ b/roles/apt_common/templates/20auto-upgrades.j2 @@ -1,4 +1,4 @@ -// {{ ansible_managed }} +{{ ansible_managed | comment("c") }} APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1"; diff --git a/roles/apt_common/templates/50unattended-upgrades.j2 b/roles/apt_common/templates/50unattended-upgrades.j2 index b2932b5..3f02655 100644 --- a/roles/apt_common/templates/50unattended-upgrades.j2 +++ b/roles/apt_common/templates/50unattended-upgrades.j2 @@ -1,4 +1,4 @@ -// {{ ansible_managed }} +{{ ansible_managed | comment("c") }} Unattended-Upgrade::Origins-Pattern { "origin=Debian,codename=${distro_codename},label=Debian-Security"; @@ -9,8 +9,10 @@ Unattended-Upgrade::Package-Blacklist {}; Unattended-Upgrade::MinimalSteps "true"; Unattended-Upgrade::InstallOnShutdown "false"; -Unattended-Upgrade::Mail "{{ monitoring_mail }}"; -// Unattended-Upgrade::MailOnlyOnError "false"; +{% if apt_upgrade_email_address | default(False) %} +Unattended-Upgrade::Mail "{{ apt_upgrade_email_address }}"; +Unattended-Upgrade::MailOnlyOnError "false"; +{% endif %} Unattended-Upgrade::Remove-Unused-Kernel-Packages "false"; Unattended-Upgrade::Remove-New-Unused-Dependencies "false"; diff --git a/roles/basesecurity/tasks/main.yml b/roles/basesecurity/tasks/main.yml index 948a015..2d19e3e 100644 --- a/roles/basesecurity/tasks/main.yml +++ b/roles/basesecurity/tasks/main.yml @@ -23,12 +23,4 @@ - /bin/mount # Only root should mount - /bin/umount # Only root should umount ignore_errors: true # Sometimes file won't exist - -# See altered packages and configurations with `debsums -ca` -- name: Install debsums - apt: - name: debsums - state: present - register: apt_result - retries: 3 - until: apt_result is succeeded +...