From e2ea89aa7a5da2d239fe46d036dfc7fa92e56a03 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Mon, 31 Aug 2015 19:55:17 +0000 Subject: reboot_required_notify: move all code to a ::wheezy class. It doesn't work on Jessie and newer (#1). --- manifests/reboot_required_notify.pp | 18 +----------------- manifests/reboot_required_notify/wheezy.pp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 manifests/reboot_required_notify/wheezy.pp diff --git a/manifests/reboot_required_notify.pp b/manifests/reboot_required_notify.pp index 722e8a5..d0006f3 100644 --- a/manifests/reboot_required_notify.pp +++ b/manifests/reboot_required_notify.pp @@ -1,21 +1,5 @@ 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'], - } + class { 'apt::reboot_required_notify::wheezy': } } diff --git a/manifests/reboot_required_notify/wheezy.pp b/manifests/reboot_required_notify/wheezy.pp new file mode 100644 index 0000000..14fdd79 --- /dev/null +++ b/manifests/reboot_required_notify/wheezy.pp @@ -0,0 +1,22 @@ +class apt::reboot_required_notify::wheezy { + + # 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 => 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'], + } + +} -- cgit v1.2.3 From a82e3ae272c8510b3dc30f499316a7bfb518d330 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Mon, 31 Aug 2015 19:56:16 +0000 Subject: reboot_required_notify::wheezy: add an "ensure" parameter, defaulting to "present". --- manifests/reboot_required_notify/wheezy.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/reboot_required_notify/wheezy.pp b/manifests/reboot_required_notify/wheezy.pp index 14fdd79..06998ef 100644 --- a/manifests/reboot_required_notify/wheezy.pp +++ b/manifests/reboot_required_notify/wheezy.pp @@ -1,17 +1,18 @@ -class apt::reboot_required_notify::wheezy { +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 => installed, + 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, -- cgit v1.2.3 From 3630285006d9fb60c5fbecebc976623c37dd1395 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Mon, 31 Aug 2015 20:01:22 +0000 Subject: reboot_required_notify: add initial support for Jessie and newer. Note that reboot-notifier is only in stretch/sid at the moment, so to use this one needs to configure APT pinning themselves to make this package installable. --- manifests/reboot_required_notify.pp | 15 ++++++++++++++- manifests/reboot_required_notify/jessie.pp | 13 +++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 manifests/reboot_required_notify/jessie.pp diff --git a/manifests/reboot_required_notify.pp b/manifests/reboot_required_notify.pp index d0006f3..82466d2 100644 --- a/manifests/reboot_required_notify.pp +++ b/manifests/reboot_required_notify.pp @@ -1,5 +1,18 @@ class apt::reboot_required_notify { - class { 'apt::reboot_required_notify::wheezy': } + $jessie_or_newer = $::operatingsystemmajrelease ? { + 5 => false, + 6 => false, + 7 => false, + default => true, + } + + if $jessie_or_newer { + 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..51b75a2 --- /dev/null +++ b/manifests/reboot_required_notify/jessie.pp @@ -0,0 +1,13 @@ +class apt::reboot_required_notify::jessie ($ensure = present) { + + # 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, + } + +} -- cgit v1.2.3 From 48bf4a390e7fc2d7fa948ca1c441785880f4c22b Mon Sep 17 00:00:00 2001 From: Jerome Charaoui Date: Wed, 7 Oct 2015 10:36:12 -0400 Subject: Merge Debian squeeze, wheezy, jessie and sid preferences templates into one --- manifests/preferences.pp | 5 ++++- templates/Debian/preferences.erb | 33 ++++++++++++++++++++++++++++++++ templates/Debian/preferences_jessie.erb | 14 -------------- templates/Debian/preferences_sid.erb | 10 ---------- templates/Debian/preferences_squeeze.erb | 30 ----------------------------- templates/Debian/preferences_wheezy.erb | 20 ------------------- 6 files changed, 37 insertions(+), 75 deletions(-) create mode 100644 templates/Debian/preferences.erb delete mode 100644 templates/Debian/preferences_jessie.erb delete mode 100644 templates/Debian/preferences_sid.erb delete mode 100644 templates/Debian/preferences_squeeze.erb delete mode 100644 templates/Debian/preferences_wheezy.erb diff --git a/manifests/preferences.pp b/manifests/preferences.pp index 9ed24c1..50ca23a 100644 --- a/manifests/preferences.pp +++ b/manifests/preferences.pp @@ -2,7 +2,10 @@ class apt::preferences { $pref_contents = $apt::custom_preferences ? { '' => $::operatingsystem ? { - 'debian' => template("apt/${::operatingsystem}/preferences_${apt::codename}.erb"), + 'debian' => $::debian_codename ? { + 'lenny' => template("apt/${::operatingsystem}/preferences_lenny.erb"), + default => template("apt/${::operatingsystem}/preferences.erb"), + }, 'ubuntu' => template("apt/${::operatingsystem}/preferences_${apt::codename}.erb"), }, default => $apt::custom_preferences diff --git a/templates/Debian/preferences.erb b/templates/Debian/preferences.erb new file mode 100644 index 0000000..37cf80d --- /dev/null +++ b/templates/Debian/preferences.erb @@ -0,0 +1,33 @@ +# This file is managed by puppet +# all local modifications will be overwritten + +Explanation: Debian <%= codename=scope.lookupvar('::debian_codename') %> +Package: * +Pin: release o=Debian,n=<%= codename %> +Pin-Priority: 990 + +<% if use_volatile=scope.lookupvar('apt::use_volatile') -%> +Explanation: Debian <%= codename %>-updates +Package: * +Pin: release o=Debian,n=<%= codename %>-updates +Pin-Priority: 990 +<%- end -%> + +<% if (use_lts=scope.lookupvar('apt::use_lts')) && (scope.lookupvar('::debian_lts') == "true") -%> +Explanation: Debian <%= codename %>-lts +Package: * +Pin: release o=Debian,n=<%= codename %>-lts +Pin-Priority: 990 +<%- end -%> + +<% if (next_codename=scope.lookupvar('::debian_nextcodename')) && (next_codename != "experimental") -%> +Explanation: Debian <%= next_codename %> +Package: * +Pin: release o=Debian,n=<%= next_codename %> +Pin-Priority: 2 +<%- end -%> + +Explanation: Debian fallback +Package: * +Pin: release o=Debian +Pin-Priority: -10 diff --git a/templates/Debian/preferences_jessie.erb b/templates/Debian/preferences_jessie.erb deleted file mode 100644 index 4f8e95c..0000000 --- a/templates/Debian/preferences_jessie.erb +++ /dev/null @@ -1,14 +0,0 @@ -Explanation: Debian <%= codename=scope.lookupvar('apt::codename') %> -Package: * -Pin: release o=Debian,n=<%= codename %> -Pin-Priority: 990 - -Explanation: Debian sid -Package: * -Pin: release o=Debian,n=sid -Pin-Priority: 1 - -Explanation: Debian fallback -Package: * -Pin: release o=Debian -Pin-Priority: -10 diff --git a/templates/Debian/preferences_sid.erb b/templates/Debian/preferences_sid.erb deleted file mode 100644 index eb18554..0000000 --- a/templates/Debian/preferences_sid.erb +++ /dev/null @@ -1,10 +0,0 @@ -Explanation: Debian sid -Package: * -Pin: release o=Debian,n=sid -Pin-Priority: 990 - -Explanation: Debian fallback -Package: * -Pin: release o=Debian -Pin-Priority: -10 - diff --git a/templates/Debian/preferences_squeeze.erb b/templates/Debian/preferences_squeeze.erb deleted file mode 100644 index 838b3a1..0000000 --- a/templates/Debian/preferences_squeeze.erb +++ /dev/null @@ -1,30 +0,0 @@ -Explanation: Debian <%= codename=scope.lookupvar('apt::codename') %> -Package: * -Pin: release o=Debian,n=<%= codename %> -Pin-Priority: 990 - -Explanation: Debian <%= codename %>-updates -Package: * -Pin: release o=Debian,n=<%= codename %>-updates -Pin-Priority: 990 - -Explanation: Debian <%= codename %>-lts -Package: * -Pin: release o=Debian,n=<%= codename %>-lts -Pin-Priority: 990 - -Explanation: Debian <%= next_codename=scope.lookupvar('apt::next_codename') %> -Package: * -Pin: release o=Debian,n=<%= next_codename %> -Pin-Priority: 2 - -Explanation: Debian sid -Package: * -Pin: release o=Debian,n=sid -Pin-Priority: 1 - -Explanation: Debian fallback -Package: * -Pin: release o=Debian -Pin-Priority: -10 - diff --git a/templates/Debian/preferences_wheezy.erb b/templates/Debian/preferences_wheezy.erb deleted file mode 100644 index 0cc0e5c..0000000 --- a/templates/Debian/preferences_wheezy.erb +++ /dev/null @@ -1,20 +0,0 @@ -Explanation: Debian <%= codename=scope.lookupvar('apt::codename') %> -Package: * -Pin: release o=Debian,n=<%= codename %> -Pin-Priority: 990 - -Explanation: Debian <%= codename %>-updates -Package: * -Pin: release o=Debian,n=<%= codename %>-updates -Pin-Priority: 990 - -Explanation: Debian sid -Package: * -Pin: release o=Debian,n=sid -Pin-Priority: 1 - -Explanation: Debian fallback -Package: * -Pin: release o=Debian -Pin-Priority: -10 - -- cgit v1.2.3 From 005f06f3dde8198fac2ca1a0206e05157e927d3c Mon Sep 17 00:00:00 2001 From: varac Date: Sun, 20 Dec 2015 01:57:04 +0100 Subject: [tests] Use beaker+docker for acceptance tests Beaker together with docker is a very fast way to do acceptance testing. This commit adds basic beaker/docker support: - Add a debian jessie nodeset - Test if the module applies idempotentially, so it doesn't change resources on a second run with the same parameters. https://github.com/puppetlabs/beaker/blob/master/docs/Docker-Support.md --- .gitignore | 1 + Gemfile | 7 +++++++ README | 24 ++++++++++++++++++++++ spec/acceptance/apt_spec.rb | 21 +++++++++++++++++++ .../acceptance/nodesets/debian-8-x86_64-docker.yml | 19 +++++++++++++++++ spec/acceptance/nodesets/default.yml | 1 + spec/spec_helper_acceptance.rb | 18 ++++++++++++++++ 7 files changed, 91 insertions(+) create mode 100644 spec/acceptance/apt_spec.rb create mode 100644 spec/acceptance/nodesets/debian-8-x86_64-docker.yml create mode 120000 spec/acceptance/nodesets/default.yml create mode 100644 spec/spec_helper_acceptance.rb 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 b/README index 410201d..1d63af2 100644 --- a/README +++ b/README @@ -576,11 +576,35 @@ 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 +---------------- + +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 ========= 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 -- cgit v1.2.3 From e70a6712d31e91ecbf71f4de841735c3b36193ba Mon Sep 17 00:00:00 2001 From: intrigeri Date: Wed, 16 Mar 2016 14:26:52 +0000 Subject: apt::reboot_required_notify::jessie: manage APT pinning to fetch reboot-notifier from jessie-backports, when running on Jessie. --- manifests/reboot_required_notify/jessie.pp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/manifests/reboot_required_notify/jessie.pp b/manifests/reboot_required_notify/jessie.pp index 51b75a2..9b5a0c0 100644 --- a/manifests/reboot_required_notify/jessie.pp +++ b/manifests/reboot_required_notify/jessie.pp @@ -1,5 +1,15 @@ class apt::reboot_required_notify::jessie ($ensure = present) { + $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 @@ -7,7 +17,8 @@ class apt::reboot_required_notify::jessie ($ensure = present) { # 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, + ensure => $ensure, + require => Apt::Preferences_snippet['reboot-notifier'], } - + } -- cgit v1.2.3 From d7c9feda05bd4bfa3002deb0ba55939c69b1d910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Wed, 27 Apr 2016 14:28:47 -0400 Subject: README is now markdown --- README | 593 ----------------------------------------------------------------- 1 file changed, 593 deletions(-) delete mode 100644 README diff --git a/README b/README deleted file mode 100644 index e097a7e..0000000 --- a/README +++ /dev/null @@ -1,593 +0,0 @@ - -Overview -======== - -This module manages apt on Debian. - -It keeps dpkg's and apt's databases as well as the keyrings for securing -package download current. - -backports.debian.org is added. - -/etc/apt/sources.list and /etc/apt/preferences are managed. More -recent Debian releases are pinned to very low values by default to -prevent accidental upgrades. - -Ubuntu support is lagging behind but not absent either. - -! Upgrade Notice ! - - * 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. - You can include the `apt::update` class if you want it to be run every time. - - * The `apt::upgrade_package` now doesn't automatically call an Exec['apt_updated'] - anymore, so you would need to include `apt::update` now by hand. - - * The apt::codename parameter has been removed. In its place, the - debian_codename fact may be overridden via an environment variable. This - will affect all other debian_* facts, and achieve the same result. - - FACTER_debian_codename=jessie puppet agent -t - - * If you were using custom 50unattended-upgrades.${::lsbdistcodename} in your - site_apt, these are no longer supported. You should migrate to passing - $blacklisted_packages to the apt::unattended_upgrades class. - - * the apt class has been moved to a paramterized class. if you were including - this class before, after passing some variables, you will need to move to - 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 - - 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 } - - previously, you could manually set $lsbdistcodename which would enable forced - upgrades, but because this is a top-level facter variable, and newer puppet - versions do not let you assign variables to other namespaces, this is no - longer possible. However, there is a way to obtain this functionality, and - that is to pass the 'codename' parameter to the apt class, which will change - the sources.list and preferences files to be the codename you set, allowing - you to trigger upgrades: - - include 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 - - you will need to remove the variables, and the include and instead do the - following: - - class { 'apt::apticron': email => 'foo@example.com', notifynew => '1' } - - * the apt::listchanges class has been moved to a paramterized class. if you - were including this class before, after passing some variables, you will need - 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 - - you will need to remove the variables, and the include and instead do the - following: - - class { 'apt::listchanges': email => 'foo@example.com' } - - * the apt::proxy_client class has been moved to a paramterized class. if you - were including this class before, after passing some variables, you will need - 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 - - 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' } - -Requirements -============ - -This module needs: - -- the lsb-release package should be installed on the server prior to running - puppet. otherwise, all of the $::lsb* facts will be empty during runs. -- the common module: https://gitlab.com/shared-puppet-modules-group/common - -By default, on normal hosts, this module sets the configuration option -DSelect::Clean to 'auto'. On virtual servers, the value is set by default to -'pre-auto', because virtual servers are usually more space-bound and have better -recovery mechanisms via the host: - -From apt.conf(5), 0.7.2: - "Cache Clean mode; this value may be one of always, prompt, auto, - pre-auto and never. always and prompt will remove all packages - from the cache after upgrading, prompt (the default) does so - conditionally. auto removes only those packages which are no - longer downloadable (replaced with a new version for - instance). pre-auto performs this action before downloading new - packages." - -To change the default setting for DSelect::Clean, you can create a file named -"03clean" or "03clean_vserver" in your site_apt module's files directory. You -can also define this for a specific host by creating a file in a subdirectory of -the site_apt modules' files directory that is named the same as the -host. (example: site_apt/files/some.host.com/03clean, or -site_apt/files/some.host.com/03clean_vserver) - -Classes -======= - -apt ---- - -The apt class sets up most of the documented functionality. To use functionality -that is not enabled by default, you must set one of the following parameters. - -Example usage: - - class { 'apt': use_next_release => true, debian_url => 'http://localhost:9999/debian/' } - -Class parameters: - -* use_lts - - If this variable is set to true the CODENAME-lts sources (such as - squeeze-lts) are added. - - By default this is false for backward compatibility with older - versions of this module. - -* use_volatile - - If this variable is set to true the CODENAME-updates sources (such as - squeeze-updates) are added. - - By default this is false for backward compatibility with older - versions of this module. - -* include_src - - If this variable is set to true a deb-src source is added for every - added binary archive source. - - By default this is false for backward compatibility with older - versions of this module. - -* use_next_release - - If this variable is set to true the sources for the next Debian - release are added. The default pinning configuration pins it to very - low values. - - By default this is false for backward compatibility with older - versions of this module. - -* debian_url, security_url, backports_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. - -* ubuntu_url - - These variables allows to override the default APT mirror used for all - standard Ubuntu archives (including updates, security, backports). - -* repos - - If this variable is set the default repositories list ("main contrib non-free") - is overriden. - -* custom_preferences - - For historical reasons (Debian Lenny's version of APT did not support the use - of the preferences.d directory for putting fragments of 'preferences'), this - module will manage a default generic apt/preferences file with more - recent releases pinned to very low values so that any package - installation will not accidentally pull in packages from those suites - unless you explicitly specify the version number. This file will be - complemented with all of the preferences_snippet calls (see below). - - If the default preferences template doesn't suit your needs, you can create a - template located in your site_apt module, and set custom_preferences with the - content (eg. custom_preferences => template('site_apt/preferences') ) - - Setting this variable to false before including this class will force the - apt/preferences file to be absent: - - class { 'apt': custom_preferences => false } - -* custom_sources_list - - By default this module will use a basic apt/sources.list template with - a generic Debian mirror. If you need to set more specific sources, - e.g. changing the sections included in the source, etc. you can set - this variable to the content that you desire to use instead. - - For example, setting this variable will pull in the - templates/site_apt/sources.list file: - - class { 'apt': custom_sources_list => template('site_apt/sources.list') } - -* custom_key_dir - - If you have different apt-key files that you want to get added to your - apt keyring, you can set this variable to a path in your fileserver - where individual key files can be placed. If this is set and keys - exist there, this module will 'apt-key add' each key. - - The debian-archive-keyring package is installed and kept current up to the - latest revision (this includes the backports archive keyring). - -apt::apticron -------------- - -When you instantiate this class, apticron will be installed, with the following -defaults, which you are free to change: - - $ensure_version = 'installed', - $config = "apt/${::operatingsystem}/apticron_${::lsbdistcodename}.erb", - $email = 'root', - $diff_only = '1', - $listchanges_profile = 'apticron', - $system = false, - $ipaddressnum = false, - $ipaddresses = false, - $notifyholds = '0', - $notifynew = '0', - $customsubject = '' - -Example usage: - - class { 'apt::apticron': email => 'foo@example.com', notifynew => '1' } - -apt::cron::download -------------------- - -This class sets up cron-apt so that it downloads upgradable packages, does not -actually do any upgrade and emails when the output changes. - -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 -be passed as the "hours" parameter of a cronjob. Example: - - # Run cron-apt every three hours - $apt_cron_hours = '*/3' - -Note that the default 4 AM cronjob won't be disabled. - -apt::cron::dist_upgrade ------------------------ - -This class sets up cron-apt so that it dist-upgrades the system and -emails when upgrades are performed. - -See apt::cron::download above if you need to run cron-apt more often -than once a day. - -apt::dist_upgrade ------------------ - -This class provides the Exec['apt_dist-upgrade'] resource that -dist-upgrade's the system. - -This exec is set as refreshonly so including this class does not -trigger any action per-se: other resources may notify it, other -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. - -apt::dist_upgrade::initiator ----------------------------- - -This class automatically dist-upgrade's the system when an initiator -file's content changes. The initiator file is copied from the first -available source amongst the following ones, in decreasing priority -order: - -- puppet:///modules/site_apt/${::fqdn}/upgrade_initiator -- puppet:///modules/site_apt/upgrade_initiator -- puppet:///modules/apt/upgrade_initiator - -This is useful when one does not want to setup a fully automated -upgrade process but still needs a way to manually trigger full -upgrades of any number of systems at scheduled times. - -Beware: a dist-upgrade is triggered the first time Puppet runs after -this class has been included. This is actually the single reason why -this class is not enabled by default. - -When this class is included the APT indexes are updated on every -Puppet run due to the author's lack of Puppet wizardry. - -apt::dselect ------------- - -This class, when included, installs dselect and switches it to expert mode to -suppress superfluous help screens. - -apt::listchanges ----------------- - -This class, when instantiated, installs apt-listchanges and configures it using -the following parameterized variables, which can be changed: - - version = 'present' - config = "apt/${::operatingsystem}/listchanges_${::lsbrelease}.erb" - frontend = 'pager' - email = 'root' - confirm = 0 - saveseen = '/var/lib/apt/listchanges.db' - which = 'both' - - Example usage: - class { 'apt::listchanges': email => 'foo@example.com' } - -apt::proxy_client ------------------ - -This class adds the right configuration to apt to make it fetch packages via a -proxy. The class parameters apt_proxy and apt_proxy_port need to be set: - -You can set the 'proxy' class parameter variable to the URL of the proxy that -will be used. By default, the proxy will be queried on port 3142, but you can -change the port number by setting the 'port' class parameter. - -Example: - - class { 'apt::proxy_client': proxy => 'http://proxy.domain', port => '666' } - -apt::reboot_required_notify ---------------------------- - -This class installs a daily cronjob that checks if a package upgrade -requires the system to be rebooted; if so, cron sends a notification -email to root. - -apt::unattended_upgrades ------------------------- - -If this class is included, it will install the package 'unattended-upgrades' -and configure it to daily upgrade the system. - -The class has the following parameters that you can use to change the contents -of the configuration file. The values shown here are the default values: - - * $config_content = undef - * $config_template = 'apt/50unattended-upgrades.erb' - * $mailonlyonerror = true - * $mail_recipient = 'root' - * $blacklisted_packages = [] - -Note that using $config_content actually specifies all of the configuration -contents and thus makes the other parameters useless. - -example: - - class { 'apt::unattended_upgrades': - config_template => 'site_apt/50unattended-upgrades.jessie', - blacklisted_packages => [ - 'libc6', 'libc6-dev', 'libc6-i686', 'mysql-server', 'redmine', 'nodejs', - 'bird' - ], - } - -Defines -======= - -apt::apt_conf -------------- - -Creates a file in the apt/apt.conf.d directory to easily add configuration -components. One can use either the 'source' meta-parameter to specify a list of -static files to include from the puppet fileserver or the 'content' -meta-parameter to define content inline or with the help of a template. - -Example: - - apt::apt_conf { '80download-only': - source => 'puppet:///modules/site_apt/80download-only', - } - -apt::preferences_snippet ------------------------- - -A way to add pinning information to files in /etc/apt/preferences.d/ - -Example: - - apt::preferences_snippet { - 'irssi-plugin-otr': - release => 'squeeze-backports', - priority => 999; - } - - apt::preferences_snippet { - 'unstable_fallback': - package => '*', - release => 'unstable', - priority => 1; - } - - apt::preferences_snippet { - 'ttdnsd': - pin => 'origin deb.torproject.org', - priority => 999; - } - -The names of the resources will be used as the names of the files in the -preferences.d directory, so you should ensure that resource names follow the -prescribed naming scheme. - -From apt_preferences(5): - Note that the files in the /etc/apt/preferences.d directory are parsed in - alphanumeric ascending order and need to obey the following naming - convention: The files have no or "pref" as filename extension and which - only contain alphanumeric, hyphen (-), underscore (_) and period (.) - characters - otherwise they will be silently ignored. - -apt::preseeded_package ----------------------- - -This simplifies installation of packages for which you wish to preseed the -answers to debconf. For example, if you wish to provide a preseed file for the -locales package, you would place the locales.seed file in -'site_apt/templates/${::lsbdistcodename}/locales.seeds' and then include the -following in your manifest: - - apt::preseeded_package { locales: } - -You can also specify the content of the seed via the content parameter, -for example: - - apt::preseeded_package { 'apticron': - content => 'apticron apticron/notification string root@example.com', - } - -apt::sources_list ------------------ - -Creates a file in the apt/sources.list.d directory to easily add additional apt -sources. One can use either the 'source' meta-parameter to specify a list of -static files to include from the puppet fileserver or the 'content' -meta-parameter to define content inline or with the help of a template. Ending -the resource name in '.list' is optional: it will be automatically added to the -file name if not present in the resource name. - -Example: - - apt::sources_list { 'company_internals': - source => [ "puppet:///modules/site_apt/${::fqdn}/company_internals.list", - 'puppet:///modules/site_apt/company_internals.list' ], - } - -apt::key --------- - -Deploys a secure apt OpenPGP key. This usually accompanies the -sources.list snippets above for third party repositories. For example, -you would do: - - apt::key { 'neurodebian.gpg': - ensure => present, - source => 'puppet:///modules/site_apt/neurodebian.gpg', - } - -This deploys the key in the `/etc/apt/trusted.gpg.d` directory, which -is assumed by secure apt to be binary OpenPGP keys and *not* -"ascii-armored" or "plain text" OpenPGP key material. For the latter, -use `apt::key::plain`. - -The `.gpg` extension is compulsory for `apt` to pickup the key properly. - -apt::key::plain ---------------- - -Deploys a secure apt OpenPGP key. This usually accompanies the -sources.list snippets above for third party repositories. For example, -you would do: - - apt::key::plain { 'neurodebian.asc': - source => 'puppet:///modules/site_apt/neurodebian.asc', - } - -This deploys the key in the `${apt_base_dir}/keys` directory (as -opposed to `$custom_key_dir` which deploys it in `keys.d`). The reason -this exists on top of `$custom_key_dir` is to allow a more -decentralised distribution of those keys, without having all modules -throw their keys in the same directory in the manifests. - -Note that this model does *not* currently allow keys to be removed! -Use `apt::key` instead for a more practical, revokable approach, but -that needs binary keys. - -apt::upgrade_package --------------------- - -This simplifies upgrades for DSA security announcements or point-releases. This -will ensure that the named package is upgraded to the version specified, only if -the package is installed, otherwise nothing happens. If the specified version -is 'latest' (the default), then the package is ensured to be upgraded to the -latest package revision when it becomes available. - -For example, the following upgrades the perl package to version 5.8.8-7etch1 -(if it is installed), it also upgrades the syslog-ng and perl-modules packages -to their latest (also, only if they are installed): - -upgrade_package { 'perl': - version => '5.8.8-7etch1'; - 'syslog-ng': - version => latest; - 'perl-modules': -} - -Resources -========= - -File['apt_config'] ------------------- - -Use this resource to depend on or add to a completed apt configuration - -Exec['apt_updated'] -------------------- - -After this point the APT indexes are up-to-date. -This resource is set to `refreshonly => true` so it is not run on -every puppetrun. To run this every time, you can include the `apt::update` -class. - -This resource is usually used like this to ensure current packages are -installed by Package resources: - - include apt::update - Package { require => Exec['apt_updated'] } - -Note that nodes can be updated once a day by using - - APT::Periodic::Update-Package-Lists "1"; - -in i.e. /etc/apt/apt.conf.d/80_apt_update_daily. - - -Tests -===== - -To run pupept rspec tests: - - bundle install --path vendor/bundle - bundle exec rake spec - -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 - -Licensing -========= - -This puppet module is licensed under the GPL version 3 or later. Redistribution -and modification is encouraged. - -The GPL version 3 license text can be found in the "LICENSE" file accompanying -this puppet module, or at the following URL: - -http://www.gnu.org/licenses/gpl-3.0.html -- cgit v1.2.3 From fca9b745eabb3d85ed4b53b61654ced1e5cd342f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Wed, 27 Apr 2016 14:29:00 -0400 Subject: README is now markdown --- README.md | 620 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 620 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f9ab19a --- /dev/null +++ b/README.md @@ -0,0 +1,620 @@ +# apt module + +#### Table of Contents + +* [Overview](#overview) + * [Upgrade Notice](#upgrade-notice) +* [Requirements](#requirements) +* [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) + * [apt::dselect](#apt-dselect) + * [apt::listchanges](#apt-listchanges) + * [apt::proxy_client](apt-proxy_client) + * [apt::reboot_required_notify](apt-reboot_required_notify) + * [apt::unattended_upgrades](#apt-unattended_upgrades) +* [Defines](#defines) + * [apt::apt_conf](#apt-apt_conf) + * [apt::preferences_snippet](#apt-preferences_snippet) + * [apt::preseeded_package](#apt-preseeded_package) + * [apt::sources_list](#apt-sources_list) + * [apt::key](#apt-key) + * [apt::key::plain](#apt-key-plain) + * [apt::upgrade_package](#apt-upgrade_package) +* [Resources](#ressources) + * [File\['apt_config'\]](#file-apt_config) + * [Exec\['apt_updated'\]](#exec-apt_updated) +* [Tests](#tests) +* [Licensing](#licensing) + + +# Overview + +This module manages apt on Debian. + +It keeps dpkg's and apt's databases as well as the keyrings for securing +package download current. + +backports.debian.org is added. + +/etc/apt/sources.list and /etc/apt/preferences are managed. More +recent Debian releases are pinned to very low values by default to +prevent accidental upgrades. + +Ubuntu support is lagging behind but not absent either. + +## Upgrade Notice + + * 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. + You can include the `apt::update` class if you want it to be run every time. + + * The `apt::upgrade_package` now doesn't automatically call an Exec['apt_updated'] + anymore, so you would need to include `apt::update` now by hand. + + * The apt::codename parameter has been removed. In its place, the + debian_codename fact may be overridden via an environment variable. This + will affect all other debian_* facts, and achieve the same result. + + FACTER_debian_codename=jessie puppet agent -t + + * If you were using custom 50unattended-upgrades.${::lsbdistcodename} in your + site_apt, these are no longer supported. You should migrate to passing + $blacklisted_packages to the apt::unattended_upgrades class. + + * the apt class has been moved to a paramterized class. if you were including + this class before, after passing some variables, you will need to move to + 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 + + 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 } + + previously, you could manually set $lsbdistcodename which would enable forced + upgrades, but because this is a top-level facter variable, and newer puppet + versions do not let you assign variables to other namespaces, this is no + longer possible. However, there is a way to obtain this functionality, and + that is to pass the 'codename' parameter to the apt class, which will change + the sources.list and preferences files to be the codename you set, allowing + you to trigger upgrades: + + include 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 + + you will need to remove the variables, and the include and instead do the + following: + + class { 'apt::apticron': email => 'foo@example.com', notifynew => '1' } + + * the apt::listchanges class has been moved to a paramterized class. if you + were including this class before, after passing some variables, you will need + 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 + + you will need to remove the variables, and the include and instead do the + following: + + class { 'apt::listchanges': email => 'foo@example.com' } + + * the apt::proxy_client class has been moved to a paramterized class. if you + were including this class before, after passing some variables, you will need + 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 + + 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' } + + +# Requirements + +This module needs: + +- the lsb-release package should be installed on the server prior to running + puppet. otherwise, all of the $::lsb* facts will be empty during runs. +- the common module: https://gitlab.com/shared-puppet-modules-group/common + +By default, on normal hosts, this module sets the configuration option +DSelect::Clean to 'auto'. On virtual servers, the value is set by default to +'pre-auto', because virtual servers are usually more space-bound and have better +recovery mechanisms via the host: + +From apt.conf(5), 0.7.2: + "Cache Clean mode; this value may be one of always, prompt, auto, + pre-auto and never. always and prompt will remove all packages + from the cache after upgrading, prompt (the default) does so + conditionally. auto removes only those packages which are no + longer downloadable (replaced with a new version for + instance). pre-auto performs this action before downloading new + packages." + +To change the default setting for DSelect::Clean, you can create a file named +"03clean" or "03clean_vserver" in your site_apt module's files directory. You +can also define this for a specific host by creating a file in a subdirectory of +the site_apt modules' files directory that is named the same as the +host. (example: site_apt/files/some.host.com/03clean, or +site_apt/files/some.host.com/03clean_vserver) + + +# Classes + +## apt + +The apt class sets up most of the documented functionality. To use functionality +that is not enabled by default, you must set one of the following parameters. + +Example usage: + + class { 'apt': use_next_release => true, debian_url => 'http://localhost:9999/debian/' } + +Class parameters: + +### use_lts + + If this variable is set to true the CODENAME-lts sources (such as + squeeze-lts) are added. + + By default this is false for backward compatibility with older + versions of this module. + +### use_volatile + + If this variable is set to true the CODENAME-updates sources (such as + squeeze-updates) are added. + + By default this is false for backward compatibility with older + versions of this module. + +### include_src + + If this variable is set to true a deb-src source is added for every + added binary archive source. + + By default this is false for backward compatibility with older + versions of this module. + +### use_next_release + + If this variable is set to true the sources for the next Debian + release are added. The default pinning configuration pins it to very + low values. + + By default this is false for backward compatibility with older + versions of this module. + +### debian_url, security_url, backports_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. + +### ubuntu_url + + These variables allows to override the default APT mirror used for all + standard Ubuntu archives (including updates, security, backports). + +### repos + + If this variable is set the default repositories list ("main contrib non-free") + is overriden. + +### custom_preferences + + For historical reasons (Debian Lenny's version of APT did not support the use + of the preferences.d directory for putting fragments of 'preferences'), this + module will manage a default generic apt/preferences file with more + recent releases pinned to very low values so that any package + installation will not accidentally pull in packages from those suites + unless you explicitly specify the version number. This file will be + complemented with all of the preferences_snippet calls (see below). + + If the default preferences template doesn't suit your needs, you can create a + template located in your site_apt module, and set custom_preferences with the + content (eg. custom_preferences => template('site_apt/preferences') ) + + Setting this variable to false before including this class will force the + apt/preferences file to be absent: + + class { 'apt': custom_preferences => false } + +### custom_sources_list + + By default this module will use a basic apt/sources.list template with + a generic Debian mirror. If you need to set more specific sources, + e.g. changing the sections included in the source, etc. you can set + this variable to the content that you desire to use instead. + + For example, setting this variable will pull in the + templates/site_apt/sources.list file: + + class { 'apt': custom_sources_list => template('site_apt/sources.list') } + +### custom_key_dir + + If you have different apt-key files that you want to get added to your + apt keyring, you can set this variable to a path in your fileserver + where individual key files can be placed. If this is set and keys + exist there, this module will 'apt-key add' each key. + + The debian-archive-keyring package is installed and kept current up to the + latest revision (this includes the backports archive keyring). + + +## apt::apticron + +When you instantiate this class, apticron will be installed, with the following +defaults, which you are free to change: + + $ensure_version = 'installed', + $config = "apt/${::operatingsystem}/apticron_${::lsbdistcodename}.erb", + $email = 'root', + $diff_only = '1', + $listchanges_profile = 'apticron', + $system = false, + $ipaddressnum = false, + $ipaddresses = false, + $notifyholds = '0', + $notifynew = '0', + $customsubject = '' + +Example usage: + + class { 'apt::apticron': email => 'foo@example.com', notifynew => '1' } + + +## apt::cron::download + +This class sets up cron-apt so that it downloads upgradable packages, does not +actually do any upgrade and emails when the output changes. + +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 +be passed as the "hours" parameter of a cronjob. Example: + + # Run cron-apt every three hours + $apt_cron_hours = '*/3' + +Note that the default 4 AM cronjob won't be disabled. + + +## apt::cron::dist_upgrade + +This class sets up cron-apt so that it dist-upgrades the system and +emails when upgrades are performed. + +See apt::cron::download above if you need to run cron-apt more often +than once a day. + + +## apt::dist_upgrade + +This class provides the Exec['apt_dist-upgrade'] resource that +dist-upgrade's the system. + +This exec is set as refreshonly so including this class does not +trigger any action per-se: other resources may notify it, other +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. + + +## apt::dist_upgrade::initiator + +This class automatically dist-upgrade's the system when an initiator +file's content changes. The initiator file is copied from the first +available source amongst the following ones, in decreasing priority +order: + +- puppet:///modules/site_apt/${::fqdn}/upgrade_initiator +- puppet:///modules/site_apt/upgrade_initiator +- puppet:///modules/apt/upgrade_initiator + +This is useful when one does not want to setup a fully automated +upgrade process but still needs a way to manually trigger full +upgrades of any number of systems at scheduled times. + +Beware: a dist-upgrade is triggered the first time Puppet runs after +this class has been included. This is actually the single reason why +this class is not enabled by default. + +When this class is included the APT indexes are updated on every +Puppet run due to the author's lack of Puppet wizardry. + + +## apt::dselect + +This class, when included, installs dselect and switches it to expert mode to +suppress superfluous help screens. + + +## apt::listchanges + +This class, when instantiated, installs apt-listchanges and configures it using +the following parameterized variables, which can be changed: + + version = 'present' + config = "apt/${::operatingsystem}/listchanges_${::lsbrelease}.erb" + frontend = 'pager' + email = 'root' + confirm = 0 + saveseen = '/var/lib/apt/listchanges.db' + which = 'both' + + Example usage: + class { 'apt::listchanges': email => 'foo@example.com' } + + +## apt::proxy_client + +This class adds the right configuration to apt to make it fetch packages via a +proxy. The class parameters apt_proxy and apt_proxy_port need to be set: + +You can set the 'proxy' class parameter variable to the URL of the proxy that +will be used. By default, the proxy will be queried on port 3142, but you can +change the port number by setting the 'port' class parameter. + +Example: + + class { 'apt::proxy_client': proxy => 'http://proxy.domain', port => '666' } + + +## apt::reboot_required_notify + +This class installs a daily cronjob that checks if a package upgrade +requires the system to be rebooted; if so, cron sends a notification +email to root. + + +## apt::unattended_upgrades + +If this class is included, it will install the package 'unattended-upgrades' +and configure it to daily upgrade the system. + +The class has the following parameters that you can use to change the contents +of the configuration file. The values shown here are the default values: + + * $config_content = undef + * $config_template = 'apt/50unattended-upgrades.erb' + * $mailonlyonerror = true + * $mail_recipient = 'root' + * $blacklisted_packages = [] + +Note that using $config_content actually specifies all of the configuration +contents and thus makes the other parameters useless. + +example: + + class { 'apt::unattended_upgrades': + config_template => 'site_apt/50unattended-upgrades.jessie', + blacklisted_packages => [ + 'libc6', 'libc6-dev', 'libc6-i686', 'mysql-server', 'redmine', 'nodejs', + 'bird' + ], + } + + +# Defines + +## apt::apt_conf + +Creates a file in the apt/apt.conf.d directory to easily add configuration +components. One can use either the 'source' meta-parameter to specify a list of +static files to include from the puppet fileserver or the 'content' +meta-parameter to define content inline or with the help of a template. + +Example: + + apt::apt_conf { '80download-only': + source => 'puppet:///modules/site_apt/80download-only', + } + + +## apt::preferences_snippet + +A way to add pinning information to files in /etc/apt/preferences.d/ + +Example: + + apt::preferences_snippet { + 'irssi-plugin-otr': + release => 'squeeze-backports', + priority => 999; + } + + apt::preferences_snippet { + 'unstable_fallback': + package => '*', + release => 'unstable', + priority => 1; + } + + apt::preferences_snippet { + 'ttdnsd': + pin => 'origin deb.torproject.org', + priority => 999; + } + +The names of the resources will be used as the names of the files in the +preferences.d directory, so you should ensure that resource names follow the +prescribed naming scheme. + +From apt_preferences(5): + Note that the files in the /etc/apt/preferences.d directory are parsed in + alphanumeric ascending order and need to obey the following naming + convention: The files have no or "pref" as filename extension and which + only contain alphanumeric, hyphen (-), underscore (_) and period (.) + characters - otherwise they will be silently ignored. + + +## apt::preseeded_package + +This simplifies installation of packages for which you wish to preseed the +answers to debconf. For example, if you wish to provide a preseed file for the +locales package, you would place the locales.seed file in +'site_apt/templates/${::lsbdistcodename}/locales.seeds' and then include the +following in your manifest: + + apt::preseeded_package { locales: } + +You can also specify the content of the seed via the content parameter, +for example: + + apt::preseeded_package { 'apticron': + content => 'apticron apticron/notification string root@example.com', + } + + +## apt::sources_list + +Creates a file in the apt/sources.list.d directory to easily add additional apt +sources. One can use either the 'source' meta-parameter to specify a list of +static files to include from the puppet fileserver or the 'content' +meta-parameter to define content inline or with the help of a template. Ending +the resource name in '.list' is optional: it will be automatically added to the +file name if not present in the resource name. + +Example: + + apt::sources_list { 'company_internals': + source => [ "puppet:///modules/site_apt/${::fqdn}/company_internals.list", + 'puppet:///modules/site_apt/company_internals.list' ], + } + + +## apt::key + +Deploys a secure apt OpenPGP key. This usually accompanies the +sources.list snippets above for third party repositories. For example, +you would do: + + apt::key { 'neurodebian.gpg': + ensure => present, + source => 'puppet:///modules/site_apt/neurodebian.gpg', + } + +This deploys the key in the `/etc/apt/trusted.gpg.d` directory, which +is assumed by secure apt to be binary OpenPGP keys and *not* +"ascii-armored" or "plain text" OpenPGP key material. For the latter, +use `apt::key::plain`. + +The `.gpg` extension is compulsory for `apt` to pickup the key properly. + + +## apt::key::plain + +Deploys a secure apt OpenPGP key. This usually accompanies the +sources.list snippets above for third party repositories. For example, +you would do: + + apt::key::plain { 'neurodebian.asc': + source => 'puppet:///modules/site_apt/neurodebian.asc', + } + +This deploys the key in the `${apt_base_dir}/keys` directory (as +opposed to `$custom_key_dir` which deploys it in `keys.d`). The reason +this exists on top of `$custom_key_dir` is to allow a more +decentralised distribution of those keys, without having all modules +throw their keys in the same directory in the manifests. + +Note that this model does *not* currently allow keys to be removed! +Use `apt::key` instead for a more practical, revokable approach, but +that needs binary keys. + + +## apt::upgrade_package + +This simplifies upgrades for DSA security announcements or point-releases. This +will ensure that the named package is upgraded to the version specified, only if +the package is installed, otherwise nothing happens. If the specified version +is 'latest' (the default), then the package is ensured to be upgraded to the +latest package revision when it becomes available. + +For example, the following upgrades the perl package to version 5.8.8-7etch1 +(if it is installed), it also upgrades the syslog-ng and perl-modules packages +to their latest (also, only if they are installed): + +upgrade_package { 'perl': + version => '5.8.8-7etch1'; + 'syslog-ng': + version => latest; + 'perl-modules': +} + + +# Resources + +## File['apt_config'] + +Use this resource to depend on or add to a completed apt configuration + +## Exec['apt_updated'] + +After this point the APT indexes are up-to-date. +This resource is set to `refreshonly => true` so it is not run on +every puppetrun. To run this every time, you can include the `apt::update` +class. + +This resource is usually used like this to ensure current packages are +installed by Package resources: + + include apt::update + Package { require => Exec['apt_updated'] } + +Note that nodes can be updated once a day by using + + APT::Periodic::Update-Package-Lists "1"; + +in i.e. /etc/apt/apt.conf.d/80_apt_update_daily. + + +# Tests + +To run pupept rspec tests: + + bundle install --path vendor/bundle + bundle exec rake spec + +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 + + +# Licensing + +This puppet module is licensed under the GPL version 3 or later. Redistribution +and modification is encouraged. + +The GPL version 3 license text can be found in the "LICENSE" file accompanying +this puppet module, or at the following URL: + +http://www.gnu.org/licenses/gpl-3.0.html -- cgit v1.2.3 From 511cd83922b7522f20dcb5ff61c0c600932cea37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Wed, 27 Apr 2016 14:31:20 -0400 Subject: typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f9ab19a..d700853 100644 --- a/README.md +++ b/README.md @@ -356,7 +356,7 @@ This class, when included, installs dselect and switches it to expert mode to suppress superfluous help screens. -## apt::listchanges +## apt::listchanges This class, when instantiated, installs apt-listchanges and configures it using the following parameterized variables, which can be changed: -- cgit v1.2.3 From cfb1eefa1dd8b651fc03524803ba21b1b1684f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Wed, 27 Apr 2016 14:33:08 -0400 Subject: typo (bis) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d700853..cac0f65 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ * [apt::dist_upgrade::initiator](#apt-dist_upgrade-initiator) * [apt::dselect](#apt-dselect) * [apt::listchanges](#apt-listchanges) - * [apt::proxy_client](apt-proxy_client) - * [apt::reboot_required_notify](apt-reboot_required_notify) + * [apt::proxy_client](#apt-proxy_client) + * [apt::reboot_required_notify](#apt-reboot_required_notify) * [apt::unattended_upgrades](#apt-unattended_upgrades) * [Defines](#defines) * [apt::apt_conf](#apt-apt_conf) -- cgit v1.2.3 From b45d09561e70bcb7429c9a2ecb481fc31ae20814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Wed, 27 Apr 2016 14:38:47 -0400 Subject: typo (tris?) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cac0f65..dce6131 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ * [apt::key::plain](#apt-key-plain) * [apt::upgrade_package](#apt-upgrade_package) * [Resources](#ressources) - * [File\['apt_config'\]](#file-apt_config) - * [Exec\['apt_updated'\]](#exec-apt_updated) + * [File\['apt_config'\]](#fileapt_config) + * [Exec\['apt_updated'\]](#execapt_updated) * [Tests](#tests) * [Licensing](#licensing) @@ -529,7 +529,7 @@ use `apt::key::plain`. The `.gpg` extension is compulsory for `apt` to pickup the key properly. -## apt::key::plain +## apt ::key::plain Deploys a secure apt OpenPGP key. This usually accompanies the sources.list snippets above for third party repositories. For example, -- cgit v1.2.3 From ec3bceff10b0227ec3b9db06e6fa410b432116cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Wed, 27 Apr 2016 15:00:35 -0400 Subject: syntax highlighting --- README.md | 274 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 139 insertions(+), 135 deletions(-) diff --git a/README.md b/README.md index dce6131..7151dd1 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ package download current. backports.debian.org is added. -/etc/apt/sources.list and /etc/apt/preferences are managed. More +`/etc/apt/sources.list` and `/etc/apt/preferences` are managed. More recent Debian releases are pinned to very low values by default to prevent accidental upgrades. @@ -54,18 +54,18 @@ Ubuntu support is lagging behind but not absent either. parameter seems useless. You can include the `apt::update` class if you want it to be run every time. - * The `apt::upgrade_package` now doesn't automatically call an Exec['apt_updated'] + * The `apt::upgrade_package` now doesn't automatically call an `Exec['apt_updated']` anymore, so you would need to include `apt::update` now by hand. - * The apt::codename parameter has been removed. In its place, the - debian_codename fact may be overridden via an environment variable. This - will affect all other debian_* facts, and achieve the same result. + * The `apt::codename` parameter has been removed. In its place, the + `debian_codename` fact may be overridden via an environment variable. This + will affect all other `debian_*` facts, and achieve the same result. - FACTER_debian_codename=jessie puppet agent -t + FACTER_debian_codename=jessie puppet agent -t - * If you were using custom 50unattended-upgrades.${::lsbdistcodename} in your - site_apt, these are no longer supported. You should migrate to passing - $blacklisted_packages to the apt::unattended_upgrades class. + * If you were using custom `50unattended-upgrades.${::lsbdistcodename}` in your + `site_apt`, these are no longer supported. You should migrate to passing + `$blacklisted_packages` to the `apt::unattended_upgrades` class. * the apt class has been moved to a paramterized class. if you were including this class before, after passing some variables, you will need to move to @@ -81,18 +81,18 @@ Ubuntu support is lagging behind but not absent either. class { 'apt': debian_url => 'http://localhost:9999/debian/', use_next_release => true } - previously, you could manually set $lsbdistcodename which would enable forced + previously, you could manually set `$lsbdistcodename` which would enable forced upgrades, but because this is a top-level facter variable, and newer puppet versions do not let you assign variables to other namespaces, this is no longer possible. However, there is a way to obtain this functionality, and that is to pass the 'codename' parameter to the apt class, which will change - the sources.list and preferences files to be the codename you set, allowing + the `sources.list` and `preferences` files to be the codename you set, allowing you to trigger upgrades: - include apt::dist_upgrade - class { 'apt': codename => 'wheezy', notify => Exec['apt_dist-upgrade'] } + include 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 + * 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: @@ -106,7 +106,7 @@ Ubuntu support is lagging behind but not absent either. class { 'apt::apticron': email => 'foo@example.com', notifynew => '1' } - * the apt::listchanges class has been moved to a paramterized class. if you + * the `apt::listchanges` class has been moved to a paramterized class. if you were including this class before, after passing some variables, you will need to move to instantiating the class with those variables instead. For example, if you had the following in your manifests: @@ -120,7 +120,7 @@ Ubuntu support is lagging behind but not absent either. class { 'apt::listchanges': email => 'foo@example.com' } - * the apt::proxy_client class has been moved to a paramterized class. if you + * the `apt::proxy_client` class has been moved to a paramterized class. if you were including this class before, after passing some variables, you will need to move to instantiating the class with those variables instead. For example, if you had the following in your manifests: @@ -139,12 +139,13 @@ Ubuntu support is lagging behind but not absent either. This module needs: -- the lsb-release package should be installed on the server prior to running - puppet. otherwise, all of the $::lsb* facts will be empty during runs. -- the common module: https://gitlab.com/shared-puppet-modules-group/common + * the `lsb-release` package should be installed on the server prior to running + puppet. otherwise, all of the `$::lsb*` facts will be empty during runs. + + * the [common module](https://gitlab.com/shared-puppet-modules-group/common) By default, on normal hosts, this module sets the configuration option -DSelect::Clean to 'auto'. On virtual servers, the value is set by default to +`DSelect::Clean` to 'auto'. On virtual servers, the value is set by default to 'pre-auto', because virtual servers are usually more space-bound and have better recovery mechanisms via the host: @@ -157,10 +158,10 @@ From apt.conf(5), 0.7.2: instance). pre-auto performs this action before downloading new packages." -To change the default setting for DSelect::Clean, you can create a file named -"03clean" or "03clean_vserver" in your site_apt module's files directory. You +To change the default setting for `DSelect::Clean`, you can create a file named +"03clean" or "03clean_vserver" in your `site_apt` module's files directory. You can also define this for a specific host by creating a file in a subdirectory of -the site_apt modules' files directory that is named the same as the +the `site_apt` modules' files directory that is named the same as the host. (example: site_apt/files/some.host.com/03clean, or site_apt/files/some.host.com/03clean_vserver) @@ -174,7 +175,7 @@ that is not enabled by default, you must set one of the following parameters. Example usage: - class { 'apt': use_next_release => true, debian_url => 'http://localhost:9999/debian/' } + class { 'apt': use_next_release => true, debian_url => 'http://localhost:9999/debian/' } Class parameters: @@ -230,7 +231,7 @@ Class parameters: ### custom_preferences For historical reasons (Debian Lenny's version of APT did not support the use - of the preferences.d directory for putting fragments of 'preferences'), this + of the `preferences.d` directory for putting fragments of 'preferences'), this module will manage a default generic apt/preferences file with more recent releases pinned to very low values so that any package installation will not accidentally pull in packages from those suites @@ -238,32 +239,32 @@ Class parameters: complemented with all of the preferences_snippet calls (see below). If the default preferences template doesn't suit your needs, you can create a - template located in your site_apt module, and set custom_preferences with the + template located in your `site_apt` module, and set custom_preferences with the content (eg. custom_preferences => template('site_apt/preferences') ) Setting this variable to false before including this class will force the - apt/preferences file to be absent: + `apt/preferences` file to be absent: class { 'apt': custom_preferences => false } ### custom_sources_list - By default this module will use a basic apt/sources.list template with + By default this module will use a basic `apt/sources.list` template with a generic Debian mirror. If you need to set more specific sources, e.g. changing the sections included in the source, etc. you can set this variable to the content that you desire to use instead. For example, setting this variable will pull in the - templates/site_apt/sources.list file: + `templates/site_apt/sources.list` file: - class { 'apt': custom_sources_list => template('site_apt/sources.list') } + class { 'apt': custom_sources_list => template('site_apt/sources.list') } ### custom_key_dir If you have different apt-key files that you want to get added to your apt keyring, you can set this variable to a path in your fileserver where individual key files can be placed. If this is set and keys - exist there, this module will 'apt-key add' each key. + exist there, this module will `apt-key add` each key. The debian-archive-keyring package is installed and kept current up to the latest revision (this includes the backports archive keyring). @@ -274,34 +275,34 @@ Class parameters: When you instantiate this class, apticron will be installed, with the following defaults, which you are free to change: - $ensure_version = 'installed', - $config = "apt/${::operatingsystem}/apticron_${::lsbdistcodename}.erb", - $email = 'root', - $diff_only = '1', - $listchanges_profile = 'apticron', - $system = false, - $ipaddressnum = false, - $ipaddresses = false, - $notifyholds = '0', - $notifynew = '0', - $customsubject = '' + $ensure_version = 'installed', + $config = "apt/${::operatingsystem}/apticron_${::lsbdistcodename}.erb", + $email = 'root', + $diff_only = '1', + $listchanges_profile = 'apticron', + $system = false, + $ipaddressnum = false, + $ipaddresses = false, + $notifyholds = '0', + $notifynew = '0', + $customsubject = '' Example usage: - class { 'apt::apticron': email => 'foo@example.com', notifynew => '1' } + class { 'apt::apticron': email => 'foo@example.com', notifynew => '1' } ## apt::cron::download -This class sets up cron-apt so that it downloads upgradable packages, does not +This class sets up `cron-apt` so that it downloads upgradable packages, does not actually do any upgrade and emails when the output changes. -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-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 be passed as the "hours" parameter of a cronjob. Example: - # Run cron-apt every three hours - $apt_cron_hours = '*/3' + # Run cron-apt every three hours + $apt_cron_hours = '*/3' Note that the default 4 AM cronjob won't be disabled. @@ -311,20 +312,20 @@ Note that the default 4 AM cronjob won't be disabled. This class sets up cron-apt so that it dist-upgrades the system and emails when upgrades are performed. -See apt::cron::download above if you need to run cron-apt more often +See [apt::cron::download](#apt-cron-download) above if you need to run `cron-apt` more often than once a day. ## apt::dist_upgrade -This class provides the Exec['apt_dist-upgrade'] resource that +This class provides the `Exec['apt_dist-upgrade']` resource that dist-upgrade's the system. This exec is set as refreshonly so including this class does not trigger any action per-se: other resources may notify it, other 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. +using the plusignment (`+>`) operator. A real-world example can be +seen in the `apt::dist_upgrade::initiator` source. ## apt::dist_upgrade::initiator @@ -334,15 +335,17 @@ file's content changes. The initiator file is copied from the first available source amongst the following ones, in decreasing priority order: -- puppet:///modules/site_apt/${::fqdn}/upgrade_initiator -- puppet:///modules/site_apt/upgrade_initiator -- puppet:///modules/apt/upgrade_initiator + * `puppet:///modules/site_apt/${::fqdn}/upgrade_initiator` + + * `puppet:///modules/site_apt/upgrade_initiator` + + * `puppet:///modules/apt/upgrade_initiator` This is useful when one does not want to setup a fully automated upgrade process but still needs a way to manually trigger full upgrades of any number of systems at scheduled times. -Beware: a dist-upgrade is triggered the first time Puppet runs after +**Beware:** a `dist-upgrade` is triggered the first time Puppet runs after this class has been included. This is actually the single reason why this class is not enabled by default. @@ -358,33 +361,34 @@ suppress superfluous help screens. ## apt::listchanges -This class, when instantiated, installs apt-listchanges and configures it using +This class, when instantiated, installs `apt-listchanges` and configures it using the following parameterized variables, which can be changed: - version = 'present' - config = "apt/${::operatingsystem}/listchanges_${::lsbrelease}.erb" - frontend = 'pager' - email = 'root' - confirm = 0 - saveseen = '/var/lib/apt/listchanges.db' - which = 'both' + version = 'present' + config = "apt/${::operatingsystem}/listchanges_${::lsbrelease}.erb" + frontend = 'pager' + email = 'root' + confirm = 0 + saveseen = '/var/lib/apt/listchanges.db' + which = 'both' - Example usage: - class { 'apt::listchanges': email => 'foo@example.com' } +Example usage: + + class { 'apt::listchanges': email => 'foo@example.com' } ## apt::proxy_client This class adds the right configuration to apt to make it fetch packages via a -proxy. The class parameters apt_proxy and apt_proxy_port need to be set: +proxy. The class parameters `apt_proxy` and `apt_proxy_port` need to be set: -You can set the 'proxy' class parameter variable to the URL of the proxy that +You can set the `proxy` class parameter variable to the URL of the proxy that will be used. By default, the proxy will be queried on port 3142, but you can -change the port number by setting the 'port' class parameter. +change the port number by setting the `port` class parameter. -Example: +Example usage: - class { 'apt::proxy_client': proxy => 'http://proxy.domain', port => '666' } + class { 'apt::proxy_client': proxy => 'http://proxy.domain', port => '666' } ## apt::reboot_required_notify @@ -396,22 +400,22 @@ email to root. ## apt::unattended_upgrades -If this class is included, it will install the package 'unattended-upgrades' +If this class is included, it will install the package `unattended-upgrades` and configure it to daily upgrade the system. The class has the following parameters that you can use to change the contents of the configuration file. The values shown here are the default values: - * $config_content = undef - * $config_template = 'apt/50unattended-upgrades.erb' - * $mailonlyonerror = true - * $mail_recipient = 'root' - * $blacklisted_packages = [] + $config_content = undef + $config_template = 'apt/50unattended-upgrades.erb' + $mailonlyonerror = true + $mail_recipient = 'root' + $blacklisted_packages = [] -Note that using $config_content actually specifies all of the configuration +Note that using `$config_content` actually specifies all of the configuration contents and thus makes the other parameters useless. -example: +Example usage: class { 'apt::unattended_upgrades': config_template => 'site_apt/50unattended-upgrades.jessie', @@ -426,42 +430,42 @@ example: ## apt::apt_conf -Creates a file in the apt/apt.conf.d directory to easily add configuration -components. One can use either the 'source' meta-parameter to specify a list of -static files to include from the puppet fileserver or the 'content' +Creates a file in the `apt/apt.conf.d` directory to easily add configuration +components. One can use either the `source` meta-parameter to specify a list of +static files to include from the puppet fileserver or the `content` meta-parameter to define content inline or with the help of a template. -Example: +Example usage: - apt::apt_conf { '80download-only': - source => 'puppet:///modules/site_apt/80download-only', - } + apt::apt_conf { '80download-only': + source => 'puppet:///modules/site_apt/80download-only', + } ## apt::preferences_snippet -A way to add pinning information to files in /etc/apt/preferences.d/ +A way to add pinning information to files in `/etc/apt/preferences.d/` Example: - apt::preferences_snippet { - 'irssi-plugin-otr': - release => 'squeeze-backports', - priority => 999; - } - - apt::preferences_snippet { - 'unstable_fallback': - package => '*', - release => 'unstable', - priority => 1; - } - - apt::preferences_snippet { - 'ttdnsd': - pin => 'origin deb.torproject.org', - priority => 999; - } + apt::preferences_snippet { + 'irssi-plugin-otr': + release => 'squeeze-backports', + priority => 999; + } + + apt::preferences_snippet { + 'unstable_fallback': + package => '*', + release => 'unstable', + priority => 1; + } + + apt::preferences_snippet { + 'ttdnsd': + pin => 'origin deb.torproject.org', + priority => 999; + } The names of the resources will be used as the names of the files in the preferences.d directory, so you should ensure that resource names follow the @@ -479,35 +483,35 @@ From apt_preferences(5): This simplifies installation of packages for which you wish to preseed the answers to debconf. For example, if you wish to provide a preseed file for the -locales package, you would place the locales.seed file in -'site_apt/templates/${::lsbdistcodename}/locales.seeds' and then include the +locales package, you would place the `locales.seed` file in +`site_apt/templates/${::lsbdistcodename}/locales.seeds` and then include the following in your manifest: - apt::preseeded_package { locales: } + apt::preseeded_package { locales: } You can also specify the content of the seed via the content parameter, for example: - apt::preseeded_package { 'apticron': - content => 'apticron apticron/notification string root@example.com', - } + apt::preseeded_package { 'apticron': + content => 'apticron apticron/notification string root@example.com', + } ## apt::sources_list -Creates a file in the apt/sources.list.d directory to easily add additional apt -sources. One can use either the 'source' meta-parameter to specify a list of -static files to include from the puppet fileserver or the 'content' +Creates a file in the `apt/sources.list.d` directory to easily add additional apt +sources. One can use either the `source` meta-parameter to specify a list of +static files to include from the puppet fileserver or the `content` meta-parameter to define content inline or with the help of a template. Ending -the resource name in '.list' is optional: it will be automatically added to the +the resource name in `.list` is optional: it will be automatically added to the file name if not present in the resource name. -Example: +Example usage: - apt::sources_list { 'company_internals': - source => [ "puppet:///modules/site_apt/${::fqdn}/company_internals.list", - 'puppet:///modules/site_apt/company_internals.list' ], - } + apt::sources_list { 'company_internals': + source => [ "puppet:///modules/site_apt/${::fqdn}/company_internals.list", + 'puppet:///modules/site_apt/company_internals.list' ], + } ## apt::key @@ -516,10 +520,10 @@ Deploys a secure apt OpenPGP key. This usually accompanies the sources.list snippets above for third party repositories. For example, you would do: - apt::key { 'neurodebian.gpg': - ensure => present, - source => 'puppet:///modules/site_apt/neurodebian.gpg', - } + apt::key { 'neurodebian.gpg': + ensure => present, + source => 'puppet:///modules/site_apt/neurodebian.gpg', + } This deploys the key in the `/etc/apt/trusted.gpg.d` directory, which is assumed by secure apt to be binary OpenPGP keys and *not* @@ -529,15 +533,15 @@ use `apt::key::plain`. The `.gpg` extension is compulsory for `apt` to pickup the key properly. -## apt ::key::plain +## apt:: key::plain Deploys a secure apt OpenPGP key. This usually accompanies the sources.list snippets above for third party repositories. For example, you would do: - apt::key::plain { 'neurodebian.asc': - source => 'puppet:///modules/site_apt/neurodebian.asc', - } + apt::key::plain { 'neurodebian.asc': + source => 'puppet:///modules/site_apt/neurodebian.asc', + } This deploys the key in the `${apt_base_dir}/keys` directory (as opposed to `$custom_key_dir` which deploys it in `keys.d`). The reason @@ -562,12 +566,12 @@ For example, the following upgrades the perl package to version 5.8.8-7etch1 (if it is installed), it also upgrades the syslog-ng and perl-modules packages to their latest (also, only if they are installed): -upgrade_package { 'perl': - version => '5.8.8-7etch1'; - 'syslog-ng': - version => latest; - 'perl-modules': -} + upgrade_package { 'perl': + version => '5.8.8-7etch1'; + 'syslog-ng': + version => latest; + 'perl-modules': + } # Resources @@ -593,7 +597,7 @@ Note that nodes can be updated once a day by using APT::Periodic::Update-Package-Lists "1"; -in i.e. /etc/apt/apt.conf.d/80_apt_update_daily. +in i.e. `/etc/apt/apt.conf.d/80_apt_update_daily`. # Tests -- cgit v1.2.3 From 3abd96bb653e16b229debafe0ac9aff8a0bcbdce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Wed, 27 Apr 2016 15:12:19 -0400 Subject: use the same code indenting (Puppet's code guideline one) everywhere to uniform --- README.md | 129 +++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 89 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 7151dd1..2aea453 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,11 @@ Ubuntu support is lagging behind but not absent either. 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 upgrades, but because this is a top-level facter variable, and newer puppet @@ -90,7 +94,11 @@ 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 @@ -104,7 +112,11 @@ Ubuntu support is lagging behind but not absent either. you will need to remove the variables, and the include and instead do the following: - class { 'apt::apticron': email => 'foo@example.com', notifynew => '1' } + class { + 'apt::apticron': + email => 'foo@example.com', + notifynew => '1'; + } * the `apt::listchanges` class has been moved to a paramterized class. if you were including this class before, after passing some variables, you will need @@ -118,7 +130,10 @@ Ubuntu support is lagging behind but not absent either. 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 were including this class before, after passing some variables, you will need @@ -132,7 +147,11 @@ Ubuntu support is lagging behind but not absent either. 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 @@ -175,9 +194,13 @@ that is not enabled by default, you must set one of the following parameters. Example usage: - class { 'apt': use_next_release => true, debian_url => 'http://localhost:9999/debian/' } + class { + 'apt': + use_next_release => true, + debian_url => 'http://localhost:9999/debian/'; + } -Class parameters: +**Class parameters:** ### use_lts @@ -245,7 +268,10 @@ Class parameters: Setting this variable to false before including this class will force the `apt/preferences` file to be absent: - class { 'apt': custom_preferences => false } + class { + 'apt': + custom_preferences => false; + } ### custom_sources_list @@ -257,7 +283,10 @@ Class parameters: For example, setting this variable will pull in the `templates/site_apt/sources.list` file: - class { 'apt': custom_sources_list => template('site_apt/sources.list') } + class { + 'apt': + custom_sources_list => template('site_apt/sources.list'); + } ### custom_key_dir @@ -289,7 +318,11 @@ defaults, which you are free to change: Example usage: - class { 'apt::apticron': email => 'foo@example.com', notifynew => '1' } + class { + 'apt::apticron': + email => 'foo@example.com', + notifynew => '1'; + } ## apt::cron::download @@ -374,7 +407,10 @@ the following parameterized variables, which can be changed: Example usage: - class { 'apt::listchanges': email => 'foo@example.com' } + class { + 'apt::listchanges': + email => 'foo@example.com'; + } ## apt::proxy_client @@ -388,7 +424,11 @@ change the port number by setting the `port` class parameter. Example usage: - class { 'apt::proxy_client': proxy => 'http://proxy.domain', port => '666' } + class { + 'apt::proxy_client': + proxy => 'http://proxy.domain', + port => '666'; + } ## apt::reboot_required_notify @@ -417,12 +457,11 @@ contents and thus makes the other parameters useless. Example usage: - class { 'apt::unattended_upgrades': - config_template => 'site_apt/50unattended-upgrades.jessie', - blacklisted_packages => [ - 'libc6', 'libc6-dev', 'libc6-i686', 'mysql-server', 'redmine', 'nodejs', - 'bird' - ], + class { + 'apt::unattended_upgrades': + config_template => 'site_apt/50unattended-upgrades.jessie', + blacklisted_packages => [ 'libc6', 'libc6-dev', 'libc6-i686', + 'mysql-server', 'redmine', 'nodejs', 'bird' ]; } @@ -437,8 +476,9 @@ meta-parameter to define content inline or with the help of a template. Example usage: - apt::apt_conf { '80download-only': - source => 'puppet:///modules/site_apt/80download-only', + apt::apt_conf { + '80download-only': + source => 'puppet:///modules/site_apt/80download-only'; } @@ -450,20 +490,20 @@ Example: apt::preferences_snippet { 'irssi-plugin-otr': - release => 'squeeze-backports', + release => 'squeeze-backports', priority => 999; } apt::preferences_snippet { 'unstable_fallback': - package => '*', - release => 'unstable', + package => '*', + release => 'unstable', priority => 1; } apt::preferences_snippet { 'ttdnsd': - pin => 'origin deb.torproject.org', + pin => 'origin deb.torproject.org', priority => 999; } @@ -492,8 +532,9 @@ following in your manifest: You can also specify the content of the seed via the content parameter, for example: - apt::preseeded_package { 'apticron': - content => 'apticron apticron/notification string root@example.com', + apt::preseeded_package { + 'apticron': + content => 'apticron apticron/notification string root@example.com'; } @@ -508,9 +549,10 @@ file name if not present in the resource name. Example usage: - apt::sources_list { 'company_internals': - source => [ "puppet:///modules/site_apt/${::fqdn}/company_internals.list", - 'puppet:///modules/site_apt/company_internals.list' ], + apt::sources_list { + 'company_internals': + source => [ "puppet:///modules/site_apt/${::fqdn}/company_internals.list", + 'puppet:///modules/site_apt/company_internals.list' ]; } @@ -520,9 +562,10 @@ Deploys a secure apt OpenPGP key. This usually accompanies the sources.list snippets above for third party repositories. For example, you would do: - apt::key { 'neurodebian.gpg': - ensure => present, - source => 'puppet:///modules/site_apt/neurodebian.gpg', + apt::key { + 'neurodebian.gpg': + ensure => present, + source => 'puppet:///modules/site_apt/neurodebian.gpg'; } This deploys the key in the `/etc/apt/trusted.gpg.d` directory, which @@ -539,8 +582,9 @@ Deploys a secure apt OpenPGP key. This usually accompanies the sources.list snippets above for third party repositories. For example, you would do: - apt::key::plain { 'neurodebian.asc': - source => 'puppet:///modules/site_apt/neurodebian.asc', + apt::key::plain { + 'neurodebian.asc': + source => 'puppet:///modules/site_apt/neurodebian.asc'; } This deploys the key in the `${apt_base_dir}/keys` directory (as @@ -566,11 +610,14 @@ For example, the following upgrades the perl package to version 5.8.8-7etch1 (if it is installed), it also upgrades the syslog-ng and perl-modules packages to their latest (also, only if they are installed): - upgrade_package { 'perl': - version => '5.8.8-7etch1'; - 'syslog-ng': - version => latest; - 'perl-modules': + upgrade_package { + 'perl': + version => '5.8.8-7etch1'; + + 'syslog-ng': + version => latest; + + 'perl-modules': } @@ -591,7 +638,9 @@ This resource is usually used like this to ensure current packages are installed by Package resources: include apt::update - Package { require => Exec['apt_updated'] } + Package { + require => Exec['apt_updated'] + } Note that nodes can be updated once a day by using -- cgit v1.2.3 From 770f8fb5dafa442bc018fa95fcab2fb60d817020 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sat, 3 Oct 2015 01:13:50 -0400 Subject: make backports_url follow debian_url by default backports_url was already set to the same value than debian_url by default, but it was set to the default value of debian_url. this meant that when giving a url to the debian_url parameter to the apt class, the backports_url would not follow and would still be using the default value for debian_url. with this change, when backports_url is not specified, but debian_url is, then both of them take on the value given to the debian_url. of course if backports_url is also given a value, then it keeps the value given by the user. --- manifests/init.pp | 9 +++++++-- manifests/params.pp | 5 +---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 4c44af2..9c186cc 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -35,6 +35,11 @@ class apt( } } + $real_backports_url = $backports_url ? { + false => $debian_url, + default => $backports_url, + } + package { 'apt': ensure => installed, require => undef, @@ -99,12 +104,12 @@ class apt( 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 ${real_backports_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 ${real_backports_url} ${::debian_codename}-backports ${apt::repos}", } } } diff --git a/manifests/params.pp b/manifests/params.pp index 28af06e..be7262d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -9,10 +9,7 @@ class apt::params () { $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, - } + default => false, } $lts_url = $debian_url $volatile_url = 'http://volatile.debian.org/debian-volatile/' -- cgit v1.2.3 From 0752201ce40e7bf4a9acdf642b455e1d97e8789f Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sat, 3 Oct 2015 01:18:07 -0400 Subject: push logic behind apt::repos back in apt::params The logic in specifying the default value for apt::repos is in the wrong place: it should be in apt::params since this is exactly what this latter class is for. There's no special case that can involve making default the value follow the value of another parameter so there's no point in having that logic in the main class. --- manifests/init.pp | 14 -------------- manifests/params.pp | 12 +++++++++++- templates/Debian/sources.list.erb | 2 +- templates/Ubuntu/sources.list.erb | 4 ++-- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9c186cc..46e5cb0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -20,20 +20,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, - } - } - } $real_backports_url = $backports_url ? { false => $debian_url, diff --git a/manifests/params.pp b/manifests/params.pp index be7262d..a70dac1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -13,7 +13,17 @@ class apt::params () { } $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/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 -%> -- cgit v1.2.3 From bb823a23f84e2fea55bf8b8c3eb47028d0378305 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Mon, 27 Jun 2016 23:47:14 +0200 Subject: extraneous space in subsection title --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2aea453..851f7aa 100644 --- a/README.md +++ b/README.md @@ -576,7 +576,7 @@ use `apt::key::plain`. The `.gpg` extension is compulsory for `apt` to pickup the key properly. -## apt:: key::plain +## apt::key::plain Deploys a secure apt OpenPGP key. This usually accompanies the sources.list snippets above for third party repositories. For example, -- cgit v1.2.3 From 5d95c3f5e7d0543d28792a96bb3cd927b265ec71 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Mon, 27 Jun 2016 23:47:43 +0200 Subject: README: make examples more compact also, use commas instead of semi-colon at the end of resources to use a coding style that makes things more extensible. --- README.md | 102 ++++++++++++++++++++++++++------------------------------------ 1 file changed, 43 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 851f7aa..5f6a109 100644 --- a/README.md +++ b/README.md @@ -194,10 +194,9 @@ that is not enabled by default, you must set one of the following parameters. Example usage: - class { - 'apt': - use_next_release => true, - debian_url => 'http://localhost:9999/debian/'; + class { 'apt': + use_next_release => true, + debian_url => 'http://localhost:9999/debian/', } **Class parameters:** @@ -268,9 +267,8 @@ Example usage: Setting this variable to false before including this class will force the `apt/preferences` file to be absent: - class { - 'apt': - custom_preferences => false; + class { 'apt': + custom_preferences => false, } ### custom_sources_list @@ -283,9 +281,8 @@ Example usage: For example, setting this variable will pull in the `templates/site_apt/sources.list` file: - class { - 'apt': - custom_sources_list => template('site_apt/sources.list'); + class { 'apt': + custom_sources_list => template('site_apt/sources.list'), } ### custom_key_dir @@ -318,10 +315,9 @@ defaults, which you are free to change: Example usage: - class { - 'apt::apticron': - email => 'foo@example.com', - notifynew => '1'; + class { 'apt::apticron': + email => 'foo@example.com', + notifynew => '1', } @@ -407,9 +403,8 @@ the following parameterized variables, which can be changed: Example usage: - class { - 'apt::listchanges': - email => 'foo@example.com'; + class { 'apt::listchanges': + email => 'foo@example.com', } @@ -424,10 +419,9 @@ change the port number by setting the `port` class parameter. Example usage: - class { - 'apt::proxy_client': - proxy => 'http://proxy.domain', - port => '666'; + class { 'apt::proxy_client': + proxy => 'http://proxy.domain', + port => '666', } @@ -457,11 +451,10 @@ contents and thus makes the other parameters useless. Example usage: - class { - 'apt::unattended_upgrades': - config_template => 'site_apt/50unattended-upgrades.jessie', - blacklisted_packages => [ 'libc6', 'libc6-dev', 'libc6-i686', - 'mysql-server', 'redmine', 'nodejs', 'bird' ]; + class { 'apt::unattended_upgrades': + config_template => 'site_apt/50unattended-upgrades.jessie', + blacklisted_packages => [ 'libc6', 'libc6-dev', 'libc6-i686', + 'mysql-server', 'redmine', 'nodejs', 'bird' ], } @@ -476,9 +469,8 @@ meta-parameter to define content inline or with the help of a template. Example usage: - apt::apt_conf { - '80download-only': - source => 'puppet:///modules/site_apt/80download-only'; + apt::apt_conf { '80download-only': + source => 'puppet:///modules/site_apt/80download-only', } @@ -486,25 +478,22 @@ Example usage: A way to add pinning information to files in `/etc/apt/preferences.d/` -Example: +Examples: - apt::preferences_snippet { - 'irssi-plugin-otr': - release => 'squeeze-backports', - priority => 999; + apt::preferences_snippet { 'irssi-plugin-otr': + release => 'squeeze-backports', + priority => 999, } - apt::preferences_snippet { - 'unstable_fallback': - package => '*', - release => 'unstable', - priority => 1; + apt::preferences_snippet { 'unstable_fallback': + package => '*', + release => 'unstable', + priority => 1, } - apt::preferences_snippet { - 'ttdnsd': - pin => 'origin deb.torproject.org', - priority => 999; + apt::preferences_snippet { 'ttdnsd': + pin => 'origin deb.torproject.org', + priority => 999, } The names of the resources will be used as the names of the files in the @@ -532,9 +521,8 @@ following in your manifest: You can also specify the content of the seed via the content parameter, for example: - apt::preseeded_package { - 'apticron': - content => 'apticron apticron/notification string root@example.com'; + apt::preseeded_package { 'apticron': + content => 'apticron apticron/notification string root@example.com', } @@ -549,10 +537,9 @@ file name if not present in the resource name. Example usage: - apt::sources_list { - 'company_internals': - source => [ "puppet:///modules/site_apt/${::fqdn}/company_internals.list", - 'puppet:///modules/site_apt/company_internals.list' ]; + apt::sources_list { 'company_internals': + source => [ "puppet:///modules/site_apt/${::fqdn}/company_internals.list", + 'puppet:///modules/site_apt/company_internals.list' ]; } @@ -582,9 +569,8 @@ Deploys a secure apt OpenPGP key. This usually accompanies the sources.list snippets above for third party repositories. For example, you would do: - apt::key::plain { - 'neurodebian.asc': - source => 'puppet:///modules/site_apt/neurodebian.asc'; + apt::key::plain { 'neurodebian.asc': + source => 'puppet:///modules/site_apt/neurodebian.asc'; } This deploys the key in the `${apt_base_dir}/keys` directory (as @@ -612,12 +598,10 @@ to their latest (also, only if they are installed): upgrade_package { 'perl': - version => '5.8.8-7etch1'; - - 'syslog-ng': - version => latest; - - 'perl-modules': + version => '5.8.8-7etch1'; + 'syslog-ng': + version => latest; + 'perl-modules': } -- cgit v1.2.3 From 8859eba152a5a504db9816b64fec6720f7ba5f14 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Wed, 29 Jun 2016 16:45:22 +0200 Subject: add an upgrade notice about the change of default value for $repos --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5f6a109..f6a0c4a 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,10 @@ Ubuntu support is lagging behind but not absent either. ## Upgrade Notice + * 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. -- cgit v1.2.3 From 2bbfe8cab9ba8125feb9f54865e3025bf4d355ee Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Wed, 29 Jun 2016 17:31:14 +0200 Subject: Fix some minor lint issues This was shown by the testing that was added in merge request !34 --- manifests/preseeded_package.pp | 5 ++++- manifests/sources_list.pp | 5 ++++- manifests/upgrade_package.pp | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) 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/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'] } -- cgit v1.2.3 From b8a461638eca77e2fdd82c6bf07784b0b44cc917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= Date: Wed, 29 Jun 2016 17:57:08 +0200 Subject: Always set debian_nextcodename to 'sid' on systems running testing, fixes #12 --- lib/facter/debian_nextcodename.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/facter/debian_nextcodename.rb b/lib/facter/debian_nextcodename.rb index c4c569b..654fe20 100644 --- a/lib/facter/debian_nextcodename.rb +++ b/lib/facter/debian_nextcodename.rb @@ -4,8 +4,10 @@ rescue LoadError require "#{File.dirname(__FILE__)}/util/debian" end -def debian_codename_to_next(codename) - if codename == "sid" +def debian_codename_to_next(codename, release) + if release == "testing" + return "sid" + elsif release == "unstable" return "experimental" else codenames = Facter::Util::Debian::CODENAMES @@ -18,6 +20,6 @@ end Facter.add(:debian_nextcodename) do confine :operatingsystem => 'Debian' setcode do - debian_codename_to_next(Facter.value('debian_codename')) + debian_codename_to_next(Facter.value('debian_codename'), Facter.value('debian_release')) end end -- cgit v1.2.3 From 5102b7863b09e58bdd712c9019885313270299ce Mon Sep 17 00:00:00 2001 From: intrigeri Date: Wed, 29 Jun 2016 15:49:22 +0000 Subject: Drop apt::cron::download, and turn $apt_cron_hours into a class parameter for apt::cron::dist_upgrade. I've introduced apt::cron::download, am not using it anymore, and have never seen anyone else submit a bug or a merge request for it. Thus, I feel pretty confident in dropping it. And this allows me to trivially get rid of the $apt_cron_hours global variable noticed by LeLutin in #13. --- README.md | 3 +++ manifests/cron/base.pp | 20 -------------------- manifests/cron/dist_upgrade.pp | 21 ++++++++++++++++++++- manifests/cron/download.pp | 27 --------------------------- 4 files changed, 23 insertions(+), 48 deletions(-) delete mode 100644 manifests/cron/base.pp delete mode 100644 manifests/cron/download.pp diff --git a/README.md b/README.md index f6a0c4a..7431038 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,9 @@ Ubuntu support is lagging behind but not absent either. ## Upgrade Notice + * 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. 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'; - } - -} -- cgit v1.2.3 From 0250f57b821619bba2cb25fdc16f90ac34cab2f0 Mon Sep 17 00:00:00 2001 From: Tech SOGEECOM Date: Wed, 29 Jun 2016 12:00:21 -0400 Subject: use the same style for all the examples --- README.md | 56 +++++++++++++------------------------------------------- 1 file changed, 13 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 41a9aeb..695a824 100644 --- a/README.md +++ b/README.md @@ -49,10 +49,6 @@ Ubuntu support is lagging behind but not absent either. ## Upgrade Notice - * 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. @@ -83,10 +79,9 @@ Ubuntu support is lagging behind but not absent either. 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 @@ -98,10 +93,9 @@ 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 @@ -116,8 +110,7 @@ Ubuntu support is lagging behind but not absent either. 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'; } @@ -134,9 +127,8 @@ Ubuntu support is lagging behind but not absent either. 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 @@ -151,10 +143,9 @@ Ubuntu support is lagging behind but not absent either. 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'; } @@ -644,33 +635,11 @@ 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 - -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 @@ -681,3 +650,4 @@ The GPL version 3 license text can be found in the "LICENSE" file accompanying this puppet module, or at the following URL: http://www.gnu.org/licenses/gpl-3.0.html + -- cgit v1.2.3 From eedc5eef88f19e83581742d305af82ae27a6fad5 Mon Sep 17 00:00:00 2001 From: Tech SOGEECOM Date: Wed, 29 Jun 2016 12:01:18 -0400 Subject: fix :key: in Gitlab markdown --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 695a824..6ad05de 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ * [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) @@ -558,7 +558,7 @@ use `apt::key::plain`. The `.gpg` extension is compulsory for `apt` to pickup the key properly. -## apt::key::plain +## `apt::key::plain` Deploys a secure apt OpenPGP key. This usually accompanies the sources.list snippets above for third party repositories. For example, -- cgit v1.2.3 From 195ed5d31bf5dabd5efe4460127002351499eac2 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Wed, 29 Jun 2016 17:39:14 +0000 Subject: apt::dist_upgrade: add a timeout parameter (#8). --- manifests/dist_upgrade.pp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/manifests/dist_upgrade.pp b/manifests/dist_upgrade.pp index 19c031e..e5475fc 100644 --- a/manifests/dist_upgrade.pp +++ b/manifests/dist_upgrade.pp @@ -1,8 +1,13 @@ -class apt::dist_upgrade { +# Parameters: +# - timeout: specified in seconds +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'] } -- cgit v1.2.3 From 419f9e460113d31e0d3d7c95ede5e41e7918d2bf Mon Sep 17 00:00:00 2001 From: Tech SOGEECOM Date: Wed, 29 Jun 2016 13:42:41 -0400 Subject: add back the parts of the README that were lost --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 6ad05de..940e533 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ * [File\['apt_config'\]](#fileapt_config) * [Exec\['apt_updated'\]](#execapt_updated) * [Tests](#tests) + * [Acceptance Tests](#acceptance-tests) * [Licensing](#licensing) @@ -49,6 +50,10 @@ Ubuntu support is lagging behind but not absent either. ## Upgrade Notice + * 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. @@ -635,11 +640,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 + +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 -- cgit v1.2.3 From 89a024678e39fec8a5c05371bcceaece605fbd88 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Wed, 29 Jun 2016 17:54:16 +0000 Subject: apt::reboot_required_notify::jessie: explicitly check that $apt::use_backports is true when running Jessie. Otherwise, it would fail anyway when trying to install reboot-notifier, but in a way less user-friendly. Thanks to lavamind for the suggestion! --- manifests/reboot_required_notify/jessie.pp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifests/reboot_required_notify/jessie.pp b/manifests/reboot_required_notify/jessie.pp index 9b5a0c0..2de6b62 100644 --- a/manifests/reboot_required_notify/jessie.pp +++ b/manifests/reboot_required_notify/jessie.pp @@ -1,5 +1,9 @@ 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, -- cgit v1.2.3 From 5a7336ad479ce98877b80f901863f253c0b74a1d Mon Sep 17 00:00:00 2001 From: Tech SOGEECOM Date: Wed, 29 Jun 2016 13:55:29 -0400 Subject: fix formatting errors --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 940e533..a77026f 100644 --- a/README.md +++ b/README.md @@ -642,7 +642,7 @@ To run pupept rspec tests: Verbose Output: - bundle exec rake spec SPEC_OPTS='--format documentation' + bundle exec rake spec SPEC_OPTS='--format documentation' Using different facter/puppet versions: @@ -657,15 +657,15 @@ Be sure to have a recent docker version installed. List configured nodesets: - bundle exec rake beaker_nodes + bundle exec rake beaker_nodes Run tests on default node (Debian Jessie): - bundle exec rake beaker + bundle exec rake beaker Run different nodeset: - BEAKER_set="debian-8-x86_64-docker" bundle exec rspec spec/acceptance/*_spec.rb + BEAKER_set="debian-8-x86_64-docker" bundle exec rspec spec/acceptance/*_spec.rb # Licensing @@ -677,4 +677,3 @@ The GPL version 3 license text can be found in the "LICENSE" file accompanying this puppet module, or at the following URL: http://www.gnu.org/licenses/gpl-3.0.html - -- cgit v1.2.3 From 05ca5b0a05d1ac38bb61d42f06b61a230060520f Mon Sep 17 00:00:00 2001 From: Tech SOGEECOM Date: Wed, 29 Jun 2016 13:59:51 -0400 Subject: ident the upgrade notices correctly --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a77026f..83a7ec9 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Ubuntu support is lagging behind but not absent either. ## Upgrade Notice - * The default value of the `$repos` parameter was removed since the logic is + * 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. @@ -77,8 +77,8 @@ 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 + $ 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 -- cgit v1.2.3 From 70118955f6dae59a021880865408cf9367c3dc57 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Wed, 29 Jun 2016 17:56:40 +0000 Subject: apt::reboot_required_notify: get rid of temporary variable. --- manifests/reboot_required_notify.pp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/manifests/reboot_required_notify.pp b/manifests/reboot_required_notify.pp index 82466d2..efd8aeb 100644 --- a/manifests/reboot_required_notify.pp +++ b/manifests/reboot_required_notify.pp @@ -1,13 +1,6 @@ class apt::reboot_required_notify { - $jessie_or_newer = $::operatingsystemmajrelease ? { - 5 => false, - 6 => false, - 7 => false, - default => true, - } - - if $jessie_or_newer { + 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 } -- cgit v1.2.3 From 8723519f0fec46fb39a99ae7c57581271e532322 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Wed, 29 Jun 2016 18:21:19 +0000 Subject: Fix newly introduced white-space issues. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 83a7ec9..41194e1 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,8 @@ Ubuntu support is lagging behind but not absent either. ## Upgrade Notice * 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. + 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 @@ -77,8 +77,8 @@ 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 + $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 -- cgit v1.2.3 From bc73809d7b33541b50ba9f38cb3bf1dd2237b98f Mon Sep 17 00:00:00 2001 From: intrigeri Date: Wed, 29 Jun 2016 18:21:30 +0000 Subject: Try to fix rendering of Markdown pre-formatted sections in bullet lists. --- README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 41194e1..c0d5f85 100644 --- a/README.md +++ b/README.md @@ -77,9 +77,9 @@ 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: @@ -107,10 +107,10 @@ Ubuntu support is lagging behind but not absent either. 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: @@ -125,9 +125,9 @@ 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: @@ -141,17 +141,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 -- cgit v1.2.3 From c439b8a524fc8f797e98b2c5351b028cf91ce237 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Wed, 29 Jun 2016 18:45:32 +0000 Subject: Remove documentation for apt::cron::download, and document the new parameter to apt::cron::dist_upgrade. --- README.md | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 2173d7e..2028e2a 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) @@ -324,30 +323,20 @@ Example usage: } -## apt::cron::download +## apt::cron::dist_upgrade -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 - -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 This class provides the `Exec['apt_dist-upgrade']` resource that -- cgit v1.2.3 From 13cb9fb48538fc7eed9b2f924aa4c84dd1434e3b Mon Sep 17 00:00:00 2001 From: intrigeri Date: Wed, 29 Jun 2016 18:49:23 +0000 Subject: Move documentation to README, and expand a bit on it. --- README.md | 5 +++++ manifests/dist_upgrade.pp | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c0d5f85..185efb0 100644 --- a/README.md +++ b/README.md @@ -356,6 +356,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 diff --git a/manifests/dist_upgrade.pp b/manifests/dist_upgrade.pp index e5475fc..3061fb8 100644 --- a/manifests/dist_upgrade.pp +++ b/manifests/dist_upgrade.pp @@ -1,5 +1,3 @@ -# Parameters: -# - timeout: specified in seconds class apt::dist_upgrade ( $timeout = 300, ) { -- cgit v1.2.3 From e876cd25b56b208b3a3b1bc1ce317338213cf45f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= Date: Wed, 29 Jun 2016 20:06:20 +0200 Subject: Remove redundant symlinks for the Debian listchanges template, fixes #2 --- manifests/listchanges.pp | 2 +- templates/Debian/listchanges.erb | 7 +++++++ templates/Debian/listchanges_jessie.erb | 1 - templates/Debian/listchanges_lenny.erb | 7 ------- templates/Debian/listchanges_sid.erb | 1 - templates/Debian/listchanges_squeeze.erb | 1 - templates/Debian/listchanges_wheezy.erb | 1 - 7 files changed, 8 insertions(+), 12 deletions(-) create mode 100644 templates/Debian/listchanges.erb delete mode 120000 templates/Debian/listchanges_jessie.erb delete mode 100644 templates/Debian/listchanges_lenny.erb delete mode 120000 templates/Debian/listchanges_sid.erb delete mode 120000 templates/Debian/listchanges_squeeze.erb delete mode 120000 templates/Debian/listchanges_wheezy.erb 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/templates/Debian/listchanges.erb b/templates/Debian/listchanges.erb new file mode 100644 index 0000000..1025dd0 --- /dev/null +++ b/templates/Debian/listchanges.erb @@ -0,0 +1,7 @@ +[apt] +frontend=<%= scope.lookupvar('apt::listchanges::frontend') %> +email_address=<%= scope.lookupvar('apt::listchanges::email') %> +confirm=<%= scope.lookupvar('apt::listchanges::confirm') %> +save_seen=<%= scope.lookupvar('apt::listchanges::saveseen') %> +which=<%= scope.lookupvar('apt::listchanges::which') %> + 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_lenny.erb b/templates/Debian/listchanges_lenny.erb deleted file mode 100644 index 1025dd0..0000000 --- a/templates/Debian/listchanges_lenny.erb +++ /dev/null @@ -1,7 +0,0 @@ -[apt] -frontend=<%= scope.lookupvar('apt::listchanges::frontend') %> -email_address=<%= scope.lookupvar('apt::listchanges::email') %> -confirm=<%= scope.lookupvar('apt::listchanges::confirm') %> -save_seen=<%= scope.lookupvar('apt::listchanges::saveseen') %> -which=<%= scope.lookupvar('apt::listchanges::which') %> - 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 -- cgit v1.2.3 From 6c0c1f4a1625d44e28fe6c150988be27c2bb4694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= Date: Wed, 29 Jun 2016 20:46:11 +0200 Subject: Remove redundant symlinks for the Debian apticron template, fixes #2 --- manifests/apticron.pp | 2 +- templates/Debian/apticron.erb | 80 ++++++++++++++++++++++++++++++++++ templates/Debian/apticron_jessie.erb | 1 - templates/Debian/apticron_sid.erb | 1 - templates/Debian/apticron_squeeze.erb | 82 ----------------------------------- templates/Debian/apticron_wheezy.erb | 80 ---------------------------------- 6 files changed, 81 insertions(+), 165 deletions(-) create mode 100644 templates/Debian/apticron.erb delete mode 120000 templates/Debian/apticron_jessie.erb delete mode 120000 templates/Debian/apticron_sid.erb delete mode 100644 templates/Debian/apticron_squeeze.erb delete mode 100644 templates/Debian/apticron_wheezy.erb 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/templates/Debian/apticron.erb b/templates/Debian/apticron.erb new file mode 100644 index 0000000..655854e --- /dev/null +++ b/templates/Debian/apticron.erb @@ -0,0 +1,80 @@ +# 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. +# If you want to use internal vars please use single quotes here. Ex: +# ='[apticron] : package update(s)' +# +# CUSTOM_SUBJECT="" +CUSTOM_SUBJECT="<%= scope.lookupvar('apt::apticron::customsubject') %>" 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_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/apticron_wheezy.erb b/templates/Debian/apticron_wheezy.erb deleted file mode 100644 index 655854e..0000000 --- a/templates/Debian/apticron_wheezy.erb +++ /dev/null @@ -1,80 +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. -# If you want to use internal vars please use single quotes here. Ex: -# ='[apticron] : package update(s)' -# -# CUSTOM_SUBJECT="" -CUSTOM_SUBJECT="<%= scope.lookupvar('apt::apticron::customsubject') %>" -- cgit v1.2.3 From 5fd6c96c4202b27dd3cea335a1bebdf7b7e717ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= Date: Wed, 29 Jun 2016 20:48:02 +0200 Subject: Fix missing quote in IPADDRESSES assignment in apticron config --- templates/Debian/apticron.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/Debian/apticron.erb b/templates/Debian/apticron.erb index 655854e..c6d3853 100644 --- a/templates/Debian/apticron.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 -%> # -- cgit v1.2.3 From 98b4be5570064e8f6a962b11a3f48dc7834241a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= Date: Wed, 29 Jun 2016 21:49:21 +0200 Subject: Drop Debian lenny and squeeze support. --- manifests/init.pp | 13 ++------- manifests/preferences.pp | 5 +--- templates/Debian/apticron_lenny.erb | 50 ---------------------------------- templates/Debian/preferences_lenny.erb | 25 ----------------- 4 files changed, 3 insertions(+), 90 deletions(-) delete mode 100644 templates/Debian/apticron_lenny.erb delete mode 100644 templates/Debian/preferences_lenny.erb diff --git a/manifests/init.pp b/manifests/init.pp index 46e5cb0..2ee4d10 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, @@ -21,11 +20,6 @@ class apt( $custom_key_dir = $apt::params::custom_key_dir ) inherits apt::params { - $real_backports_url = $backports_url ? { - false => $debian_url, - default => $backports_url, - } - package { 'apt': ensure => installed, require => undef, @@ -84,18 +78,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 ${real_backports_url} ${::debian_codename}-backports ${apt::repos}", + content => "deb ${debian_url} ${::debian_codename}-backports ${apt::repos}", } if $include_src { apt::sources_list { 'backports-src': - content => "deb-src ${real_backports_url} ${::debian_codename}-backports ${apt::repos}", + content => "deb-src ${debian_url} ${::debian_codename}-backports ${apt::repos}", } } } 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/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/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 - -- cgit v1.2.3 From f86963aab144e6da9e2d6405991e7f72bde801a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= Date: Thu, 30 Jun 2016 21:17:49 +0200 Subject: Remove references to backports_url parameter and squeeze from README. --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c0d5f85..3d094c3 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,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 +212,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 +234,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 @@ -481,7 +481,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, } -- cgit v1.2.3 From e55da5b7b803d34efc28c3c019269ff57958e7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= Date: Thu, 30 Jun 2016 21:19:01 +0200 Subject: Remove backports_url parameter. For jessie and later releases, backports use debian_url. --- manifests/params.pp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index a70dac1..2b18eb5 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -7,10 +7,6 @@ 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 => false, - } $lts_url = $debian_url $volatile_url = 'http://volatile.debian.org/debian-volatile/' case $::operatingsystem { -- cgit v1.2.3 From 78e07815bc860bca849b1a1f2a78dc4cbd794c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= Date: Thu, 30 Jun 2016 21:20:05 +0200 Subject: Remove squeeze special-case from unattended-upgrades template. --- templates/50unattended-upgrades.erb | 4 ---- 1 file changed, 4 deletions(-) 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"; -- cgit v1.2.3 From 328a6215a3a7728b39bbebc6a85d6371a23b9301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= Date: Thu, 30 Jun 2016 21:20:51 +0200 Subject: Take out comment referencing squeeze, see issue #14 --- manifests/init.pp | 2 -- 1 file changed, 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 2ee4d10..4bf126c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -67,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 } } -- cgit v1.2.3 From 9cd565f00ae8f6e10ad96c7c8ab2aa65d8fabe8a Mon Sep 17 00:00:00 2001 From: varac Date: Mon, 31 Oct 2016 13:46:05 +0100 Subject: Fix CI, dont install beaker on gitlab CI - Don't install `system-tests` gem group for rspec tests on CI - Use leapcode/ruby docker image because it has a more default ruby installation than the 'official' one. - Use `/var/cache/gitlab-runner/` as gem install path so we can cache this folder later --- .gitlab-ci.yml | 5 +++-- Gemfile | 16 +++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f7b8eca..2f381cd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,8 @@ +image: leapcode/ruby before_script: - ruby -v - - gem install bundler --no-ri --no-rdoc - - bundle install --jobs $(nproc) "${FLAGS[@]}" + - sudo gem install bundler --no-ri --no-rdoc + - sudo bundle install --jobs $(nproc) --without system_tests --path=/var/cache/gitlab-runner/ "${FLAGS[@]}" # don't fail on lint warnings rspec: diff --git a/Gemfile b/Gemfile index a2756c4..7ef1ec3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,8 @@ source "https://rubygems.org" -group :test do +group :development, :unit_tests do gem "rake" gem "rspec", '< 3.2.0' - gem "puppet", ENV['PUPPET_VERSION'] || ENV['GEM_PUPPET_VERSION'] || ENV['PUPPET_GEM_VERSION'] || '~> 3.7.0' - gem "facter", ENV['FACTER_VERSION'] || ENV['GEM_FACTER_VERSION'] || ENV['FACTER_GEM_VERSION'] || '~> 2.2.0' gem "rspec-puppet" gem "puppetlabs_spec_helper" gem "metadata-json-lint" @@ -13,8 +11,12 @@ group :test do end group :system_tests do - gem 'beaker', :require => false - gem 'beaker-rspec', :require => false - gem 'beaker_spec_helper', :require => false - gem 'serverspec', :require => false + gem 'beaker' + gem 'beaker-rspec' + gem 'beaker_spec_helper' + gem 'serverspec' end + +gem "puppet", ENV['PUPPET_VERSION'] || ENV['GEM_PUPPET_VERSION'] || ENV['PUPPET_GEM_VERSION'] || '~> 3.7.0' +gem "facter", ENV['FACTER_VERSION'] || ENV['GEM_FACTER_VERSION'] || ENV['FACTER_GEM_VERSION'] || '~> 2.2.0' + -- cgit v1.2.3 From aeb3bdba1c66f245e9eda46a564a956252cc609b Mon Sep 17 00:00:00 2001 From: varac Date: Wed, 2 Nov 2016 21:26:14 +0100 Subject: Compile test, test apt::conf --- spec/classes/init_spec.rb | 16 +++++++++++ spec/defines/conf_spec.rb | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 spec/classes/init_spec.rb create mode 100644 spec/defines/conf_spec.rb diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb new file mode 100644 index 0000000..dfb7521 --- /dev/null +++ b/spec/classes/init_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe 'apt', :type => :class do + let :pre_condition do + 'class { "apt": }' + end + let(:facts) { { + :lsbdistid => 'Debian', + :osfamily => 'Debian', + :operatingsystem => 'Debian', + :debian_release => 'jessie', + :lsbdistcodename => 'jessie', + :puppetversion => Puppet.version, } } + #it { is_expected.to compile.with_all_deps } + it { is_expected.to compile } +end diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb new file mode 100644 index 0000000..59f49df --- /dev/null +++ b/spec/defines/conf_spec.rb @@ -0,0 +1,72 @@ +require 'spec_helper' +describe 'apt::apt_conf', :type => :define do + let :pre_condition do + 'class { "apt": }' + end + let(:facts) { { + :lsbdistid => 'Debian', + :osfamily => 'Debian', + :operatingsystem => 'Debian', + :debian_release => 'jessie', + :lsbdistcodename => 'jessie', + :puppetversion => Puppet.version, } } + let :title do + 'norecommends' + end + + describe "when creating an apt_conf snippet" do + let :default_params do + { + :ensure => 'present', + :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" + } + end + let :params do + default_params + end + let :filename do + "/etc/apt/apt.conf.d/norecommends" + end + + it { is_expected.to contain_file(filename).with({ + 'ensure' => 'present', + 'content' => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/, + 'owner' => 'root', + # default to '0', not 'root' + #'group' => 'root', + 'mode' => '0644', + }) + } + + end + + describe "when creating a preference without content" do + let :params do + { + :ensure => 'absent', + } + end + + it 'fails' do + expect { subject.call } .to raise_error(Puppet::Error, /One of \$source or \$content must be specified for apt_conf norecommends/) + end + end + + describe "when removing an apt preference" do + let :params do + { + :ensure => 'absent', + :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n", + } + end + + let :filename do + "/etc/apt/apt.conf.d/norecommends" + end + + it { is_expected.to contain_file(filename).with({ + 'ensure' => 'absent', + }) + } + end +end -- cgit v1.2.3 From 92e6aab93e081281d25ff69bdceb779943038b24 Mon Sep 17 00:00:00 2001 From: varac Date: Wed, 2 Nov 2016 22:47:30 +0100 Subject: Improve tests setup - Add .fixtures.yaml to checkout common module - Use puppetlabs-spec-helper in spec_helper.rb --- .fixtures.yml | 6 ++++++ Gemfile | 4 ++-- spec/spec_helper.rb | 12 ++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 .fixtures.yml diff --git a/.fixtures.yml b/.fixtures.yml new file mode 100644 index 0000000..99efd66 --- /dev/null +++ b/.fixtures.yml @@ -0,0 +1,6 @@ +fixtures: + repositories: + "common": + "repo": "https://gitlab.com/shared-puppet-modules-group/common.git" + symlinks: + "apt": "#{source_dir}" diff --git a/Gemfile b/Gemfile index 7ef1ec3..44630f4 100644 --- a/Gemfile +++ b/Gemfile @@ -2,8 +2,8 @@ source "https://rubygems.org" group :development, :unit_tests do gem "rake" - gem "rspec", '< 3.2.0' - gem "rspec-puppet" + gem "rspec-puppet", "~> 2.1", :require => false + gem "rspec-core", "3.1.7", :require => false gem "puppetlabs_spec_helper" gem "metadata-json-lint" gem "rspec-puppet-facts" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 21d1a98..3cca63a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,12 +1,12 @@ # https://puppetlabs.com/blog/testing-modules-in-the-puppet-forge -require 'rspec-puppet' -require 'mocha/api' +require 'puppetlabs_spec_helper/module_spec_helper' -RSpec.configure do |c| +fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) - c.module_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')) - c.color = true +RSpec.configure do |c| - #Puppet.features.stubs(:root? => true) + c.manifest_dir = File.join(fixture_path, 'manifests') + c.module_path = File.join(fixture_path, 'modules') + c.color = true end -- cgit v1.2.3 From 1c0278c9cece0414c8d1a64b67827d85aabf03c0 Mon Sep 17 00:00:00 2001 From: varac Date: Wed, 2 Nov 2016 23:33:35 +0100 Subject: Test multiple puppet versions --- .gitlab-ci.yml | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2f381cd..49bf2e3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,42 @@ image: leapcode/ruby before_script: - - ruby -v - - sudo gem install bundler --no-ri --no-rdoc - - sudo bundle install --jobs $(nproc) --without system_tests --path=/var/cache/gitlab-runner/ "${FLAGS[@]}" + - "[ -d /var/cache/gitlab-runner ] || sudo mkdir /var/cache/gitlab-runner" + - sudo chown cirunner:cirunner -R /var/cache/gitlab-runner + - bundle install --jobs $(nproc) --without system_tests --path=/var/cache/gitlab-runner/ "${FLAGS[@]}" -# don't fail on lint warnings -rspec: +.job_template: &job_definition script: + # don't fail on lint warnings - bundle exec rake lint || /bin/true - bundle exec rake syntax - bundle exec rake validate - bundle exec rake spec + +# Default debian jessie versions +test:puppet37: + variables: + PUPPET_VERSION: "~> 3.7.2" + FACTER_VERSION: '~> 2.2.0' + <<: *job_definition + +test:puppet38_future_parser: + variables: + PUPPET_VERSION: '~> 3.8' + FACTER_VERSION: '~> 2.2.0' + FUTURE_PARSER: 'yes' + <<: *job_definition + +# Default debia stretch versions +test:puppet45: + variables: + PUPPET_VERSION: "~> 4.5.2" + FACTER_VERSION: '~> 2.4.6' + <<: *job_definition + +# Latest greatest +test:puppet4x: + variables: + PUPPET_VERSION: "> 4" + FACTER_VERSION: '> 2' + <<: *job_definition + -- cgit v1.2.3 From 4b25160f36f7bda61e4b7da9cc21d9005aec0485 Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 3 Nov 2016 00:33:38 +0100 Subject: Add more facts --- spec/classes/init_spec.rb | 2 ++ spec/defines/conf_spec.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index dfb7521..9ba554f 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -9,7 +9,9 @@ describe 'apt', :type => :class do :osfamily => 'Debian', :operatingsystem => 'Debian', :debian_release => 'jessie', + :debian_codename => 'jessie', :lsbdistcodename => 'jessie', + :virtual => 'physical', :puppetversion => Puppet.version, } } #it { is_expected.to compile.with_all_deps } it { is_expected.to compile } diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 59f49df..cc4fb1f 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -8,7 +8,9 @@ describe 'apt::apt_conf', :type => :define do :osfamily => 'Debian', :operatingsystem => 'Debian', :debian_release => 'jessie', + :debian_codename => 'jessie', :lsbdistcodename => 'jessie', + :virtual => 'physical', :puppetversion => Puppet.version, } } let :title do 'norecommends' -- cgit v1.2.3 From 83c7034b8925d73a2c8157e2841ccf66c0ae23a7 Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 3 Nov 2016 00:34:17 +0100 Subject: Ignore spec/fixtures --- .gitignore | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3b626b8..ad8ff1f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,7 @@ /pkg/ /Gemfile.lock /vendor/ -/spec/fixtures/manifests/* -/spec/fixtures/modules/* -!/spec/fixtures/modules/apt -!/spec/fixtures/modules/apt/* +/spec/fixtures /log /.vagrant/ /.bundle/ -- cgit v1.2.3 From 6baa09d71eac070cbe2bd71afb27064bef7c809d Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 3 Nov 2016 00:09:25 +0100 Subject: Scope defines of apt_conf --- manifests/init.pp | 6 +++--- manifests/proxy_client.pp | 2 +- manifests/unattended_upgrades.pp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 4bf126c..3d93d22 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -40,14 +40,14 @@ class apt( mode => '0644'; } - apt_conf { '02show_upgraded': + ::apt::apt_conf { '02show_upgraded': source => [ "puppet:///modules/site_apt/${::fqdn}/02show_upgraded", 'puppet:///modules/site_apt/02show_upgraded', 'puppet:///modules/apt/02show_upgraded' ] } if ( $::virtual == 'vserver' ) { - apt_conf { '03clean_vserver': + ::apt::apt_conf { '03clean_vserver': source => [ "puppet:///modules/site_apt/${::fqdn}/03clean_vserver", 'puppet:///modules/site_apt/03clean_vserver', 'puppet:///modules/apt/03clean_vserver' ], @@ -55,7 +55,7 @@ class apt( } } else { - apt_conf { '03clean': + ::apt::apt_conf { '03clean': source => [ "puppet:///modules/site_apt/${::fqdn}/03clean", 'puppet:///modules/site_apt/03clean', 'puppet:///modules/apt/03clean' ] diff --git a/manifests/proxy_client.pp b/manifests/proxy_client.pp index 9ba79f2..e7972f7 100644 --- a/manifests/proxy_client.pp +++ b/manifests/proxy_client.pp @@ -3,7 +3,7 @@ class apt::proxy_client( $port = '3142', ){ - apt_conf { '20proxy': + ::apt::apt_conf { '20proxy': content => template('apt/20proxy.erb'), } } diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index 52d7542..d604125 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -26,7 +26,7 @@ class apt::unattended_upgrades ( default => $config_content } - apt_conf { '50unattended-upgrades': + ::apt::apt_conf { '50unattended-upgrades': content => $file_content, require => Package['unattended-upgrades'], refresh_apt => false -- cgit v1.2.3 From 04c73a73d46ccea8df6cce145ed6a516d2150d3a Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 3 Nov 2016 00:45:34 +0100 Subject: Use undef as default for source parameter --- manifests/apt_conf.pp | 6 +++--- manifests/sources_list.pp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/manifests/apt_conf.pp b/manifests/apt_conf.pp index 949f615..fa8cfa3 100644 --- a/manifests/apt_conf.pp +++ b/manifests/apt_conf.pp @@ -1,15 +1,15 @@ define apt::apt_conf( $ensure = 'present', - $source = '', + $source = undef, $content = undef, $refresh_apt = true ) { - if $source == '' and $content == undef { + if $source == undef and $content == undef { fail("One of \$source or \$content must be specified for apt_conf ${name}") } - if $source != '' and $content != undef { + if $source != undef and $content != undef { fail("Only one of \$source or \$content must specified for apt_conf ${name}") } diff --git a/manifests/sources_list.pp b/manifests/sources_list.pp index 7565bce..6ff4fc3 100644 --- a/manifests/sources_list.pp +++ b/manifests/sources_list.pp @@ -1,15 +1,15 @@ # Configure an apt source define apt::sources_list ( - $ensure = 'present', - $source = '', + $ensure = 'present', + $source = undef, $content = undef ) { if $ensure == 'present' { - if $source == '' and $content == undef { + if $source == undef and $content == undef { fail("One of \$source or \$content must be specified for apt_sources_snippet ${name}") } - if $source != '' and $content != undef { + if $source != undef and $content != undef { fail("Only one of \$source or \$content must specified for apt_sources_snippet ${name}") } } -- cgit v1.2.3 From b86b0feb7e98c96317946c67c81c669696290d8f Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 3 Nov 2016 01:15:25 +0100 Subject: Test for compile.with_all_deps --- spec/classes/init_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 9ba554f..5a65fc9 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -13,6 +13,5 @@ describe 'apt', :type => :class do :lsbdistcodename => 'jessie', :virtual => 'physical', :puppetversion => Puppet.version, } } - #it { is_expected.to compile.with_all_deps } - it { is_expected.to compile } + it { is_expected.to compile.with_all_deps } end -- cgit v1.2.3 From 92f7340f30ddee7cedd6c70827c763189478de74 Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 3 Nov 2016 15:30:46 +0100 Subject: Do a simple compile test for now --- spec/classes/init_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 5a65fc9..9ba554f 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -13,5 +13,6 @@ describe 'apt', :type => :class do :lsbdistcodename => 'jessie', :virtual => 'physical', :puppetversion => Puppet.version, } } - it { is_expected.to compile.with_all_deps } + #it { is_expected.to compile.with_all_deps } + it { is_expected.to compile } end -- cgit v1.2.3 From c7581a1f0e2b64b186a2d7c37e7ba0a9fa2cc1df Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 3 Nov 2016 15:54:46 +0100 Subject: Fix preferences_snippet.pp for puppet 4 --- manifests/preferences_snippet.pp | 10 ++--- spec/defines/preferences_snippet_spec.rb | 66 ++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 spec/defines/preferences_snippet_spec.rb diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp index b7dba0d..2b2fb74 100644 --- a/manifests/preferences_snippet.pp +++ b/manifests/preferences_snippet.pp @@ -2,9 +2,9 @@ define apt::preferences_snippet ( $priority = undef, $package = false, $ensure = 'present', - $source = '', - $release = '', - $pin = '' + $source = undef, + $release = undef, + $pin = undef ) { $real_package = $package ? { @@ -36,9 +36,9 @@ define apt::preferences_snippet ( } case $source { - '': { + undef: { case $release { - '': { + undef: { File["/etc/apt/preferences.d/${name}"]{ content => template('apt/preferences_snippet.erb') } diff --git a/spec/defines/preferences_snippet_spec.rb b/spec/defines/preferences_snippet_spec.rb new file mode 100644 index 0000000..012a5f6 --- /dev/null +++ b/spec/defines/preferences_snippet_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper' +describe 'apt::preferences_snippet', :type => :define do + let :pre_condition do + 'class { "apt": }' + end + let(:facts) { { + :lsbdistid => 'Debian', + :osfamily => 'Debian', + :operatingsystem => 'Debian', + :debian_release => 'jessie', + :debian_codename => 'jessie', + :lsbdistcodename => 'jessie', + :virtual => 'physical', + :puppetversion => Puppet.version, } } + let :title do + 'test' + end + + describe "when creating a preferences_snippet" do + let :default_params do + { + :ensure => 'present', + :release => "jessie-backports", + :priority => '999' + } + end + let :params do + default_params + end + let :filename do + "/etc/apt/preferences.d/test" + end + + it { is_expected.to contain_file(filename).with({ + 'ensure' => 'present', + 'content' => /Package: test\nPin: release a=jessie-backports\nPin-Priority: 999/, + 'owner' => 'root', + 'group' => '0', + 'mode' => '0644', + }) + } + + end + + describe "when using both pin and release parameters" do + let :default_params do + { + :ensure => 'present', + :priority => '999', + :release => "jessie-backports", + :pin => '1.0' + } + end + let :params do + default_params + end + let :filename do + "/etc/apt/preferences.d/test" + end + + it 'fails' do + expect { subject.call } .to raise_error(Puppet::Error, /apt::preferences_snippet requires either a 'pin' or 'release' argument, not both/) + end + end + +end -- cgit v1.2.3