From c75ddcf1a3a6240a1456339d6e554e42c239ad47 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 5 Oct 2015 21:13:09 +0200 Subject: [PATCH] Enabling and configuring unattended-upgrades. --- roles/custom/files/20-auto-upgrades | 5 ++++ roles/custom/files/50-unattended-upgrades | 33 ++++++++++++++++++++++ roles/custom/tasks/custom.yml | 9 ------ roles/custom/tasks/main.yml | 5 ++++ roles/custom/tasks/unattended-upgrades.yml | 32 +++++++++++++++++++++ 5 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 roles/custom/files/20-auto-upgrades create mode 100644 roles/custom/files/50-unattended-upgrades create mode 100644 roles/custom/tasks/unattended-upgrades.yml diff --git a/roles/custom/files/20-auto-upgrades b/roles/custom/files/20-auto-upgrades new file mode 100644 index 0000000..f82e52c --- /dev/null +++ b/roles/custom/files/20-auto-upgrades @@ -0,0 +1,5 @@ +APT::Periodic::Update-Package-Lists "1"; +APT::Periodic::Download-Upgradeable-Packages "1"; +APT::Periodic::AutocleanInterval "7"; +APT::Periodic::Unattended-Upgrade "1"; +//APT::Periodic::RandomSleep "0"; diff --git a/roles/custom/files/50-unattended-upgrades b/roles/custom/files/50-unattended-upgrades new file mode 100644 index 0000000..970bf45 --- /dev/null +++ b/roles/custom/files/50-unattended-upgrades @@ -0,0 +1,33 @@ +// Automatically upgrade packages from these (origin, archive) pairs +Unattended-Upgrade::Allowed-Origins { + "${distro_id}:${distro_codename}"; + "${distro_id}:${distro_codename}-security"; + "${distro_id}:${distro_codename}-updates"; + "${distro_id}:${distro_codename}-proposed"; + "${distro_id}:${distro_codename}-backports"; + "LP-PPA-libreoffice-libreoffice-5-0:trusty"; + "LP-PPA-ansible-ansible:trusty"; + "BgLUG:trusty"; +}; + +// List of packages to not update +Unattended-Upgrade::Package-Blacklist { +// "vim"; +// "libc6"; +// "libc6-dev"; +// "libc6-i686"; +}; + +// Send email to this address for problems or packages upgrades +// If empty or unset then no email is sent, make sure that you +// have a working mail setup on your system. The package 'mailx' +// must be installed or anything that provides /usr/bin/mail. +//Unattended-Upgrade::Mail "root@localhost"; + +// Do automatic removal of new unused dependencies after the upgrade +// (equivalent to apt-get autoremove) +Unattended-Upgrade::Remove-Unused-Dependencies "true"; + +// Automatically reboot *WITHOUT CONFIRMATION* if a +// the file /var/run/reboot-required is found after the upgrade +Unattended-Upgrade::Automatic-Reboot "false"; diff --git a/roles/custom/tasks/custom.yml b/roles/custom/tasks/custom.yml index 86533bd..d843a08 100644 --- a/roles/custom/tasks/custom.yml +++ b/roles/custom/tasks/custom.yml @@ -1,20 +1,11 @@ --- -- name: Adding sys42 repo - lineinfile: - dest: /etc/apt/sources.list.d/sys42.list - line: 'deb http://bglug.sys42.eu/ubuntu trusty main' - create: yes - state: present - when: ansible_product_name == 'VirtualBox' - - name: Adding mirrored sys42 repo lineinfile: dest: /etc/apt/sources.list.d/sys42.list line: 'deb http://{{ ansible_local.domain.mirrorpath }}bglug.sys42.eu/ubuntu trusty main' create: yes state: present - when: ansible_product_name != 'VirtualBox' - name: Reloading available packages apt: diff --git a/roles/custom/tasks/main.yml b/roles/custom/tasks/main.yml index 99dbe66..00bcd84 100644 --- a/roles/custom/tasks/main.yml +++ b/roles/custom/tasks/main.yml @@ -1,6 +1,11 @@ --- # BgLUG customization +- include: unattended-upgrades.yml + tags: + - custom + - unattended-upgrades + - include: custom.yml tags: - custom diff --git a/roles/custom/tasks/unattended-upgrades.yml b/roles/custom/tasks/unattended-upgrades.yml new file mode 100644 index 0000000..ebd68f0 --- /dev/null +++ b/roles/custom/tasks/unattended-upgrades.yml @@ -0,0 +1,32 @@ +--- + +- name: Adding proposed sources to apt/sources.list + lineinfile: + line: "{{ item }}" + dest: /etc/apt/sources.list + with_items: + - "deb http://{{ ansible_local.domain.mirrorpath }}archive.ubuntu.com/ubuntu/ trusty-proposed restricted main multiverse universe" + - "deb-src http://{{ ansible_local.domain.mirrorpath }}archive.ubuntu.com/ubuntu/ trusty-proposed restricted main multiverse universe" + sudo: yes + +- name: Ensure unattended-upgrades is installed + apt: + name: unattended-upgrades + state: present + sudo: yes + + - name: Ensure update-notifier-common is installed + apt: + name: update-notifier-common + state: present + sudo: yes + +- name: Configuring unattended upgrades from file + copy: + src: 50-unattended-upgrades + dest: /etc/apt/apt.conf.d/50-unattended-upgrades + +- name: Activating automatic updates + copy: + src: 20-auto-upgrades + dest: /etc/apt/apt.conf.d/20-auto-upgrades