summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Galić <i.galic@brainsware.org>2015-09-21 14:48:40 +0200
committerIgor Galić <i.galic@brainsware.org>2015-09-21 14:48:40 +0200
commit87f195af653ea2e23ce1816d557d250f8d6b86c4 (patch)
tree5239239bb7bedd52f0bb334e268a2811ab7d4c2a
parenta5e8ebe70724de398e5e1cfa8a9c5324729c8c91 (diff)
parent0d2b73da1a528daed34b9bff1f120145da5799fd (diff)
Merge pull request #26 from raoulbhatia/fixes
Enhancements by merging Debian defaults, puppetlabs-apt and own research
-rw-r--r--manifests/params.pp46
-rw-r--r--spec/classes/unattended_upgrades_spec.rb134
2 files changed, 165 insertions, 15 deletions
diff --git a/manifests/params.pp b/manifests/params.pp
index 04ba3ec..4e1b9de 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -1,3 +1,4 @@
+#
class unattended_upgrades::params {
if $::osfamily != 'Debian' {
@@ -35,21 +36,48 @@ class unattended_upgrades::params {
'debian', 'raspbian': {
case $xfacts['lsbdistcodename'] {
'squeeze': {
- $legacy_origin = true
- $origins = ['${distro_id} oldstable', #lint:ignore:single_quote_string_with_variables
- '${distro_id} ${distro_codename}-security', #lint:ignore:single_quote_string_with_variables
- '${distro_id} ${distro_codename}-lts',] #lint:ignore:single_quote_string_with_variables
+ $legacy_origin = true
+ $origins = ['${distro_id} oldoldstable', #lint:ignore:single_quote_string_with_variables
+ '${distro_id} ${distro_codename}-security', #lint:ignore:single_quote_string_with_variables
+ '${distro_id} ${distro_codename}-lts',] #lint:ignore:single_quote_string_with_variables
+ }
+ 'wheezy': {
+ $legacy_origin = false
+ $origins = ['origin=Debian,archive=stable,label=Debian-Security',
+ 'origin=Debian,archive=oldstable,label=Debian-Security',]
}
default: {
- $legacy_origin = false
- $origins = ['origin=Debian,archive=stable,label=Debian-Security']
+ $legacy_origin = false
+ $origins = ['origin=Debian,codename=${distro_codename},label=Debian-Security',] #lint:ignore:single_quote_string_with_variables
}
}
}
'ubuntu': {
- $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
+ # TODO do we really want to pull in ${distro_codename}-updates by default?
+ case $distcodename {
+ '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
+ ]
+
+ }
+ 'trusty', 'utopic', 'vivid', 'wily': {
+ $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
+ ]
+ }
+ 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
+ ]
+ }
+ }
}
default: {
fail('Please explicitly specify unattended_upgrades::legacy_origin and unattended_upgrades::origins')
diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb
index 1333434..72291d5 100644
--- a/spec/classes/unattended_upgrades_spec.rb
+++ b/spec/classes/unattended_upgrades_spec.rb
@@ -6,7 +6,7 @@ describe 'unattended_upgrades' do
let(:facts) { {
:osfamily => 'Debian',
:lsbdistid => 'Debian',
- :lsbistcodename => 'wheezy',
+ :lsbdistcodename => 'wheezy',
:lsbrelease => '7.0.3',
} }
let(:pre_condition) {
@@ -92,11 +92,94 @@ describe 'unattended_upgrades' do
}
end
- context 'with defaults on ubuntu' do
+ context 'with defaults on Debian 6 Squeeze' do
+ let(:facts) { {
+ :osfamily => 'Debian',
+ :lsbdistid => 'Debian',
+ :lsbdistcodename => 'squeeze',
+ :lsbdistrelease => '6.0.10',
+ } }
+ it {
+ should create_file(file_unattended).with({
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ }).with_content(
+ # This section varies for different releases
+ /\Unattended-Upgrade::Allowed-Origins\ {\n
+ \t"\${distro_id}\ oldoldstable";\n
+ \t"\${distro_id}\ \${distro_codename}-security";\n
+ \t"\${distro_id}\ \${distro_codename}-lts";\n
+ };/x
+ )}
+ end
+
+ context 'with defaults on Debian 7 Wheezy' do
+ let(:facts) { {
+ :osfamily => 'Debian',
+ :lsbdistid => 'Debian',
+ :lsbdistcodename => 'wheezy',
+ :lsbdistrelease => '7.1',
+ } }
+ it {
+ should create_file(file_unattended).with({
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ }).with_content(
+ # This section varies for different releases
+ /\Unattended-Upgrade::Origins-Pattern\ {\n
+ \t"origin=Debian,archive=stable,label=Debian-Security";\n
+ \t"origin=Debian,archive=oldstable,label=Debian-Security";\n
+ };/x
+ )}
+ end
+
+ context 'with defaults on Debian 8 Jessie' do
+ let(:facts) { {
+ :osfamily => 'Debian',
+ :lsbdistid => 'Debian',
+ :lsbdistcodename => 'jessie',
+ :lsbdistrelease => '8.2',
+ } }
+ it {
+ should create_file(file_unattended).with({
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ }).with_content(
+ # This section varies for different releases
+ /\Unattended-Upgrade::Origins-Pattern\ {\n
+ \t"origin=Debian,codename=\${distro_codename},label=Debian-Security";\n
+ };/x
+ )}
+ end
+
+ context 'with defaults on Ubuntu 12.04LTS Precise Pangolin' do
+ let(:facts) { {
+ :osfamily => 'Debian',
+ :lsbdistid => 'Ubuntu',
+ :lsbdistcodename => 'precise',
+ :lsbrelease => '12.04',
+ } }
+ it {
+ 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
+
+ context 'with defaults on Ubuntu 14.04LTS Trusty Tahr' do
let(:facts) { {
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
- :lsbistcodename => 'trusty',
+ :lsbdistcodename => 'trusty',
:lsbrelease => '14.04',
} }
it {
@@ -107,8 +190,47 @@ describe 'unattended_upgrades' do
}).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
- \t"\${distro_id}\ \${distro_codename}-updates";\n
+ \t"\${distro_id}\:\${distro_codename}-security";\n
+ };/x
+ )}
+ end
+
+ context 'with defaults on Ubuntu 15.04 Vivid Vervet' do
+ let(:facts) { {
+ :osfamily => 'Debian',
+ :lsbdistid => 'Ubuntu',
+ :lsbdistcodename => 'vivid',
+ :lsbrelease => '15.04',
+ } }
+ it {
+ 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
+
+ context 'with defaults on Ubuntu 15.10 Wily Werewolf' do
+ let(:facts) { {
+ :osfamily => 'Debian',
+ :lsbdistid => 'Ubuntu',
+ :lsbdistcodename => 'wily',
+ :lsbrelease => '15.10',
+ } }
+ it {
+ 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
@@ -117,7 +239,7 @@ describe 'unattended_upgrades' do
let(:facts) { {
:osfamily => 'Debian',
:lsbdistid => 'Raspbian',
- :lsbistcodename => 'jessie',
+ :lsbdistcodename => 'jessie',
:lsbrelease => '8.0',
} }
it {