From 2835cfbc652e37f8daccc36282cfbd5f34cad918 Mon Sep 17 00:00:00 2001 From: Raoul Bhatia Date: Sat, 28 May 2016 16:41:01 +0200 Subject: Ubuntu: Add 16.04 Xenial Xerus and 16.10 Yakkety Yak. --- README.md | 2 +- manifests/params.pp | 10 ++++--- spec/classes/unattended_upgrades_spec.rb | 48 ++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index af74c63..4fd3f3e 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Using unattended\_upgrades simply consists of including the module and if needed * `dl_limit`(`undef`): Use a bandwidth limit for downloading, specified in kb/sec. * `enable` (`1`): Enable the automatic installation of updates. * `install_on_shutdown` (`false`): Install updates on shutdown instead of in the background. -* `legacy_origin` (`true` for Debian (squeeze), Ubuntu (precise, trusty, utopic, vivid, wily and default), `false`for Debian (wheezy and default)): Use the legacy `Unattended-Upgrade::Allowed-Origins` setting or the modern `Unattended-Upgrade::Origins-Pattern`. +* `legacy_origin` (`true` for Debian (squeeze), Ubuntu (precise, trusty, utopic, vivid, wily, xenial, yakkety, and default), `false` for Debian (wheezy and default)): Use the legacy `Unattended-Upgrade::Allowed-Origins` setting or the modern `Unattended-Upgrade::Origins-Pattern`. * `mail`: A hash to configure email behaviour with two possible keys: * `only_on_error` (`true`): Only send mail when something went wrong * `to` (`undef`): Email address to send email too diff --git a/manifests/params.pp b/manifests/params.pp index 046da45..007464c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -63,13 +63,11 @@ class unattended_upgrades::params { } } 'ubuntu': { - # TODO do we really want to pull in ${distro_codename}-updates by default? case $xfacts['lsbdistcodename'] { 'precise': { $legacy_origin = true $origins = [ '${distro_id}:${distro_codename}-security', #lint:ignore:single_quote_string_with_variables - #'${distro_id}:${distro_codename}-updates', #lint:ignore:single_quote_string_with_variables ] } @@ -77,14 +75,18 @@ class unattended_upgrades::params { $legacy_origin = true $origins = [ '${distro_id}:${distro_codename}-security', #lint:ignore:single_quote_string_with_variables - #'${distro_id}:${distro_codename}-updates', #lint:ignore:single_quote_string_with_variables + ] + } + 'xenial', 'yakkety': { + $legacy_origin = true + $origins = [ + '${distro_id}:${distro_codename}-security', #lint:ignore:single_quote_string_with_variables ] } default: { $legacy_origin = true $origins = [ '${distro_id}:${distro_codename}-security', #lint:ignore:single_quote_string_with_variables - #'${distro_id}:${distro_codename}-updates', #lint:ignore:single_quote_string_with_variables ] } } diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index c3b9673..ecbce37 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -300,6 +300,54 @@ describe 'unattended_upgrades' do end end + context 'with defaults on Ubuntu 16.04 Xenial Xerus' do + let(:facts) do + { + osfamily: 'Debian', + lsbdistid: 'Ubuntu', + lsbdistcodename: 'xenial', + lsbrelease: '16.04', + lsbdistrelease: '16.04' + } + end + it do + should create_file(file_unattended).with( + owner: 'root', + group: 'root', + mode: '0644' + ).with_content( + # This is the only section that's different for Ubuntu compared to Debian + /\Unattended-Upgrade::Allowed-Origins\ {\n + \t"\${distro_id}\:\${distro_codename}-security";\n + };/x + ) + end + end + + context 'with defaults on Ubuntu 16.10 Yakkety Yak' do + let(:facts) do + { + osfamily: 'Debian', + lsbdistid: 'Ubuntu', + lsbdistcodename: 'yakkety', + lsbrelease: '16.10', + lsbdistrelease: '16.10' + } + end + it do + should create_file(file_unattended).with( + owner: 'root', + group: 'root', + mode: '0644' + ).with_content( + # This is the only section that's different for Ubuntu compared to Debian + /\Unattended-Upgrade::Allowed-Origins\ {\n + \t"\${distro_id}\:\${distro_codename}-security";\n + };/x + ) + end + end + context 'with defaults on Raspbian' do let(:facts) do { -- cgit v1.2.3 From cf722ccf9077066a35ab05e5e2f1d9c8302dce16 Mon Sep 17 00:00:00 2001 From: Raoul Bhatia Date: Sat, 28 May 2016 16:55:29 +0200 Subject: =?UTF-8?q?lsbrelease:=20This=20legacy=20fact=20is=20hidden=20by?= =?UTF-8?q?=20default=20in=20Facter=E2=80=99s=20command-line=20output.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://docs.puppet.com/facter/latest/core_facts.html#lsbrelease --- spec/classes/unattended_upgrades_spec.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index ecbce37..e0b2263 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -210,7 +210,6 @@ describe 'unattended_upgrades' do osfamily: 'Debian', lsbdistid: 'Ubuntu', lsbdistcodename: 'precise', - lsbrelease: '12.04', lsbdistrelease: '12.04' } end @@ -234,7 +233,6 @@ describe 'unattended_upgrades' do osfamily: 'Debian', lsbdistid: 'Ubuntu', lsbdistcodename: 'trusty', - lsbrelease: '14.04', lsbdistrelease: '14.04' } end @@ -258,7 +256,6 @@ describe 'unattended_upgrades' do osfamily: 'Debian', lsbdistid: 'Ubuntu', lsbdistcodename: 'vivid', - lsbrelease: '15.04', lsbdistrelease: '15.04' } end @@ -282,7 +279,6 @@ describe 'unattended_upgrades' do osfamily: 'Debian', lsbdistid: 'Ubuntu', lsbdistcodename: 'wily', - lsbrelease: '15.10', lsbdistrelease: '15.10' } end @@ -306,7 +302,6 @@ describe 'unattended_upgrades' do osfamily: 'Debian', lsbdistid: 'Ubuntu', lsbdistcodename: 'xenial', - lsbrelease: '16.04', lsbdistrelease: '16.04' } end @@ -330,7 +325,6 @@ describe 'unattended_upgrades' do osfamily: 'Debian', lsbdistid: 'Ubuntu', lsbdistcodename: 'yakkety', - lsbrelease: '16.10', lsbdistrelease: '16.10' } end -- cgit v1.2.3 From 33fabe02547a8c4b15278fe8636d83fe1354f4ae Mon Sep 17 00:00:00 2001 From: Raoul Bhatia Date: Sat, 28 May 2016 17:01:25 +0200 Subject: Ubuntu: Issue EOL warning for unsupported release. --- manifests/params.pp | 8 +++++++- spec/classes/unattended_upgrades_spec.rb | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 007464c..4451bf1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -21,6 +21,7 @@ class unattended_upgrades::params { 'lsbdistid' => $::lsbdistid, 'lsbdistcodename' => $::lsbdistcodename, 'lsbmajdistrelease' => $::lsbmajdistrelease, + 'lsbdistrelease' => $::lsbdistrelease, } } else { # Strict variables facts lookup compatibility @@ -37,6 +38,10 @@ class unattended_upgrades::params { true => $::lsbmajdistrelease, default => undef, }, + 'lsbdistrelease' => defined('$lsbdistrelease') ? { + true => $::lsbdistrelease, + default => undef, + }, } } @@ -71,7 +76,7 @@ class unattended_upgrades::params { ] } - 'trusty', 'utopic', 'vivid', 'wily': { + 'trusty', 'wily': { $legacy_origin = true $origins = [ '${distro_id}:${distro_codename}-security', #lint:ignore:single_quote_string_with_variables @@ -84,6 +89,7 @@ class unattended_upgrades::params { ] } default: { + warning("Ubuntu ${xfacts['lsbdistrelease']} \"${xfacts['lsbdistcodename']}\" has reached End of Life - please upgrade!") $legacy_origin = true $origins = [ '${distro_id}:${distro_codename}-security', #lint:ignore:single_quote_string_with_variables diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index e0b2263..d927a55 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -271,6 +271,9 @@ describe 'unattended_upgrades' do };/x ) end + # TODO: implement test case for "warning", similar to + # w = 'Ubuntu 15.04 "vivid" has reached End of Life - please upgrade!' + # it_behaves_like 'has_warning', pp, w end context 'with defaults on Ubuntu 15.10 Wily Werewolf' do -- cgit v1.2.3