From 71fd08550408cf877b30a9f7bb59fe6842dd5c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Fri, 18 Aug 2017 11:10:36 +0200 Subject: [PATCH] Manage `unattended-upgrades`. --- CHANGELOG.md | 1 + README.md | 2 ++ defaults/main.yml | 7 +++++++ tasks/packages.yml | 10 ++++++++-- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 212fb7e..54bf352 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,3 +11,4 @@ * Ensure to never remove some packages pattern. * Manage general, periodic and dpkg config files. * Purge default configuration files sets by others apps. +* Manage `unattended-upgrades`. diff --git a/README.md b/README.md index ab9a596..25dbaca 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Manage APT repos, preferences and configuration for IPR's servers. * **apt_old_pkg_list** : The list of totally useless packages for a production server [default [see below](#tools)]. * **apt_old_pkg_state** : State of old packages [default : `absent`]. * **apt_old_pkg_manage** : If those old packages should be managed by the role [default : `true`]. +* **apt_unattended_upgrades** : If `unattended-upgrades` should be managed by the role [default : `yes`]. ## Example Playbook @@ -71,6 +72,7 @@ Manage Debian's sources.list : - Ensure to remove really useless packages from a default installation : * laptop-detect (if a server is a laptop…) * tasksel (simple interface) +- Manage `unattended-upgrades`. ## Development diff --git a/defaults/main.yml b/defaults/main.yml index ee0ae7c..dd1e720 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,7 @@ --- # defaults file for apt +# configuration apt_conf_update_pkg_lists: 1 apt_conf_download_upgradeable_pkg: 1 apt_conf_auto_clean_interval: 0 @@ -11,14 +12,17 @@ apt_conf_purge_list: - 70debconf apt_conf_purge_manage: true +# repositories apt_src_list_manage: true apt_purge_src_list_file: true apt_stretch_manage: true +# preferences apt_default_pref_path: '/etc/apt/preferences.d/default.pref' apt_default_pref_tpl: 'etc/apt/preferences.d/default.pref.j2' +# packages apt_tools_list: - aptitude apt_tools_state: 'installed' @@ -28,3 +32,6 @@ apt_old_pkg_list: - tasksel apt_old_pkg_state: 'absent' apt_old_pkg_manage: true + +# unattended-upgrades +apt_unattended_upgrades: yes diff --git a/tasks/packages.yml b/tasks/packages.yml index a49a1cc..b260639 100644 --- a/tasks/packages.yml +++ b/tasks/packages.yml @@ -2,7 +2,7 @@ # tasks file for packages # Packages -- name: Ensure useful tools packages +- name: INSTALL useful tools packages apt: name: '{{ item }}' state: '{{ apt_tools_state }}' @@ -10,7 +10,13 @@ - '{{ apt_tools_list }}' when: apt_tools_manage -- name: Ensure to purge useless packages +- name: INSTALL unattended-upgrades + apt: + pkg: "unattended-upgrades" + state: "{{ 'latest' if apt_unattended_upgrades else 'absent' }}" + when: apt_unattended_upgrades + +- name: INSTALL purge useless packages apt: name: '{{ item }}' state: '{{ apt_old_pkg_state }}'