summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Gemfile7
-rw-r--r--README.md127
-rw-r--r--manifests/apticron.pp2
-rw-r--r--manifests/cron/base.pp20
-rw-r--r--manifests/cron/dist_upgrade.pp21
-rw-r--r--manifests/cron/download.pp27
-rw-r--r--manifests/dist_upgrade.pp5
-rw-r--r--manifests/init.pp24
-rw-r--r--manifests/listchanges.pp2
-rw-r--r--manifests/params.pp19
-rw-r--r--manifests/preferences.pp5
-rw-r--r--manifests/preseeded_package.pp5
-rw-r--r--manifests/reboot_required_notify.pp22
-rw-r--r--manifests/reboot_required_notify/jessie.pp28
-rw-r--r--manifests/reboot_required_notify/wheezy.pp23
-rw-r--r--manifests/sources_list.pp5
-rw-r--r--manifests/upgrade_package.pp4
-rw-r--r--spec/acceptance/apt_spec.rb21
-rw-r--r--spec/acceptance/nodesets/debian-8-x86_64-docker.yml19
l---------spec/acceptance/nodesets/default.yml1
-rw-r--r--spec/spec_helper_acceptance.rb18
-rw-r--r--templates/50unattended-upgrades.erb4
-rw-r--r--templates/Debian/apticron.erb (renamed from templates/Debian/apticron_wheezy.erb)2
l---------templates/Debian/apticron_jessie.erb1
-rw-r--r--templates/Debian/apticron_lenny.erb50
l---------templates/Debian/apticron_sid.erb1
-rw-r--r--templates/Debian/apticron_squeeze.erb82
-rw-r--r--templates/Debian/listchanges.erb (renamed from templates/Debian/listchanges_lenny.erb)0
l---------templates/Debian/listchanges_jessie.erb1
l---------templates/Debian/listchanges_sid.erb1
l---------templates/Debian/listchanges_squeeze.erb1
l---------templates/Debian/listchanges_wheezy.erb1
-rw-r--r--templates/Debian/preferences_lenny.erb25
-rw-r--r--templates/Debian/sources.list.erb2
-rw-r--r--templates/Ubuntu/sources.list.erb4
36 files changed, 252 insertions, 329 deletions
diff --git a/.gitignore b/.gitignore
index a54aa97..3b626b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
/spec/fixtures/modules/*
!/spec/fixtures/modules/apt
!/spec/fixtures/modules/apt/*
+/log
/.vagrant/
/.bundle/
/coverage/
diff --git a/Gemfile b/Gemfile
index 8925a90..a2756c4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -11,3 +11,10 @@ group :test do
gem "rspec-puppet-facts"
gem "mocha"
end
+
+group :system_tests do
+ gem 'beaker', :require => false
+ gem 'beaker-rspec', :require => false
+ gem 'beaker_spec_helper', :require => false
+ gem 'serverspec', :require => false
+end
diff --git a/README.md b/README.md
index 5f6a109..9405bd8 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,6 @@
* [Classes](#classes)
* [apt](#apt)
* [apt::apticron](#apt-apticron)
- * [apt::cron::download](#apt-cron-download)
* [apt::cron::dist_upgrade](#apt-cron-dist_upgrade)
* [apt::dist_upgrade](#apt-dist_upgrade)
* [apt::dist_upgrade::initiator](#apt-dist_upgrade-initiator)
@@ -23,12 +22,13 @@
* [apt::preseeded_package](#apt-preseeded_package)
* [apt::sources_list](#apt-sources_list)
* [apt::key](#apt-key)
- * [apt::key::plain](#apt-key-plain)
+ * [`apt::key::plain`](#apt-key-plain)
* [apt::upgrade_package](#apt-upgrade_package)
* [Resources](#ressources)
* [File\['apt_config'\]](#fileapt_config)
* [Exec\['apt_updated'\]](#execapt_updated)
* [Tests](#tests)
+ * [Acceptance Tests](#acceptance-tests)
* [Licensing](#licensing)
@@ -49,6 +49,13 @@ Ubuntu support is lagging behind but not absent either.
## Upgrade Notice<a name="upgrade-notice"></a>
+ * The `$apt_cron_hours` global variable is deprecated.
+ Use `apt::cron::dist_upgrade`'s `cron_hours` parameter instead.
+
+ * The default value of the `$repos` parameter was removed since the logic is
+ now in the `apt::params` class. If you have explicitly set `$repos` to
+ 'auto' in your manifests, you should remove this.
+
* The `disable_update` parameter has been removed. The main apt class
defaults to *not* run an `apt-get update` on every run anyway so this
parameter seems useless.
@@ -72,17 +79,16 @@ Ubuntu support is lagging behind but not absent either.
instantiating the class with those variables instead. For example, if you
had the following in your manifests:
- $apt_debian_url = 'http://localhost:9999/debian/'
- $apt_use_next_release = true
- include apt
+ $apt_debian_url = 'http://localhost:9999/debian/'
+ $apt_use_next_release = true
+ include apt
you will need to remove the variables, and the include and instead do
the following:
- class {
- 'apt':
- debian_url => 'http://localhost:9999/debian/',
- use_next_release => true;
+ class { 'apt':
+ debian_url => 'http://localhost:9999/debian/',
+ use_next_release => true;
}
previously, you could manually set `$lsbdistcodename` which would enable forced
@@ -94,26 +100,24 @@ Ubuntu support is lagging behind but not absent either.
you to trigger upgrades:
include apt::dist_upgrade
- class {
- 'apt':
- codename => 'wheezy',
- notify => Exec['apt_dist-upgrade'];
+ class { 'apt':
+ codename => 'wheezy',
+ notify => Exec['apt_dist-upgrade'];
}
* the `apticron` class has been moved to a parameterized class. if you were
including this class before, you will need to move to instantiating the
class instead. For example, if you had the following in your manifests:
- $apticron_email = 'foo@example.com'
- $apticron_notifynew = '1'
- ... any $apticron_* variables
- include apticron
+ $apticron_email = 'foo@example.com'
+ $apticron_notifynew = '1'
+ ... any $apticron_* variables
+ include apticron
you will need to remove the variables, and the include and instead do the
following:
- class {
- 'apt::apticron':
+ class { 'apt::apticron':
email => 'foo@example.com',
notifynew => '1';
}
@@ -123,16 +127,15 @@ Ubuntu support is lagging behind but not absent either.
to move to instantiating the class with those variables instead. For example,
if you had the following in your manifests:
- $apt_listchanges_email = 'foo@example.com'
- ... any $apt_listchanges_* variables
- include apt::listchanges
+ $apt_listchanges_email = 'foo@example.com'
+ ... any $apt_listchanges_* variables
+ include apt::listchanges
you will need to remove the variables, and the include and instead do the
following:
- class {
- 'apt::listchanges':
- email => 'foo@example.com';
+ class { 'apt::listchanges':
+ email => 'foo@example.com';
}
* the `apt::proxy_client` class has been moved to a paramterized class. if you
@@ -140,18 +143,17 @@ Ubuntu support is lagging behind but not absent either.
to move to instantiating the class with those variables instead. For example,
if you had the following in your manifests:
- $apt_proxy = 'http://proxy.domain'
- $apt_proxy_port = 666
- include apt::proxy_client
+ $apt_proxy = 'http://proxy.domain'
+ $apt_proxy_port = 666
+ include apt::proxy_client
you will need to remove the variables, and the include and instead do the
following:
- class {
- 'apt::proxy_client':
- proxy => 'http://proxy.domain',
- port => '666';
- }
+ class { 'apt::proxy_client':
+ proxy => 'http://proxy.domain',
+ port => '666';
+ }
# Requirements<a name="requirements"></a>
@@ -204,7 +206,7 @@ Example usage:
### use_lts
If this variable is set to true the CODENAME-lts sources (such as
- squeeze-lts) are added.
+ wheezy-lts) are added.
By default this is false for backward compatibility with older
versions of this module.
@@ -212,7 +214,7 @@ Example usage:
### use_volatile
If this variable is set to true the CODENAME-updates sources (such as
- squeeze-updates) are added.
+ wheezy-updates) are added.
By default this is false for backward compatibility with older
versions of this module.
@@ -234,11 +236,11 @@ Example usage:
By default this is false for backward compatibility with older
versions of this module.
-### debian_url, security_url, backports_url, volatile_url
+### debian_url, security_url, volatile_url
These variables allow to override the default APT mirrors respectively
used for the standard Debian archives, the Debian security archive,
- the Debian official backports and the Debian Volatile archive.
+ and the Debian Volatile archive.
### ubuntu_url
@@ -321,30 +323,20 @@ Example usage:
}
-## apt::cron::download<a name="apt-cron-download"></a>
+## apt::cron::dist_upgrade<a name="apt-cron-dist_upgrade"></a>
-This class sets up `cron-apt` so that it downloads upgradable packages, does not
-actually do any upgrade and emails when the output changes.
+This class sets up cron-apt so that it dist-upgrades the system and
+emails when upgrades are performed.
`cron-apt` defaults to run at 4 AM. You may want to set the
-`$apt_cron_hours` variable before you include the class: its value will
+`$cron_hours` class parameter before you include the class: its value will
be passed as the "hours" parameter of a cronjob. Example:
# Run cron-apt every three hours
- $apt_cron_hours = '*/3'
+ class { 'apt::cron::dist_upgrade': cron_hours => '*/3' }
Note that the default 4 AM cronjob won't be disabled.
-
-## apt::cron::dist_upgrade<a name="apt-cron-dist_upgrade"></a>
-
-This class sets up cron-apt so that it dist-upgrades the system and
-emails when upgrades are performed.
-
-See [apt::cron::download](#apt-cron-download) above if you need to run `cron-apt` more often
-than once a day.
-
-
## apt::dist_upgrade<a name="apt-dist_upgrade"></a>
This class provides the `Exec['apt_dist-upgrade']` resource that
@@ -356,6 +348,11 @@ classes may inherit from this one and add to its subscription list
using the plusignment (`+>`) operator. A real-world example can be
seen in the `apt::dist_upgrade::initiator` source.
+Parameters:
+
+ * timeout: specified in seconds; the maximum time the `dist-upgrade`
+ command should take. If the command takes longer than the timeout,
+ the command is considered to have failed and will be stopped.
## apt::dist_upgrade::initiator<a name="apt-dist_upgrade-initiator"></a>
@@ -481,7 +478,7 @@ A way to add pinning information to files in `/etc/apt/preferences.d/`
Examples:
apt::preferences_snippet { 'irssi-plugin-otr':
- release => 'squeeze-backports',
+ release => 'jessie-backports',
priority => 999,
}
@@ -563,7 +560,7 @@ use `apt::key::plain`.
The `.gpg` extension is compulsory for `apt` to pickup the key properly.
-## apt::key::plain<a name="apt-key-plain"></a>
+## `apt::key::plain`<a name="apt-key-plain"></a>
Deploys a secure apt OpenPGP key. This usually accompanies the
sources.list snippets above for third party repositories. For example,
@@ -640,11 +637,33 @@ To run pupept rspec tests:
bundle install --path vendor/bundle
bundle exec rake spec
+Verbose Output:
+
+ bundle exec rake spec SPEC_OPTS='--format documentation'
+
Using different facter/puppet versions:
FACTER_GEM_VERSION=1.6.10 PUPPET_GEM_VERSION=2.7.23 bundle install --path vendor/bundle
bundle exec rake spec
+## Acceptance Tests<a name="acceptance-tests"></a>
+
+At the moment, we use [beaker together with docker](https://github.com/puppetlabs/beaker/blob/master/docs/Docker-Support.md)
+to do acceptance testing.
+Be sure to have a recent docker version installed.
+
+List configured nodesets:
+
+ bundle exec rake beaker_nodes
+
+Run tests on default node (Debian Jessie):
+
+ bundle exec rake beaker
+
+Run different nodeset:
+
+ BEAKER_set="debian-8-x86_64-docker" bundle exec rspec spec/acceptance/*_spec.rb
+
# Licensing<a name="licensing"></a>
diff --git a/manifests/apticron.pp b/manifests/apticron.pp
index 9c94f9c..89709a8 100644
--- a/manifests/apticron.pp
+++ b/manifests/apticron.pp
@@ -1,6 +1,6 @@
class apt::apticron(
$ensure_version = 'installed',
- $config = "apt/${::operatingsystem}/apticron_${::debian_codename}.erb",
+ $config = "apt/${::operatingsystem}/apticron.erb",
$email = 'root',
$diff_only = '1',
$listchanges_profile = 'apticron',
diff --git a/manifests/cron/base.pp b/manifests/cron/base.pp
deleted file mode 100644
index 39fc306..0000000
--- a/manifests/cron/base.pp
+++ /dev/null
@@ -1,20 +0,0 @@
-class apt::cron::base {
-
- package { 'cron-apt': ensure => installed }
-
- case $apt_cron_hours {
- '': {}
- default: {
- # cron-apt defaults to run every night at 4 o'clock
- # so we try not to run at the same time.
- cron { 'apt_cron_every_N_hours':
- command => 'test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt',
- user => root,
- hour => "${apt_cron_hours}",
- minute => 10,
- require => Package['cron-apt'],
- }
- }
- }
-
-}
diff --git a/manifests/cron/dist_upgrade.pp b/manifests/cron/dist_upgrade.pp
index 74403bb..e1a03ed 100644
--- a/manifests/cron/dist_upgrade.pp
+++ b/manifests/cron/dist_upgrade.pp
@@ -1,4 +1,23 @@
-class apt::cron::dist_upgrade inherits apt::cron::base {
+class apt::cron::dist_upgrade (
+ $cron_hours = '',
+) {
+
+ package { 'cron-apt': ensure => installed }
+
+ case $cron_hours {
+ '': {}
+ default: {
+ # cron-apt defaults to run every night at 4 o'clock
+ # so we try not to run at the same time.
+ cron { 'apt_cron_every_N_hours':
+ command => 'test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt',
+ user => root,
+ hour => "${cron_hours}",
+ minute => 10,
+ require => Package['cron-apt'],
+ }
+ }
+ }
$action = "autoclean -y
dist-upgrade -y -o APT::Get::Show-Upgraded=true -o 'DPkg::Options::=--force-confold'
diff --git a/manifests/cron/download.pp b/manifests/cron/download.pp
deleted file mode 100644
index 4a19fec..0000000
--- a/manifests/cron/download.pp
+++ /dev/null
@@ -1,27 +0,0 @@
-class apt::cron::download inherits apt::cron::base {
-
- $action = "autoclean -y
-dist-upgrade -d -y -o APT::Get::Show-Upgraded=true
-"
-
- file { '/etc/cron-apt/action.d/4-dist-upgrade':
- ensure => absent,
- }
-
- file { '/etc/cron-apt/action.d/3-download':
- content => $action,
- require => Package[cron-apt],
- owner => root,
- group => 0,
- mode => '0644';
- }
-
- file { '/etc/cron-apt/config.d/MAILON':
- content => "MAILON=changes\n",
- require => Package[cron-apt],
- owner => root,
- group => 0,
- mode => '0644';
- }
-
-}
diff --git a/manifests/dist_upgrade.pp b/manifests/dist_upgrade.pp
index 19c031e..3061fb8 100644
--- a/manifests/dist_upgrade.pp
+++ b/manifests/dist_upgrade.pp
@@ -1,8 +1,11 @@
-class apt::dist_upgrade {
+class apt::dist_upgrade (
+ $timeout = 300,
+) {
exec { 'apt_dist-upgrade':
command => '/usr/bin/apt-get -q -y -o \'DPkg::Options::=--force-confold\' dist-upgrade',
refreshonly => true,
+ timeout => $timeout,
before => Exec['apt_updated']
}
diff --git a/manifests/init.pp b/manifests/init.pp
index 4c44af2..4bf126c 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -11,7 +11,6 @@ class apt(
$use_next_release = $apt::params::use_next_release,
$debian_url = $apt::params::debian_url,
$security_url = $apt::params::security_url,
- $backports_url = $apt::params::backports_url,
$lts_url = $apt::params::lts_url,
$volatile_url = $apt::params::volatile_url,
$ubuntu_url = $apt::params::ubuntu_url,
@@ -20,20 +19,6 @@ class apt(
$custom_sources_list = '',
$custom_key_dir = $apt::params::custom_key_dir
) inherits apt::params {
- case $::operatingsystem {
- 'debian': {
- $real_repos = $repos ? {
- 'auto' => 'main contrib non-free',
- default => $repos,
- }
- }
- 'ubuntu': {
- $real_repos = $repos ? {
- 'auto' => 'main restricted universe multiverse',
- default => $repos,
- }
- }
- }
package { 'apt':
ensure => installed,
@@ -82,8 +67,6 @@ class apt(
include apt::preferences::absent
}
default: {
- # When squeeze becomes the stable branch, transform this file's header
- # into a preferences.d file
include apt::preferences
}
}
@@ -93,18 +76,15 @@ class apt(
## This package should really always be current
package { 'debian-archive-keyring': ensure => latest }
- # backports uses the normal archive key now
- package { 'debian-backports-keyring': ensure => absent }
-
if ($use_backports and !($::debian_release in ['testing', 'unstable', 'experimental'])) {
apt::sources_list {
'backports':
- content => "deb $backports_url ${::debian_codename}-backports ${apt::real_repos}",
+ content => "deb ${debian_url} ${::debian_codename}-backports ${apt::repos}",
}
if $include_src {
apt::sources_list {
'backports-src':
- content => "deb-src $backports_url ${::debian_codename}-backports ${apt::real_repos}",
+ content => "deb-src ${debian_url} ${::debian_codename}-backports ${apt::repos}",
}
}
}
diff --git a/manifests/listchanges.pp b/manifests/listchanges.pp
index e64bb1b..ecbbe6d 100644
--- a/manifests/listchanges.pp
+++ b/manifests/listchanges.pp
@@ -1,6 +1,6 @@
class apt::listchanges(
$ensure_version = 'installed',
- $config = "apt/${::operatingsystem}/listchanges_${::debian_codename}.erb",
+ $config = "apt/${::operatingsystem}/listchanges.erb",
$frontend = 'mail',
$email = 'root',
$confirm = '0',
diff --git a/manifests/params.pp b/manifests/params.pp
index 28af06e..2b18eb5 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -7,16 +7,19 @@ class apt::params () {
$debian_url = 'http://httpredir.debian.org/debian/'
$security_url = 'http://security.debian.org/'
$ubuntu_url = 'http://archive.ubuntu.com/ubuntu'
- $backports_url = $::debian_codename ? {
- 'squeeze' => 'http://backports.debian.org/debian-backports/',
- default => $::operatingsystem ? {
- 'Ubuntu' => $ubuntu_url,
- default => $debian_url,
- }
- }
$lts_url = $debian_url
$volatile_url = 'http://volatile.debian.org/debian-volatile/'
- $repos = 'auto'
+ case $::operatingsystem {
+ 'debian': {
+ $repos = 'main contrib non-free'
+ }
+ 'ubuntu': {
+ $repos = 'main restricted universe multiverse'
+ }
+ default: {
+ fail("Unsupported system '${::operatingsystem}'.")
+ }
+ }
$custom_preferences = ''
$custom_key_dir = false
}
diff --git a/manifests/preferences.pp b/manifests/preferences.pp
index 50ca23a..aedd56b 100644
--- a/manifests/preferences.pp
+++ b/manifests/preferences.pp
@@ -2,10 +2,7 @@ class apt::preferences {
$pref_contents = $apt::custom_preferences ? {
'' => $::operatingsystem ? {
- 'debian' => $::debian_codename ? {
- 'lenny' => template("apt/${::operatingsystem}/preferences_lenny.erb"),
- default => template("apt/${::operatingsystem}/preferences.erb"),
- },
+ 'debian' => template("apt/${::operatingsystem}/preferences.erb"),
'ubuntu' => template("apt/${::operatingsystem}/preferences_${apt::codename}.erb"),
},
default => $apt::custom_preferences
diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp
index 3ef0687..162ade7 100644
--- a/manifests/preseeded_package.pp
+++ b/manifests/preseeded_package.pp
@@ -1,3 +1,4 @@
+# Install a package with a preseed file to automatically answer some questions.
define apt::preseeded_package (
$ensure = 'installed',
$content = ''
@@ -10,7 +11,9 @@ define apt::preseeded_package (
file { $seedfile:
content => $real_content,
- mode => '0600', owner => root, group => root,
+ mode => '0600',
+ owner => 'root',
+ group => 0,
}
package { $name:
diff --git a/manifests/reboot_required_notify.pp b/manifests/reboot_required_notify.pp
index 722e8a5..efd8aeb 100644
--- a/manifests/reboot_required_notify.pp
+++ b/manifests/reboot_required_notify.pp
@@ -1,21 +1,11 @@
class apt::reboot_required_notify {
- # This package installs the script that created /var/run/reboot-required*.
- # This script (/usr/share/update-notifier/notify-reboot-required) is
- # triggered e.g. by kernel packages.
- package { 'update-notifier-common':
- ensure => installed,
- }
-
- # cron-apt defaults to run every night at 4 o'clock
- # plus some random time <1h.
- # so we check if a reboot is required a bit later.
- cron { 'apt_reboot_required_notify':
- command => 'if [ -f /var/run/reboot-required ]; then echo "Reboot required\n" ; cat /var/run/reboot-required.pkgs ; fi',
- user => root,
- hour => 5,
- minute => 20,
- require => Package['update-notifier-common'],
+ if versioncmp($::operatingsystemmajrelease, 8) >= 0 {
+ class { 'apt::reboot_required_notify::jessie': }
+ # Clean up systems that were upgraded from Wheezy or earlier:
+ class { 'apt::reboot_required_notify::wheezy': ensure => absent }
+ } else {
+ class { 'apt::reboot_required_notify::wheezy': }
}
}
diff --git a/manifests/reboot_required_notify/jessie.pp b/manifests/reboot_required_notify/jessie.pp
new file mode 100644
index 0000000..2de6b62
--- /dev/null
+++ b/manifests/reboot_required_notify/jessie.pp
@@ -0,0 +1,28 @@
+class apt::reboot_required_notify::jessie ($ensure = present) {
+
+ if $::operatingsystemmajrelease == 8 and ! $::apt::use_backports {
+ fail('apt::reboot_required_notify requires $apt::use_backports on Jessie')
+ }
+
+ $pinning_ensure = $::operatingsystemmajrelease ? {
+ 8 => present,
+ default => absent,
+ }
+ apt::preferences_snippet { 'reboot-notifier':
+ ensure => $pinning_ensure,
+ pin => 'release o=Debian Backports,a=jessie-backports',
+ priority => 991,
+ }
+
+ # On Jessie and newer, this package installs the script that created
+ # /var/run/reboot-required*.
+ # This script (/usr/share/update-notifier/notify-reboot-required) is
+ # triggered e.g. by kernel packages.
+ # This package also sends a daily email to the administrator when a system
+ # reboot is required, e.g. due to a kernel update.
+ package { 'reboot-notifier':
+ ensure => $ensure,
+ require => Apt::Preferences_snippet['reboot-notifier'],
+ }
+
+}
diff --git a/manifests/reboot_required_notify/wheezy.pp b/manifests/reboot_required_notify/wheezy.pp
new file mode 100644
index 0000000..06998ef
--- /dev/null
+++ b/manifests/reboot_required_notify/wheezy.pp
@@ -0,0 +1,23 @@
+class apt::reboot_required_notify::wheezy ($ensure = present) {
+
+ # On Wheezy and older, this package installs the script that created
+ # /var/run/reboot-required*.
+ # This script (/usr/share/update-notifier/notify-reboot-required) is
+ # triggered e.g. by kernel packages.
+ package { 'update-notifier-common':
+ ensure => $ensure,
+ }
+
+ # cron-apt defaults to run every night at 4 o'clock
+ # plus some random time <1h.
+ # so we check if a reboot is required a bit later.
+ cron { 'apt_reboot_required_notify':
+ ensure => $ensure,
+ command => 'if [ -f /var/run/reboot-required ]; then echo "Reboot required\n" ; cat /var/run/reboot-required.pkgs ; fi',
+ user => root,
+ hour => 5,
+ minute => 20,
+ require => Package['update-notifier-common'],
+ }
+
+}
diff --git a/manifests/sources_list.pp b/manifests/sources_list.pp
index 0ee068d..7565bce 100644
--- a/manifests/sources_list.pp
+++ b/manifests/sources_list.pp
@@ -1,3 +1,4 @@
+# Configure an apt source
define apt::sources_list (
$ensure = 'present',
$source = '',
@@ -22,7 +23,9 @@ define apt::sources_list (
# apparently doesn't.
file { "/etc/apt/sources.list.d/${realname}.list":
ensure => $ensure,
- owner => root, group => 0, mode => '0644',
+ mode => '0644',
+ owner => 'root',
+ group => 0,
notify => Exec['apt_updated'],
}
diff --git a/manifests/upgrade_package.pp b/manifests/upgrade_package.pp
index 30572c9..e61b15d 100644
--- a/manifests/upgrade_package.pp
+++ b/manifests/upgrade_package.pp
@@ -1,3 +1,5 @@
+# Install a package either to a certain version, or while making sure that it's
+# always the latest version that's installed.
define apt::upgrade_package (
$version = ''
) {
@@ -23,7 +25,7 @@ define apt::upgrade_package (
}
exec { "apt-get -q -y -o 'DPkg::Options::=--force-confold' install ${name}${version_suffix}":
- onlyif => [ "grep-status -F Status installed -a -P $name -q", "apt-show-versions -u $name | grep -q upgradeable" ],
+ onlyif => [ "grep-status -F Status installed -a -P ${name} -q", "apt-show-versions -u ${name} | grep -q upgradeable" ],
require => Package['apt-show-versions', 'dctrl-tools'],
before => Exec['apt_updated']
}
diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb
new file mode 100644
index 0000000..a976a56
--- /dev/null
+++ b/spec/acceptance/apt_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper_acceptance'
+
+describe 'apt class' do
+
+ context 'default parameters' do
+ it 'should work idempotently with no errors' do
+ pp = <<-EOS
+ class { 'apt': }
+ EOS
+
+ # Run it twice and test for idempotency
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_changes => true)
+ end
+
+ describe package('apt') do
+ it { is_expected.to be_installed }
+ end
+
+ end
+end
diff --git a/spec/acceptance/nodesets/debian-8-x86_64-docker.yml b/spec/acceptance/nodesets/debian-8-x86_64-docker.yml
new file mode 100644
index 0000000..f09ad62
--- /dev/null
+++ b/spec/acceptance/nodesets/debian-8-x86_64-docker.yml
@@ -0,0 +1,19 @@
+HOSTS:
+ debian-8-x64:
+ platform: debian-8-amd64
+ image: debian:8
+ hypervisor: docker
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y wget locales-all puppet git'
+ - 'rm -f /usr/sbin/policy-rc.d'
+
+CONFIG:
+ type: foss
+ #log_level: verbose
+ #log_level: debug
+
+ssh:
+ password: root
+ auth_methods: ["password"]
diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml
new file mode 120000
index 0000000..b125a96
--- /dev/null
+++ b/spec/acceptance/nodesets/default.yml
@@ -0,0 +1 @@
+debian-8-x86_64-docker.yml \ No newline at end of file
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
new file mode 100644
index 0000000..1ccd84d
--- /dev/null
+++ b/spec/spec_helper_acceptance.rb
@@ -0,0 +1,18 @@
+require 'beaker-rspec'
+
+RSpec.configure do |c|
+ module_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+ module_name = module_root.split('-').last
+
+ # Readable test descriptions
+ c.formatter = :documentation
+
+ # Configure all nodes in nodeset
+ c.before :suite do
+ # Install module and dependencies
+ puppet_module_install(:source => module_root, :module_name => module_name)
+ hosts.each do |host|
+ shell('git clone https://gitlab.com/shared-puppet-modules-group/common.git /etc/puppet/modules/common')
+ end
+ end
+end
diff --git a/templates/50unattended-upgrades.erb b/templates/50unattended-upgrades.erb
index 7c65d10..b271a41 100644
--- a/templates/50unattended-upgrades.erb
+++ b/templates/50unattended-upgrades.erb
@@ -5,10 +5,6 @@ Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security";
"${distro_id}:${distro_codename}-updates";
"${distro_id}:${distro_codename}-backports";
-<% elsif scope.lookupvar('::operatingsystem') == 'Debian' and scope.lookupvar('::debian_codename') == 'squeeze' -%>
-Unattended-Upgrade::Allowed-Origins {
- "${distro_id}:<%= scope.lookupvar('::debian_release') %>";
- "${distro_id}:squeeze-lts";
<% elsif scope.lookupvar('::operatingsystem') == 'Debian' and scope.lookupvar('::debian_codename') == 'wheezy' -%>
Unattended-Upgrade::Origins-Pattern {
"origin=Debian,archive=<%= scope.lookupvar('::debian_release') %>,label=Debian-Security";
diff --git a/templates/Debian/apticron_wheezy.erb b/templates/Debian/apticron.erb
index 655854e..c6d3853 100644
--- a/templates/Debian/apticron_wheezy.erb
+++ b/templates/Debian/apticron.erb
@@ -46,7 +46,7 @@ IPADDRESSNUM="<%= v %>"
#
# IPADDRESSES="192.0.2.1 2001:db8:1:2:3::1"
<% unless (v=scope.lookupvar('apt::apticron::ipaddresses')).to_s == "false" -%>
-IPADDRESSES=<%= v %>"
+IPADDRESSES="<%= v %>"
<% end -%>
#
diff --git a/templates/Debian/apticron_jessie.erb b/templates/Debian/apticron_jessie.erb
deleted file mode 120000
index a9a3a6f..0000000
--- a/templates/Debian/apticron_jessie.erb
+++ /dev/null
@@ -1 +0,0 @@
-apticron_wheezy.erb \ No newline at end of file
diff --git a/templates/Debian/apticron_lenny.erb b/templates/Debian/apticron_lenny.erb
deleted file mode 100644
index 86b0997..0000000
--- a/templates/Debian/apticron_lenny.erb
+++ /dev/null
@@ -1,50 +0,0 @@
-# apticron.conf
-#
-# set EMAIL to a list of addresses which will be notified of impending updates
-#
-EMAIL="<%= scope.lookupvar('apt::apticron::email') %>"
-
-#
-# Set DIFF_ONLY to "1" to only output the difference of the current run
-# compared to the last run (ie. only new upgrades since the last run). If there
-# are no differences, no output/email will be generated. By default, apticron
-# will output everything that needs to be upgraded.
-#
-DIFF_ONLY="<%= scope.lookupvar('apt::apticron::diff_only') %>"
-
-#
-# Set LISTCHANGES_PROFILE if you would like apticron to invoke apt-listchanges
-# with the --profile option. You should add a corresponding profile to
-# /etc/apt/listchanges.conf
-#
-LISTCHANGES_PROFILE="<%= scope.lookupvar('apt::apticron::listchanges_profile') %>"
-
-#
-# Set SYSTEM if you would like apticron to use something other than the output
-# of "hostname -f" for the system name in the mails it generates
-#
-# SYSTEM="foobar.example.com"
-<% unless (v=scope.lookupvar('apt::apticron::system')).to_s == "false" -%>
-SYSTEM="<%= v %>"
-<% end -%>
-
-#
-# Set IPADDRESSNUM if you would like to configure the maximal number of IP
-# addresses apticron displays. The default is to display 1 address of each
-# family type (inet, inet6), if available.
-#
-# IPADDRESSNUM="1"
-<% unless (v=scope.lookupvar('apt::apticron::ipaddressnum')).to_s == "false" -%>
-IPADDRESSNUM="<%= v %>"
-<% end -%>
-
-#
-# Set IPADDRESSES to a whitespace seperated list of reachable addresses for
-# this system. By default, apticron will try to work these out using the
-# "ip" command
-#
-# IPADDRESSES="192.0.2.1 2001:db8:1:2:3::1"
-<% unless (v=scope.lookupvar('apt::apticron::ipaddresses')).to_s == "false" -%>
-IPADDRESSES="<%= v %>"
-<% end -%>
-
diff --git a/templates/Debian/apticron_sid.erb b/templates/Debian/apticron_sid.erb
deleted file mode 120000
index a9a3a6f..0000000
--- a/templates/Debian/apticron_sid.erb
+++ /dev/null
@@ -1 +0,0 @@
-apticron_wheezy.erb \ No newline at end of file
diff --git a/templates/Debian/apticron_squeeze.erb b/templates/Debian/apticron_squeeze.erb
deleted file mode 100644
index 05b7c9b..0000000
--- a/templates/Debian/apticron_squeeze.erb
+++ /dev/null
@@ -1,82 +0,0 @@
-# apticron.conf
-#
-# set EMAIL to a space separated list of addresses which will be notified of
-# impending updates
-#
-EMAIL="<%= scope.lookupvar('apt::apticron::email') %>"
-
-
-#
-# Set DIFF_ONLY to "1" to only output the difference of the current run
-# compared to the last run (ie. only new upgrades since the last run). If there
-# are no differences, no output/email will be generated. By default, apticron
-# will output everything that needs to be upgraded.
-#
-DIFF_ONLY="<%= scope.lookupvar('apt::apticron::diff_only') %>"
-
-#
-# Set LISTCHANGES_PROFILE if you would like apticron to invoke apt-listchanges
-# with the --profile option. You should add a corresponding profile to
-# /etc/apt/listchanges.conf
-#
-LISTCHANGES_PROFILE="<%= scope.lookupvar('apt::apticron::listchanges_profile') %>"
-
-#
-# Set SYSTEM if you would like apticron to use something other than the output
-# of "hostname -f" for the system name in the mails it generates
-#
-# SYSTEM="foobar.example.com"
-<% unless (v=scope.lookupvar('apt::apticron::system')).to_s == "false" -%>
-SYSTEM="<%= v %>"
-<% end -%>
-
-
-#
-# Set IPADDRESSNUM if you would like to configure the maximal number of IP
-# addresses apticron displays. The default is to display 1 address of each
-# family type (inet, inet6), if available.
-#
-# IPADDRESSNUM="1"
-<% unless (v=scope.lookupvar('apt::apticron::ipaddressnum')).to_s == "false" -%>
-IPADDRESSNUM="<%= v %>"
-<% end -%>
-
-
-#
-# Set IPADDRESSES to a whitespace separated list of reachable addresses for
-# this system. By default, apticron will try to work these out using the
-# "ip" command
-#
-# IPADDRESSES="192.0.2.1 2001:db8:1:2:3::1"
-<% unless (v=scope.lookupvar('apt::apticron::ipaddresses')).to_s == "false" -%>
-IPADDRESSES="<%= v %>"
-<% end -%>
-
-
-#
-# Set NOTIFY_HOLDS="0" if you don't want to be notified about new versions of
-# packages on hold in your system. The default behavior is downloading and
-# listing them as any other package.
-#
-# NOTIFY_HOLDS="0"
-NOTIFY_HOLDS="<%= scope.lookupvar('apt::apticron::notifyholds') %>"
-
-#
-# Set NOTIFY_NEW="0" if you don't want to be notified about packages which
-# are not installed in your system. Yes, it's possible! There are some issues
-# related to systems which have mixed stable/unstable sources. In these cases
-# apt-get will consider for example that packages with "Priority:
-# required"/"Essential: yes" in unstable but not in stable should be installed,
-# so they will be listed in dist-upgrade output. Please take a look at
-# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=531002#44
-#
-# NOTIFY_NEW="0"
-NOTIFY_NEW="<%= scope.lookupvar('apt::apticron::notifynew') %>"
-
-#
-# Set CUSTOM_SUBJECT if you want to replace the default subject used in
-# the notification e-mails. This may help filtering/sorting client-side e-mail.
-#
-# CUSTOM_SUBJECT=""
-CUSTOM_SUBJECT="<%= scope.lookupvar('apt::apticron::customsubject') %>"
-
diff --git a/templates/Debian/listchanges_lenny.erb b/templates/Debian/listchanges.erb
index 1025dd0..1025dd0 100644
--- a/templates/Debian/listchanges_lenny.erb
+++ b/templates/Debian/listchanges.erb
diff --git a/templates/Debian/listchanges_jessie.erb b/templates/Debian/listchanges_jessie.erb
deleted file mode 120000
index 74ab496..0000000
--- a/templates/Debian/listchanges_jessie.erb
+++ /dev/null
@@ -1 +0,0 @@
-listchanges_lenny.erb \ No newline at end of file
diff --git a/templates/Debian/listchanges_sid.erb b/templates/Debian/listchanges_sid.erb
deleted file mode 120000
index 74ab496..0000000
--- a/templates/Debian/listchanges_sid.erb
+++ /dev/null
@@ -1 +0,0 @@
-listchanges_lenny.erb \ No newline at end of file
diff --git a/templates/Debian/listchanges_squeeze.erb b/templates/Debian/listchanges_squeeze.erb
deleted file mode 120000
index 74ab496..0000000
--- a/templates/Debian/listchanges_squeeze.erb
+++ /dev/null
@@ -1 +0,0 @@
-listchanges_lenny.erb \ No newline at end of file
diff --git a/templates/Debian/listchanges_wheezy.erb b/templates/Debian/listchanges_wheezy.erb
deleted file mode 120000
index 74ab496..0000000
--- a/templates/Debian/listchanges_wheezy.erb
+++ /dev/null
@@ -1 +0,0 @@
-listchanges_lenny.erb \ No newline at end of file
diff --git a/templates/Debian/preferences_lenny.erb b/templates/Debian/preferences_lenny.erb
deleted file mode 100644
index 6500168..0000000
--- a/templates/Debian/preferences_lenny.erb
+++ /dev/null
@@ -1,25 +0,0 @@
-Explanation: Debian <%= codename=scope.lookupvar('::debian_codename') %>
-Package: *
-Pin: release o=Debian,a=<%= scope.lookupvar('::debian_release') %>,v=5*
-Pin-Priority: 990
-
-Explanation: Debian backports
-Package: *
-Pin: origin backports.debian.org
-Pin-Priority: 200
-
-Explanation: Debian <%= next_release=scope.lookupvar('::debian_nextrelease') %>
-Package: *
-Pin: release o=Debian,a=<%= next_release %>
-Pin-Priority: 2
-
-Explanation: Debian sid
-Package: *
-Pin: release o=Debian,a=unstable
-Pin-Priority: 1
-
-Explanation: Debian fallback
-Package: *
-Pin: release o=Debian
-Pin-Priority: -10
-
diff --git a/templates/Debian/sources.list.erb b/templates/Debian/sources.list.erb
index 44eea53..c7318a2 100644
--- a/templates/Debian/sources.list.erb
+++ b/templates/Debian/sources.list.erb
@@ -4,7 +4,7 @@
### Debian current: <%= codename=scope.lookupvar('::debian_codename') %>
# basic
-deb <%= debian_url=scope.lookupvar('apt::debian_url') %> <%= codename %> <%= lrepos=scope.lookupvar('apt::real_repos') %>
+deb <%= debian_url=scope.lookupvar('apt::debian_url') %> <%= codename %> <%= lrepos=scope.lookupvar('apt::repos') %>
<% if include_src=scope.lookupvar('apt::include_src') -%>
deb-src <%= debian_url %> <%= codename %> <%= lrepos %>
<% end -%>
diff --git a/templates/Ubuntu/sources.list.erb b/templates/Ubuntu/sources.list.erb
index e6d2f64..b90b8c8 100644
--- a/templates/Ubuntu/sources.list.erb
+++ b/templates/Ubuntu/sources.list.erb
@@ -1,8 +1,8 @@
# This file is managed by puppet
# all local modifications will be overwritten
-# basic <%= codename=scope.lookupvar('::ubuntu_codename') %>
-deb <%= ubuntu_url=scope.lookupvar('apt::ubuntu_url') %> <%= codename %> <%= lrepos=scope.lookupvar('apt::real_repos') %>
+# basic <%= codename=scope.lookupvar('apt::codename') %>
+deb <%= ubuntu_url=scope.lookupvar('apt::ubuntu_url') %> <%= codename %> <%= lrepos=scope.lookupvar('apt::repos') %>
<% if include_src=scope.lookupvar('apt::include_src') -%>
deb-src <%= ubuntu_url %> <%= codename %> <%= lrepos %>
<% end -%>