From 2ecc85819566ed2ce6d6894a71fff32b416d8fb9 Mon Sep 17 00:00:00 2001 From: Tech SOGEECOM Date: Thu, 22 Sep 2016 15:13:47 -0400 Subject: fix issue #15 --- manifests/reboot_required_notify/jessie.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/reboot_required_notify/jessie.pp b/manifests/reboot_required_notify/jessie.pp index 2de6b62..6aac2b7 100644 --- a/manifests/reboot_required_notify/jessie.pp +++ b/manifests/reboot_required_notify/jessie.pp @@ -1,4 +1,4 @@ -class apt::reboot_required_notify::jessie ($ensure = present) { +class apt::reboot_required_notify::jessie ($ensure = present) inherits apt{ if $::operatingsystemmajrelease == 8 and ! $::apt::use_backports { fail('apt::reboot_required_notify requires $apt::use_backports on Jessie') -- cgit v1.2.3 From e57b37aa884713b6ff6273235ca002ae438cfb4f Mon Sep 17 00:00:00 2001 From: Tech SOGEECOM Date: Thu, 22 Sep 2016 15:56:02 -0400 Subject: fix missing whitespace --- manifests/reboot_required_notify/jessie.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/reboot_required_notify/jessie.pp b/manifests/reboot_required_notify/jessie.pp index 6aac2b7..0dd6a18 100644 --- a/manifests/reboot_required_notify/jessie.pp +++ b/manifests/reboot_required_notify/jessie.pp @@ -1,4 +1,4 @@ -class apt::reboot_required_notify::jessie ($ensure = present) inherits apt{ +class apt::reboot_required_notify::jessie ($ensure = present) inherits apt { if $::operatingsystemmajrelease == 8 and ! $::apt::use_backports { fail('apt::reboot_required_notify requires $apt::use_backports on Jessie') -- cgit v1.2.3 From 20c90d2dc61c2b1d15bebc88c839e90ef99e4b2e Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sat, 29 Oct 2016 08:15:38 +0000 Subject: Add debian_codename_to_version parser function. I need it to make libvirt::host::di_netboot_assistant::distribution use debian-installer-*-netboot-* packages without breaking backwards compatibility. refs: https://labs.riseup.net/code/issues/10092 --- .../parser/functions/debian_codename_to_version.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lib/puppet/parser/functions/debian_codename_to_version.rb diff --git a/lib/puppet/parser/functions/debian_codename_to_version.rb b/lib/puppet/parser/functions/debian_codename_to_version.rb new file mode 100644 index 0000000..c5cbcf4 --- /dev/null +++ b/lib/puppet/parser/functions/debian_codename_to_version.rb @@ -0,0 +1,18 @@ +begin + require 'facter/util/debian' +rescue LoadError + require "#{File.dirname(__FILE__)}/../../../facter/util/debian" +end + +module Puppet::Parser::Functions + versions = Facter::Util::Debian::CODENAMES.invert + newfunction(:debian_codename_to_version, :type => :rvalue) do |args| + codename = args[0] + if versions.has_key? codename + return versions[codename].to_i + else + raise Puppet::ParseError, + "Could not determine release from codename #{codename}" + end + end +end -- cgit v1.2.3 From 9493b62187b814e872eb27f4a6a18c53b5076906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Thu, 22 Dec 2016 21:25:13 -0500 Subject: indent packages correctly --- manifests/apticron.pp | 4 +++- manifests/cron/dist_upgrade.pp | 8 ++++++-- manifests/dselect.pp | 4 +++- manifests/init.pp | 4 +++- manifests/listchanges.pp | 4 +++- manifests/unattended_upgrades.pp | 2 +- manifests/upgrade_package.pp | 2 -- 7 files changed, 19 insertions(+), 9 deletions(-) diff --git a/manifests/apticron.pp b/manifests/apticron.pp index 89709a8..73ada70 100644 --- a/manifests/apticron.pp +++ b/manifests/apticron.pp @@ -12,7 +12,9 @@ class apt::apticron( $customsubject = '' ) { - package { 'apticron': ensure => $ensure_version } + package { 'apticron': + ensure => $ensure_version + } file { '/etc/apticron/apticron.conf': content => template($apt::apticron::config), diff --git a/manifests/cron/dist_upgrade.pp b/manifests/cron/dist_upgrade.pp index e1a03ed..d3d3be3 100644 --- a/manifests/cron/dist_upgrade.pp +++ b/manifests/cron/dist_upgrade.pp @@ -2,7 +2,9 @@ class apt::cron::dist_upgrade ( $cron_hours = '', ) { - package { 'cron-apt': ensure => installed } + package { 'cron-apt': + ensure => installed + } case $cron_hours { '': {} @@ -27,7 +29,9 @@ dist-upgrade -y -o APT::Get::Show-Upgraded=true -o 'DPkg::Options::=--force-conf ensure => absent, } - package { 'apt-listbugs': ensure => absent } + package { 'apt-listbugs': + ensure => absent + } file { '/etc/cron-apt/action.d/4-dist-upgrade': content => $action, diff --git a/manifests/dselect.pp b/manifests/dselect.pp index 2b99a43..da00c96 100644 --- a/manifests/dselect.pp +++ b/manifests/dselect.pp @@ -7,5 +7,7 @@ class apt::dselect { line => 'expert', } - package { 'dselect': ensure => installed } + package { 'dselect': + ensure => installed + } } diff --git a/manifests/init.pp b/manifests/init.pp index 3d93d22..30782e4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -74,7 +74,9 @@ class apt( include apt::dot_d_directories ## This package should really always be current - package { 'debian-archive-keyring': ensure => latest } + package { 'debian-archive-keyring': + ensure => latest + } if ($use_backports and !($::debian_release in ['testing', 'unstable', 'experimental'])) { apt::sources_list { diff --git a/manifests/listchanges.pp b/manifests/listchanges.pp index ecbbe6d..2c5641a 100644 --- a/manifests/listchanges.pp +++ b/manifests/listchanges.pp @@ -7,7 +7,9 @@ class apt::listchanges( $saveseen = '/var/lib/apt/listchanges.db', $which = 'both' ){ - package { 'apt-listchanges': ensure => $ensure_version } + package { 'apt-listchanges': + ensure => $ensure_version + } file { '/etc/apt/listchanges.conf': content => template($apt::listchanges::config), diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index d604125..dff911d 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -8,7 +8,7 @@ class apt::unattended_upgrades ( ) { package { 'unattended-upgrades': - ensure => $ensure_version + ensure => $ensure_version, } # For some reason, this directory is sometimes absent, which causes diff --git a/manifests/upgrade_package.pp b/manifests/upgrade_package.pp index e61b15d..73eb48b 100644 --- a/manifests/upgrade_package.pp +++ b/manifests/upgrade_package.pp @@ -13,14 +13,12 @@ define apt::upgrade_package ( if !defined(Package['apt-show-versions']) { package { 'apt-show-versions': ensure => installed, - require => undef, } } if !defined(Package['dctrl-tools']) { package { 'dctrl-tools': ensure => installed, - require => undef, } } -- cgit v1.2.3 From ef6036e879f894697a03459501a994af930dc4f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Thu, 22 Dec 2016 21:37:05 -0500 Subject: harmonize variable alignment --- manifests/apt_conf.pp | 12 ++++++------ manifests/apticron.pp | 22 +++++++++++----------- manifests/dist_upgrade/initiator.pp | 2 +- manifests/init.pp | 28 ++++++++++++++-------------- manifests/listchanges.pp | 15 ++++++++------- manifests/params.pp | 18 +++++++++--------- manifests/preferences_snippet.pp | 10 +++++----- manifests/preseeded_package.pp | 6 ++++-- manifests/proxy_client.pp | 6 +++--- manifests/sources_list.pp | 2 +- manifests/unattended_upgrades.pp | 10 +++++----- manifests/upgrade_package.pp | 2 +- 12 files changed, 68 insertions(+), 65 deletions(-) diff --git a/manifests/apt_conf.pp b/manifests/apt_conf.pp index fa8cfa3..ec6da6d 100644 --- a/manifests/apt_conf.pp +++ b/manifests/apt_conf.pp @@ -1,9 +1,9 @@ -define apt::apt_conf( - $ensure = 'present', - $source = undef, - $content = undef, - $refresh_apt = true ) -{ +define apt::apt_conf ( + $ensure = 'present', + $source = undef, + $content = undef, + $refresh_apt = true, +) { if $source == undef and $content == undef { fail("One of \$source or \$content must be specified for apt_conf ${name}") diff --git a/manifests/apticron.pp b/manifests/apticron.pp index 73ada70..a8a24be 100644 --- a/manifests/apticron.pp +++ b/manifests/apticron.pp @@ -1,15 +1,15 @@ -class apt::apticron( - $ensure_version = 'installed', - $config = "apt/${::operatingsystem}/apticron.erb", - $email = 'root', - $diff_only = '1', +class apt::apticron ( + $ensure_version = 'installed', + $config = "apt/${::operatingsystem}/apticron.erb", + $email = 'root', + $diff_only = '1', $listchanges_profile = 'apticron', - $system = false, - $ipaddressnum = false, - $ipaddresses = false, - $notifyholds = '0', - $notifynew = '0', - $customsubject = '' + $system = false, + $ipaddressnum = false, + $ipaddresses = false, + $notifyholds = '0', + $notifynew = '0', + $customsubject = '', ) { package { 'apticron': diff --git a/manifests/dist_upgrade/initiator.pp b/manifests/dist_upgrade/initiator.pp index d238988..eae5492 100644 --- a/manifests/dist_upgrade/initiator.pp +++ b/manifests/dist_upgrade/initiator.pp @@ -1,6 +1,6 @@ class apt::dist_upgrade::initiator inherits apt::dist_upgrade { - $initiator = 'upgrade_initiator' + $initiator = 'upgrade_initiator' $initiator_abs = "${apt::apt_base_dir}/${initiator}" file { 'apt_upgrade_initiator': diff --git a/manifests/init.pp b/manifests/init.pp index 30782e4..f7ef2e4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,21 +3,21 @@ # Copyright (C) 2007 David Schmitt # See LICENSE for the full license granted to you. -class apt( - $use_lts = $apt::params::use_lts, - $use_volatile = $apt::params::use_volatile, - $use_backports = $apt::params::use_backports, - $include_src = $apt::params::include_src, - $use_next_release = $apt::params::use_next_release, - $debian_url = $apt::params::debian_url, - $security_url = $apt::params::security_url, - $lts_url = $apt::params::lts_url, - $volatile_url = $apt::params::volatile_url, - $ubuntu_url = $apt::params::ubuntu_url, - $repos = $apt::params::repos, - $custom_preferences = $apt::params::custom_preferences, +class apt ( + $use_lts = $apt::params::use_lts, + $use_volatile = $apt::params::use_volatile, + $use_backports = $apt::params::use_backports, + $include_src = $apt::params::include_src, + $use_next_release = $apt::params::use_next_release, + $debian_url = $apt::params::debian_url, + $security_url = $apt::params::security_url, + $lts_url = $apt::params::lts_url, + $volatile_url = $apt::params::volatile_url, + $ubuntu_url = $apt::params::ubuntu_url, + $repos = $apt::params::repos, + $custom_preferences = $apt::params::custom_preferences, $custom_sources_list = '', - $custom_key_dir = $apt::params::custom_key_dir + $custom_key_dir = $apt::params::custom_key_dir, ) inherits apt::params { package { 'apt': diff --git a/manifests/listchanges.pp b/manifests/listchanges.pp index 2c5641a..642986b 100644 --- a/manifests/listchanges.pp +++ b/manifests/listchanges.pp @@ -1,12 +1,13 @@ -class apt::listchanges( +class apt::listchanges ( $ensure_version = 'installed', - $config = "apt/${::operatingsystem}/listchanges.erb", - $frontend = 'mail', - $email = 'root', - $confirm = '0', - $saveseen = '/var/lib/apt/listchanges.db', - $which = 'both' + $config = "apt/${::operatingsystem}/listchanges.erb", + $frontend = 'mail', + $email = 'root', + $confirm = '0', + $saveseen = '/var/lib/apt/listchanges.db', + $which = 'both', ){ + package { 'apt-listchanges': ensure => $ensure_version } diff --git a/manifests/params.pp b/manifests/params.pp index 2b18eb5..463cd63 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,14 +1,14 @@ class apt::params () { - $use_lts = false - $use_volatile = false - $use_backports = true - $include_src = false + $use_lts = false + $use_volatile = false + $use_backports = true + $include_src = false $use_next_release = false - $debian_url = 'http://httpredir.debian.org/debian/' - $security_url = 'http://security.debian.org/' - $ubuntu_url = 'http://archive.ubuntu.com/ubuntu' - $lts_url = $debian_url - $volatile_url = 'http://volatile.debian.org/debian-volatile/' + $debian_url = 'http://httpredir.debian.org/debian/' + $security_url = 'http://security.debian.org/' + $ubuntu_url = 'http://archive.ubuntu.com/ubuntu' + $lts_url = $debian_url + $volatile_url = 'http://volatile.debian.org/debian-volatile/' case $::operatingsystem { 'debian': { $repos = 'main contrib non-free' diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp index 2b2fb74..e142ea0 100644 --- a/manifests/preferences_snippet.pp +++ b/manifests/preferences_snippet.pp @@ -1,10 +1,10 @@ define apt::preferences_snippet ( $priority = undef, - $package = false, - $ensure = 'present', - $source = undef, - $release = undef, - $pin = undef + $package = false, + $ensure = 'present', + $source = undef, + $release = undef, + $pin = undef, ) { $real_package = $package ? { diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp index 162ade7..5a2979f 100644 --- a/manifests/preseeded_package.pp +++ b/manifests/preseeded_package.pp @@ -1,8 +1,10 @@ # Install a package with a preseed file to automatically answer some questions. + define apt::preseeded_package ( - $ensure = 'installed', - $content = '' + $ensure = 'installed', + $content = '', ) { + $seedfile = "/var/cache/local/preseeding/${name}.seeds" $real_content = $content ? { '' => template ( "site_apt/${::debian_codename}/${name}.seeds" ), diff --git a/manifests/proxy_client.pp b/manifests/proxy_client.pp index e7972f7..0793878 100644 --- a/manifests/proxy_client.pp +++ b/manifests/proxy_client.pp @@ -1,7 +1,7 @@ -class apt::proxy_client( +class apt::proxy_client ( $proxy = 'http://localhost', - $port = '3142', -){ + $port = '3142', +) { ::apt::apt_conf { '20proxy': content => template('apt/20proxy.erb'), diff --git a/manifests/sources_list.pp b/manifests/sources_list.pp index 6ff4fc3..22bc110 100644 --- a/manifests/sources_list.pp +++ b/manifests/sources_list.pp @@ -2,7 +2,7 @@ define apt::sources_list ( $ensure = 'present', $source = undef, - $content = undef + $content = undef, ) { if $ensure == 'present' { diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index dff911d..85d21d4 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -1,10 +1,10 @@ class apt::unattended_upgrades ( - $config_content = undef, - $config_template = 'apt/50unattended-upgrades.erb', - $mailonlyonerror = true, - $mail_recipient = 'root', + $config_content = undef, + $config_template = 'apt/50unattended-upgrades.erb', + $mailonlyonerror = true, + $mail_recipient = 'root', $blacklisted_packages = [], - $ensure_version = present + $ensure_version = 'present', ) { package { 'unattended-upgrades': diff --git a/manifests/upgrade_package.pp b/manifests/upgrade_package.pp index 73eb48b..54dbff6 100644 --- a/manifests/upgrade_package.pp +++ b/manifests/upgrade_package.pp @@ -1,7 +1,7 @@ # 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 = '' + $version = '', ) { $version_suffix = $version ? { -- cgit v1.2.3 From c4e6f42e1b629e98ddeeb7c9821f1266f7295685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Thu, 22 Dec 2016 21:46:37 -0500 Subject: fix missing/superfluous newline at the end/beginning of files --- manifests/apt_conf.pp | 1 - manifests/cron/dist_upgrade.pp | 1 - manifests/dist_upgrade.pp | 1 - manifests/dist_upgrade/initiator.pp | 1 - manifests/dot_d_directories.pp | 4 ++-- manifests/dselect.pp | 1 + manifests/init.pp | 1 - manifests/preferences.pp | 1 - manifests/reboot_required_notify.pp | 1 - manifests/reboot_required_notify/jessie.pp | 1 - manifests/reboot_required_notify/wheezy.pp | 1 - manifests/sources_list.pp | 1 + manifests/update.pp | 1 - manifests/upgrade_package.pp | 2 +- 14 files changed, 5 insertions(+), 13 deletions(-) diff --git a/manifests/apt_conf.pp b/manifests/apt_conf.pp index ec6da6d..709fd23 100644 --- a/manifests/apt_conf.pp +++ b/manifests/apt_conf.pp @@ -41,5 +41,4 @@ define apt::apt_conf ( notify => Exec['apt_updated'], } } - } diff --git a/manifests/cron/dist_upgrade.pp b/manifests/cron/dist_upgrade.pp index d3d3be3..2a46331 100644 --- a/manifests/cron/dist_upgrade.pp +++ b/manifests/cron/dist_upgrade.pp @@ -48,5 +48,4 @@ dist-upgrade -y -o APT::Get::Show-Upgraded=true -o 'DPkg::Options::=--force-conf mode => '0644', require => Package[cron-apt]; } - } diff --git a/manifests/dist_upgrade.pp b/manifests/dist_upgrade.pp index 3061fb8..3d9b29b 100644 --- a/manifests/dist_upgrade.pp +++ b/manifests/dist_upgrade.pp @@ -8,5 +8,4 @@ class apt::dist_upgrade ( timeout => $timeout, before => Exec['apt_updated'] } - } diff --git a/manifests/dist_upgrade/initiator.pp b/manifests/dist_upgrade/initiator.pp index eae5492..2ce83da 100644 --- a/manifests/dist_upgrade/initiator.pp +++ b/manifests/dist_upgrade/initiator.pp @@ -19,5 +19,4 @@ class apt::dist_upgrade::initiator inherits apt::dist_upgrade { Exec['apt_dist-upgrade'] { subscribe +> File['apt_upgrade_initiator'], } - } diff --git a/manifests/dot_d_directories.pp b/manifests/dot_d_directories.pp index 0ace863..970cea0 100644 --- a/manifests/dot_d_directories.pp +++ b/manifests/dot_d_directories.pp @@ -1,6 +1,7 @@ +# watch .d directories and ensure they are present + class apt::dot_d_directories { - # watch .d directories and ensure they are present file { '/etc/apt/apt.conf.d': ensure => directory, @@ -11,5 +12,4 @@ class apt::dot_d_directories { checksum => mtime, notify => Exec['apt_updated']; } - } diff --git a/manifests/dselect.pp b/manifests/dselect.pp index da00c96..2e6e90b 100644 --- a/manifests/dselect.pp +++ b/manifests/dselect.pp @@ -1,5 +1,6 @@ # manage dselect, like # suppressing the annoying help texts + class apt::dselect { file_line { 'dselect_expert': diff --git a/manifests/init.pp b/manifests/init.pp index f7ef2e4..63059dd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -128,5 +128,4 @@ class apt ( # Another Semaphor for all packages to reference alias => [ 'apt_updated', 'refresh_apt'] } - } diff --git a/manifests/preferences.pp b/manifests/preferences.pp index aedd56b..d3eb780 100644 --- a/manifests/preferences.pp +++ b/manifests/preferences.pp @@ -16,5 +16,4 @@ class apt::preferences { require => File['/etc/apt/sources.list'], owner => root, group => 0, mode => '0644'; } - } diff --git a/manifests/reboot_required_notify.pp b/manifests/reboot_required_notify.pp index efd8aeb..3463bb4 100644 --- a/manifests/reboot_required_notify.pp +++ b/manifests/reboot_required_notify.pp @@ -7,5 +7,4 @@ class apt::reboot_required_notify { } else { class { 'apt::reboot_required_notify::wheezy': } } - } diff --git a/manifests/reboot_required_notify/jessie.pp b/manifests/reboot_required_notify/jessie.pp index 2de6b62..b8800a3 100644 --- a/manifests/reboot_required_notify/jessie.pp +++ b/manifests/reboot_required_notify/jessie.pp @@ -24,5 +24,4 @@ class apt::reboot_required_notify::jessie ($ensure = present) { ensure => $ensure, require => Apt::Preferences_snippet['reboot-notifier'], } - } diff --git a/manifests/reboot_required_notify/wheezy.pp b/manifests/reboot_required_notify/wheezy.pp index 06998ef..1ad46cd 100644 --- a/manifests/reboot_required_notify/wheezy.pp +++ b/manifests/reboot_required_notify/wheezy.pp @@ -19,5 +19,4 @@ class apt::reboot_required_notify::wheezy ($ensure = present) { minute => 20, require => Package['update-notifier-common'], } - } diff --git a/manifests/sources_list.pp b/manifests/sources_list.pp index 22bc110..2fc7111 100644 --- a/manifests/sources_list.pp +++ b/manifests/sources_list.pp @@ -1,4 +1,5 @@ # Configure an apt source + define apt::sources_list ( $ensure = 'present', $source = undef, diff --git a/manifests/update.pp b/manifests/update.pp index dde8320..d5fd539 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -3,5 +3,4 @@ class apt::update inherits ::apt { Exec['update_apt'] { refreshonly => false } - } diff --git a/manifests/upgrade_package.pp b/manifests/upgrade_package.pp index 54dbff6..f739f07 100644 --- a/manifests/upgrade_package.pp +++ b/manifests/upgrade_package.pp @@ -1,5 +1,6 @@ # 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 = '', ) { @@ -27,5 +28,4 @@ define apt::upgrade_package ( require => Package['apt-show-versions', 'dctrl-tools'], before => Exec['apt_updated'] } - } -- cgit v1.2.3 From 0bdd46891d9fe202e22fb5a90ed720c6769edf9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Thu, 22 Dec 2016 21:56:16 -0500 Subject: fix array identation --- manifests/dist_upgrade/initiator.pp | 6 ++---- manifests/init.pp | 13 +++++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifests/dist_upgrade/initiator.pp b/manifests/dist_upgrade/initiator.pp index 2ce83da..5dfce14 100644 --- a/manifests/dist_upgrade/initiator.pp +++ b/manifests/dist_upgrade/initiator.pp @@ -9,11 +9,9 @@ class apt::dist_upgrade::initiator inherits apt::dist_upgrade { group => 0, path => $initiator_abs, checksum => md5, - source => [ - "puppet:///modules/site_apt/${::fqdn}/${initiator}", + source => [ "puppet:///modules/site_apt/${::fqdn}/${initiator}", "puppet:///modules/site_apt/${initiator}", - "puppet:///modules/apt/${initiator}", - ], + "puppet:///modules/apt/${initiator}" ], } Exec['apt_dist-upgrade'] { diff --git a/manifests/init.pp b/manifests/init.pp index 63059dd..196c0c7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -117,13 +117,18 @@ class apt ( } # workaround for preseeded_package component - file { [ '/var/cache', '/var/cache/local', '/var/cache/local/preseeding' ]: ensure => directory } + file { + [ '/var/cache', + '/var/cache/local', + '/var/cache/local/preseeding' ]: + ensure => directory; + } exec { 'update_apt': command => '/usr/bin/apt-get update', - require => [ - File['/etc/apt/apt.conf.d', '/etc/apt/preferences' ], - File['/etc/apt/sources.list'] ], + require => [ File['/etc/apt/apt.conf.d', + '/etc/apt/preferences', + '/etc/apt/sources.list'] ], refreshonly => true, # Another Semaphor for all packages to reference alias => [ 'apt_updated', 'refresh_apt'] -- cgit v1.2.3 From 2c56e06458d0308faf3746aff536558362d1082b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Thu, 22 Dec 2016 22:09:14 -0500 Subject: move parts of init.pp to config.pp^& install.pp to increase readability --- manifests/config.pp | 91 ++++++++++++++++++++++++++++++++++++++++++ manifests/init.pp | 109 +++------------------------------------------------ manifests/install.pp | 11 ++++++ 3 files changed, 108 insertions(+), 103 deletions(-) create mode 100644 manifests/config.pp create mode 100644 manifests/install.pp diff --git a/manifests/config.pp b/manifests/config.pp new file mode 100644 index 0000000..3db84d7 --- /dev/null +++ b/manifests/config.pp @@ -0,0 +1,91 @@ +class apt::config inherits apt { + + $sources_content = $custom_sources_list ? { + '' => template( "apt/${::operatingsystem}/sources.list.erb"), + default => $custom_sources_list + } + file { + # include main and security + # additional sources should be included via the apt::sources_list define + '/etc/apt/sources.list': + content => $sources_content, + notify => Exec['apt_updated'], + owner => root, + group => 0, + mode => '0644'; + } + + # workaround for preseeded_package component + file { + [ '/var/cache', + '/var/cache/local', + '/var/cache/local/preseeding' ]: + ensure => directory; + } + + ::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::apt_conf { '03clean_vserver': + source => [ "puppet:///modules/site_apt/${::fqdn}/03clean_vserver", + 'puppet:///modules/site_apt/03clean_vserver', + 'puppet:///modules/apt/03clean_vserver' ], + alias => '03clean'; + } + } + else { + ::apt::apt_conf { '03clean': + source => [ "puppet:///modules/site_apt/${::fqdn}/03clean", + 'puppet:///modules/site_apt/03clean', + 'puppet:///modules/apt/03clean' ] + } + } + + if ($use_backports and !($::debian_release in ['testing', 'unstable', 'experimental'])) { + apt::sources_list { + 'backports': + content => "deb ${debian_url} ${::debian_codename}-backports ${apt::repos}", + } + if $include_src { + apt::sources_list { + 'backports-src': + content => "deb-src ${debian_url} ${::debian_codename}-backports ${apt::repos}", + } + } + } + + if $custom_key_dir { + file { "${apt_base_dir}/keys.d": + source => $custom_key_dir, + recurse => true, + owner => root, + group => root, + mode => '0755', + } + exec { 'custom_keys': + command => "find ${apt_base_dir}/keys.d -type f -exec apt-key add '{}' \\;", + subscribe => File["${apt_base_dir}/keys.d"], + refreshonly => true, + notify => Exec[refresh_apt] + } + if $custom_preferences != false { + Exec['custom_keys'] { + before => File['apt_config'] + } + } + } + + exec { 'update_apt': + command => '/usr/bin/apt-get update', + require => [ File['/etc/apt/apt.conf.d', + '/etc/apt/preferences', + '/etc/apt/sources.list'] ], + refreshonly => true, + # Another Semaphor for all packages to reference + alias => [ 'apt_updated', 'refresh_apt'] + } +} diff --git a/manifests/init.pp b/manifests/init.pp index 196c0c7..26afaeb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -20,47 +20,13 @@ class apt ( $custom_key_dir = $apt::params::custom_key_dir, ) inherits apt::params { - package { 'apt': - ensure => installed, - require => undef, - } - - $sources_content = $custom_sources_list ? { - '' => template( "apt/${::operatingsystem}/sources.list.erb"), - default => $custom_sources_list - } - file { - # include main and security - # additional sources should be included via the apt::sources_list define - '/etc/apt/sources.list': - content => $sources_content, - notify => Exec['apt_updated'], - owner => root, - group => 0, - mode => '0644'; - } - - ::apt::apt_conf { '02show_upgraded': - source => [ "puppet:///modules/site_apt/${::fqdn}/02show_upgraded", - 'puppet:///modules/site_apt/02show_upgraded', - 'puppet:///modules/apt/02show_upgraded' ] - } + include apt::dot_d_directories + include apt::config + include apt::install - if ( $::virtual == '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' ], - alias => '03clean'; - } - } - else { - ::apt::apt_conf { '03clean': - source => [ "puppet:///modules/site_apt/${::fqdn}/03clean", - 'puppet:///modules/site_apt/03clean', - 'puppet:///modules/apt/03clean' ] - } - } + include common::moduledir + common::module_dir { 'apt': } + $apt_base_dir = "${common::moduledir::module_dir_path}/apt" case $custom_preferences { false: { @@ -70,67 +36,4 @@ class apt ( include apt::preferences } } - - include apt::dot_d_directories - - ## This package should really always be current - package { 'debian-archive-keyring': - ensure => latest - } - - if ($use_backports and !($::debian_release in ['testing', 'unstable', 'experimental'])) { - apt::sources_list { - 'backports': - content => "deb ${debian_url} ${::debian_codename}-backports ${apt::repos}", - } - if $include_src { - apt::sources_list { - 'backports-src': - content => "deb-src ${debian_url} ${::debian_codename}-backports ${apt::repos}", - } - } - } - - include common::moduledir - common::module_dir { 'apt': } - $apt_base_dir = "${common::moduledir::module_dir_path}/apt" - - if $custom_key_dir { - file { "${apt_base_dir}/keys.d": - source => $custom_key_dir, - recurse => true, - owner => root, - group => root, - mode => '0755', - } - exec { 'custom_keys': - command => "find ${apt_base_dir}/keys.d -type f -exec apt-key add '{}' \\;", - subscribe => File["${apt_base_dir}/keys.d"], - refreshonly => true, - notify => Exec[refresh_apt] - } - if $custom_preferences != false { - Exec['custom_keys'] { - before => File['apt_config'] - } - } - } - - # workaround for preseeded_package component - file { - [ '/var/cache', - '/var/cache/local', - '/var/cache/local/preseeding' ]: - ensure => directory; - } - - exec { 'update_apt': - command => '/usr/bin/apt-get update', - require => [ File['/etc/apt/apt.conf.d', - '/etc/apt/preferences', - '/etc/apt/sources.list'] ], - refreshonly => true, - # Another Semaphor for all packages to reference - alias => [ 'apt_updated', 'refresh_apt'] - } } diff --git a/manifests/install.pp b/manifests/install.pp new file mode 100644 index 0000000..5f33d11 --- /dev/null +++ b/manifests/install.pp @@ -0,0 +1,11 @@ +class apt::install { + + package { 'apt': + ensure => present, + } + + # This package should really always be current + package { 'debian-archive-keyring': + ensure => latest; + } +} -- cgit v1.2.3 From bdd6cf421143914cc2c0c63fa543013892fd3bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Thu, 22 Dec 2016 22:17:35 -0500 Subject: use the same name for the update_apt exec everywhere --- manifests/apt_conf.pp | 2 +- manifests/config.pp | 22 ++++++++++------------ manifests/dist_upgrade.pp | 2 +- manifests/dot_d_directories.pp | 5 +++-- manifests/key.pp | 2 +- manifests/key/plain.pp | 2 +- manifests/preferences_snippet.pp | 2 +- manifests/sources_list.pp | 2 +- manifests/upgrade_package.pp | 2 +- 9 files changed, 20 insertions(+), 21 deletions(-) diff --git a/manifests/apt_conf.pp b/manifests/apt_conf.pp index 709fd23..8225915 100644 --- a/manifests/apt_conf.pp +++ b/manifests/apt_conf.pp @@ -38,7 +38,7 @@ define apt::apt_conf ( if $refresh_apt { File["/etc/apt/apt.conf.d/${name}"] { - notify => Exec['apt_updated'], + notify => Exec['update_apt'], } } } diff --git a/manifests/config.pp b/manifests/config.pp index 3db84d7..416aabc 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,5 +1,13 @@ class apt::config inherits apt { + exec { 'update_apt': + command => '/usr/bin/apt-get update', + require => [ File['/etc/apt/apt.conf.d', + '/etc/apt/preferences', + '/etc/apt/sources.list'] ], + refreshonly => true; + } + $sources_content = $custom_sources_list ? { '' => template( "apt/${::operatingsystem}/sources.list.erb"), default => $custom_sources_list @@ -9,7 +17,7 @@ class apt::config inherits apt { # additional sources should be included via the apt::sources_list define '/etc/apt/sources.list': content => $sources_content, - notify => Exec['apt_updated'], + notify => Exec['update_apt'], owner => root, group => 0, mode => '0644'; @@ -70,7 +78,7 @@ class apt::config inherits apt { command => "find ${apt_base_dir}/keys.d -type f -exec apt-key add '{}' \\;", subscribe => File["${apt_base_dir}/keys.d"], refreshonly => true, - notify => Exec[refresh_apt] + notify => Exec['update_apt']; } if $custom_preferences != false { Exec['custom_keys'] { @@ -78,14 +86,4 @@ class apt::config inherits apt { } } } - - exec { 'update_apt': - command => '/usr/bin/apt-get update', - require => [ File['/etc/apt/apt.conf.d', - '/etc/apt/preferences', - '/etc/apt/sources.list'] ], - refreshonly => true, - # Another Semaphor for all packages to reference - alias => [ 'apt_updated', 'refresh_apt'] - } } diff --git a/manifests/dist_upgrade.pp b/manifests/dist_upgrade.pp index 3d9b29b..38ae417 100644 --- a/manifests/dist_upgrade.pp +++ b/manifests/dist_upgrade.pp @@ -6,6 +6,6 @@ class 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'] + before => Exec['update_apt'] } } diff --git a/manifests/dot_d_directories.pp b/manifests/dot_d_directories.pp index 970cea0..6d9f790 100644 --- a/manifests/dot_d_directories.pp +++ b/manifests/dot_d_directories.pp @@ -6,10 +6,11 @@ class apt::dot_d_directories { '/etc/apt/apt.conf.d': ensure => directory, checksum => mtime, - notify => Exec['apt_updated']; + notify => Exec['update_apt']; + '/etc/apt/sources.list.d': ensure => directory, checksum => mtime, - notify => Exec['apt_updated']; + notify => Exec['update_apt']; } } diff --git a/manifests/key.pp b/manifests/key.pp index cb70ec6..6ec6523 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -8,6 +8,6 @@ define apt::key ($source, $ensure = 'present') { "/etc/apt/trusted.gpg.d/${name}": ensure => $ensure, source => $source, - notify => Exec['apt_updated'], + notify => Exec['update_apt'], } } diff --git a/manifests/key/plain.pp b/manifests/key/plain.pp index dff8b51..e845b88 100644 --- a/manifests/key/plain.pp +++ b/manifests/key/plain.pp @@ -8,6 +8,6 @@ define apt::key::plain ($source) { exec { "apt-key add '${apt::apt_base_dir}/keys/${name}'": subscribe => File["${apt::apt_base_dir}/keys/${name}"], refreshonly => true, - notify => Exec['apt_updated'], + notify => Exec['update_apt'], } } diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp index e142ea0..eee1511 100644 --- a/manifests/preferences_snippet.pp +++ b/manifests/preferences_snippet.pp @@ -32,7 +32,7 @@ define apt::preferences_snippet ( file { "/etc/apt/preferences.d/${name}": ensure => $ensure, owner => root, group => 0, mode => '0644', - before => Exec['apt_updated']; + before => Exec['update_apt']; } case $source { diff --git a/manifests/sources_list.pp b/manifests/sources_list.pp index 2fc7111..35a7643 100644 --- a/manifests/sources_list.pp +++ b/manifests/sources_list.pp @@ -27,7 +27,7 @@ define apt::sources_list ( mode => '0644', owner => 'root', group => 0, - notify => Exec['apt_updated'], + notify => Exec['update_apt'], } if $source { diff --git a/manifests/upgrade_package.pp b/manifests/upgrade_package.pp index f739f07..a96db7c 100644 --- a/manifests/upgrade_package.pp +++ b/manifests/upgrade_package.pp @@ -26,6 +26,6 @@ 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" ], require => Package['apt-show-versions', 'dctrl-tools'], - before => Exec['apt_updated'] + before => Exec['update_apt'] } } -- cgit v1.2.3 From fd8b21222b969e779d10cb5d49e2e10f717b8358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Thu, 22 Dec 2016 22:26:43 -0500 Subject: make sure every object ends with either a comma or a semicolon --- manifests/apticron.pp | 2 +- manifests/config.pp | 8 ++++---- manifests/cron/dist_upgrade.pp | 4 ++-- manifests/dist_upgrade.pp | 2 +- manifests/dselect.pp | 2 +- manifests/install.pp | 2 +- manifests/listchanges.pp | 2 +- manifests/preferences_snippet.pp | 6 +++--- manifests/preseeded_package.pp | 2 +- manifests/unattended_upgrades.pp | 4 ++-- manifests/update.pp | 2 +- manifests/upgrade_package.pp | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/manifests/apticron.pp b/manifests/apticron.pp index a8a24be..7dbbfb6 100644 --- a/manifests/apticron.pp +++ b/manifests/apticron.pp @@ -13,7 +13,7 @@ class apt::apticron ( ) { package { 'apticron': - ensure => $ensure_version + ensure => $ensure_version; } file { '/etc/apticron/apticron.conf': diff --git a/manifests/config.pp b/manifests/config.pp index 416aabc..4c5c5d3 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -10,7 +10,7 @@ class apt::config inherits apt { $sources_content = $custom_sources_list ? { '' => template( "apt/${::operatingsystem}/sources.list.erb"), - default => $custom_sources_list + default => $custom_sources_list; } file { # include main and security @@ -34,7 +34,7 @@ class apt::config inherits apt { ::apt::apt_conf { '02show_upgraded': source => [ "puppet:///modules/site_apt/${::fqdn}/02show_upgraded", 'puppet:///modules/site_apt/02show_upgraded', - 'puppet:///modules/apt/02show_upgraded' ] + 'puppet:///modules/apt/02show_upgraded' ]; } if ( $::virtual == 'vserver' ) { @@ -49,7 +49,7 @@ class apt::config inherits apt { ::apt::apt_conf { '03clean': source => [ "puppet:///modules/site_apt/${::fqdn}/03clean", 'puppet:///modules/site_apt/03clean', - 'puppet:///modules/apt/03clean' ] + 'puppet:///modules/apt/03clean' ]; } } @@ -82,7 +82,7 @@ class apt::config inherits apt { } if $custom_preferences != false { Exec['custom_keys'] { - before => File['apt_config'] + before => File['apt_config']; } } } diff --git a/manifests/cron/dist_upgrade.pp b/manifests/cron/dist_upgrade.pp index 2a46331..39db07a 100644 --- a/manifests/cron/dist_upgrade.pp +++ b/manifests/cron/dist_upgrade.pp @@ -3,7 +3,7 @@ class apt::cron::dist_upgrade ( ) { package { 'cron-apt': - ensure => installed + ensure => installed; } case $cron_hours { @@ -30,7 +30,7 @@ dist-upgrade -y -o APT::Get::Show-Upgraded=true -o 'DPkg::Options::=--force-conf } package { 'apt-listbugs': - ensure => absent + ensure => absent; } file { '/etc/cron-apt/action.d/4-dist-upgrade': diff --git a/manifests/dist_upgrade.pp b/manifests/dist_upgrade.pp index 38ae417..eb3207c 100644 --- a/manifests/dist_upgrade.pp +++ b/manifests/dist_upgrade.pp @@ -6,6 +6,6 @@ class apt::dist_upgrade ( command => '/usr/bin/apt-get -q -y -o \'DPkg::Options::=--force-confold\' dist-upgrade', refreshonly => true, timeout => $timeout, - before => Exec['update_apt'] + before => Exec['update_apt']; } } diff --git a/manifests/dselect.pp b/manifests/dselect.pp index 2e6e90b..beee9ee 100644 --- a/manifests/dselect.pp +++ b/manifests/dselect.pp @@ -9,6 +9,6 @@ class apt::dselect { } package { 'dselect': - ensure => installed + ensure => installed; } } diff --git a/manifests/install.pp b/manifests/install.pp index 5f33d11..76eb570 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,7 +1,7 @@ class apt::install { package { 'apt': - ensure => present, + ensure => present; } # This package should really always be current diff --git a/manifests/listchanges.pp b/manifests/listchanges.pp index 642986b..e2b77be 100644 --- a/manifests/listchanges.pp +++ b/manifests/listchanges.pp @@ -9,7 +9,7 @@ class apt::listchanges ( ){ package { 'apt-listchanges': - ensure => $ensure_version + ensure => $ensure_version; } file { '/etc/apt/listchanges.conf': diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp index eee1511..1462dbe 100644 --- a/manifests/preferences_snippet.pp +++ b/manifests/preferences_snippet.pp @@ -40,19 +40,19 @@ define apt::preferences_snippet ( case $release { undef: { File["/etc/apt/preferences.d/${name}"]{ - content => template('apt/preferences_snippet.erb') + content => template('apt/preferences_snippet.erb'); } } default: { File["/etc/apt/preferences.d/${name}"]{ - content => template('apt/preferences_snippet_release.erb') + content => template('apt/preferences_snippet_release.erb'); } } } } default: { File["/etc/apt/preferences.d/${name}"]{ - source => $source + source => $source; } } } diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp index 5a2979f..3c69f9b 100644 --- a/manifests/preseeded_package.pp +++ b/manifests/preseeded_package.pp @@ -8,7 +8,7 @@ define apt::preseeded_package ( $seedfile = "/var/cache/local/preseeding/${name}.seeds" $real_content = $content ? { '' => template ( "site_apt/${::debian_codename}/${name}.seeds" ), - default => $content + default => $content; } file { $seedfile: diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index 85d21d4..4067044 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -23,12 +23,12 @@ class apt::unattended_upgrades ( $file_content = $config_content ? { undef => template($config_template), - default => $config_content + default => $config_content; } ::apt::apt_conf { '50unattended-upgrades': content => $file_content, require => Package['unattended-upgrades'], - refresh_apt => false + refresh_apt => false; } } diff --git a/manifests/update.pp b/manifests/update.pp index d5fd539..4cb4e5f 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -1,6 +1,6 @@ class apt::update inherits ::apt { Exec['update_apt'] { - refreshonly => false + refreshonly => false; } } diff --git a/manifests/upgrade_package.pp b/manifests/upgrade_package.pp index a96db7c..079fc3b 100644 --- a/manifests/upgrade_package.pp +++ b/manifests/upgrade_package.pp @@ -26,6 +26,6 @@ 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" ], require => Package['apt-show-versions', 'dctrl-tools'], - before => Exec['update_apt'] + before => Exec['update_apt']; } } -- cgit v1.2.3 From 2cf97fbf458522e9da6a3ed21e3105d1f488d111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Thu, 22 Dec 2016 22:41:20 -0500 Subject: mark packages as present instead of installed to be consistent --- manifests/apticron.pp | 2 +- manifests/cron/dist_upgrade.pp | 2 +- manifests/dselect.pp | 2 +- manifests/listchanges.pp | 2 +- manifests/preseeded_package.pp | 2 +- manifests/upgrade_package.pp | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/manifests/apticron.pp b/manifests/apticron.pp index 7dbbfb6..0adcc68 100644 --- a/manifests/apticron.pp +++ b/manifests/apticron.pp @@ -1,5 +1,5 @@ class apt::apticron ( - $ensure_version = 'installed', + $ensure_version = 'present', $config = "apt/${::operatingsystem}/apticron.erb", $email = 'root', $diff_only = '1', diff --git a/manifests/cron/dist_upgrade.pp b/manifests/cron/dist_upgrade.pp index 39db07a..7cd3964 100644 --- a/manifests/cron/dist_upgrade.pp +++ b/manifests/cron/dist_upgrade.pp @@ -3,7 +3,7 @@ class apt::cron::dist_upgrade ( ) { package { 'cron-apt': - ensure => installed; + ensure => present; } case $cron_hours { diff --git a/manifests/dselect.pp b/manifests/dselect.pp index beee9ee..bfc6cb3 100644 --- a/manifests/dselect.pp +++ b/manifests/dselect.pp @@ -9,6 +9,6 @@ class apt::dselect { } package { 'dselect': - ensure => installed; + ensure => present; } } diff --git a/manifests/listchanges.pp b/manifests/listchanges.pp index e2b77be..d657812 100644 --- a/manifests/listchanges.pp +++ b/manifests/listchanges.pp @@ -1,5 +1,5 @@ class apt::listchanges ( - $ensure_version = 'installed', + $ensure_version = 'present', $config = "apt/${::operatingsystem}/listchanges.erb", $frontend = 'mail', $email = 'root', diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp index 3c69f9b..7e092fd 100644 --- a/manifests/preseeded_package.pp +++ b/manifests/preseeded_package.pp @@ -1,7 +1,7 @@ # Install a package with a preseed file to automatically answer some questions. define apt::preseeded_package ( - $ensure = 'installed', + $ensure = 'present', $content = '', ) { diff --git a/manifests/upgrade_package.pp b/manifests/upgrade_package.pp index 079fc3b..3ba2077 100644 --- a/manifests/upgrade_package.pp +++ b/manifests/upgrade_package.pp @@ -13,13 +13,13 @@ define apt::upgrade_package ( if !defined(Package['apt-show-versions']) { package { 'apt-show-versions': - ensure => installed, + ensure => present, } } if !defined(Package['dctrl-tools']) { package { 'dctrl-tools': - ensure => installed, + ensure => present, } } -- cgit v1.2.3 From 7d52ff7414ff887c3e2128e3e05df936db9ab4ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Thu, 22 Dec 2016 22:44:17 -0500 Subject: use double quotes not to have to escape single ones --- manifests/preferences_snippet.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp index 1462dbe..3044638 100644 --- a/manifests/preferences_snippet.pp +++ b/manifests/preferences_snippet.pp @@ -18,14 +18,14 @@ define apt::preferences_snippet ( } if $priority == undef { - fail('apt::preferences_snippet requires the \'priority\' argument to be set') + fail("apt::preferences_snippet requires the 'priority' argument to be set") } if !$pin and !$release { - fail('apt::preferences_snippet requires one of the \'pin\' or \'release\' argument to be set') + fail("apt::preferences_snippet requires one of the 'pin' or 'release' argument to be set") } if $pin and $release { - fail('apt::preferences_snippet requires either a \'pin\' or \'release\' argument, not both') + fail("apt::preferences_snippet requires either a 'pin' or 'release' argument, not both") } } -- cgit v1.2.3 From 247b3b2c2a269dcd584b25f6b67fe9282befbbde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Thu, 22 Dec 2016 22:58:18 -0500 Subject: fix errors by replacing some semicolons by commas --- manifests/config.pp | 4 ++-- manifests/preferences_snippet.pp | 6 +++--- manifests/unattended_upgrades.pp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 4c5c5d3..881a091 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -10,7 +10,7 @@ class apt::config inherits apt { $sources_content = $custom_sources_list ? { '' => template( "apt/${::operatingsystem}/sources.list.erb"), - default => $custom_sources_list; + default => $custom_sources_list, } file { # include main and security @@ -82,7 +82,7 @@ class apt::config inherits apt { } if $custom_preferences != false { Exec['custom_keys'] { - before => File['apt_config']; + before => File['apt_config'], } } } diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp index 3044638..8905318 100644 --- a/manifests/preferences_snippet.pp +++ b/manifests/preferences_snippet.pp @@ -40,19 +40,19 @@ define apt::preferences_snippet ( case $release { undef: { File["/etc/apt/preferences.d/${name}"]{ - content => template('apt/preferences_snippet.erb'); + content => template('apt/preferences_snippet.erb'), } } default: { File["/etc/apt/preferences.d/${name}"]{ - content => template('apt/preferences_snippet_release.erb'); + content => template('apt/preferences_snippet_release.erb'), } } } } default: { File["/etc/apt/preferences.d/${name}"]{ - source => $source; + source => $source, } } } diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index 4067044..c6db396 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -23,7 +23,7 @@ class apt::unattended_upgrades ( $file_content = $config_content ? { undef => template($config_template), - default => $config_content; + default => $config_content, } ::apt::apt_conf { '50unattended-upgrades': -- cgit v1.2.3 From 350342c86e81e02caaf433ba0b84dbf5d8afc781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Thu, 22 Dec 2016 23:02:16 -0500 Subject: missing single quotes --- manifests/cron/dist_upgrade.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/cron/dist_upgrade.pp b/manifests/cron/dist_upgrade.pp index 7cd3964..d0d9a98 100644 --- a/manifests/cron/dist_upgrade.pp +++ b/manifests/cron/dist_upgrade.pp @@ -38,7 +38,7 @@ dist-upgrade -y -o APT::Get::Show-Upgraded=true -o 'DPkg::Options::=--force-conf owner => root, group => 0, mode => '0644', - require => Package[cron-apt]; + require => Package['cron-apt']; } file { '/etc/cron-apt/config.d/MAILON': @@ -46,6 +46,6 @@ dist-upgrade -y -o APT::Get::Show-Upgraded=true -o 'DPkg::Options::=--force-conf owner => root, group => 0, mode => '0644', - require => Package[cron-apt]; + require => Package['cron-apt']; } } -- cgit v1.2.3 From f41eebf3cae6549b6c56874fc7fda5432f95d9a2 Mon Sep 17 00:00:00 2001 From: varac Date: Fri, 23 Dec 2016 13:45:26 +0100 Subject: Dont pin rspec-core to old version --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 44630f4..226d7ae 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" group :development, :unit_tests do gem "rake" gem "rspec-puppet", "~> 2.1", :require => false - gem "rspec-core", "3.1.7", :require => false + gem "rspec-core" gem "puppetlabs_spec_helper" gem "metadata-json-lint" gem "rspec-puppet-facts" -- cgit v1.2.3 From f8ac878c19bb98db4d95f7cbb988999c33fe8e53 Mon Sep 17 00:00:00 2001 From: varac Date: Fri, 23 Dec 2016 13:45:26 +0100 Subject: Dont pin rspec-core to old version --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 44630f4..226d7ae 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" group :development, :unit_tests do gem "rake" gem "rspec-puppet", "~> 2.1", :require => false - gem "rspec-core", "3.1.7", :require => false + gem "rspec-core" gem "puppetlabs_spec_helper" gem "metadata-json-lint" gem "rspec-puppet-facts" -- cgit v1.2.3 From c72ceac8b339a159db6819455ed47ebb295519ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 30 Dec 2016 01:48:41 -0500 Subject: more ; to , --- manifests/preseeded_package.pp | 2 +- manifests/update.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp index 7e092fd..29a981e 100644 --- a/manifests/preseeded_package.pp +++ b/manifests/preseeded_package.pp @@ -8,7 +8,7 @@ define apt::preseeded_package ( $seedfile = "/var/cache/local/preseeding/${name}.seeds" $real_content = $content ? { '' => template ( "site_apt/${::debian_codename}/${name}.seeds" ), - default => $content; + default => $content, } file { $seedfile: diff --git a/manifests/update.pp b/manifests/update.pp index 4cb4e5f..72cedc2 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -1,6 +1,6 @@ class apt::update inherits ::apt { Exec['update_apt'] { - refreshonly => false; + refreshonly => false, } } -- cgit v1.2.3 From 01960a02d67f4c79edc0bace7f0358a19f9d3d23 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 7c8616b497f75594f478e9656d8bfea9f6ae7eca 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 4b01558ddbca56ac054ae268c21fb65c870020c8 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 263c8e96cecb2babd065b66d4c67fb648b0dc079 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 1ef8f3a486c6afe58e9c1ee6de9d0cf14a9265ff 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 d571464df8ecb34f26b953197353989a0176029c 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 60e334d9d7976513fa3bb7ea8406e7aabf5860f5 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 0b9e32d9ce49a3a74be559b0b487e0beba1c3298 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 ee49b28eeac4f0e7e746aafc6a000adfa89b3687 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 1c86fd4c8e1b15db8ed4eca3f42108434ee5cf7a 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 5a7c6c98853cc7b6126cba9d86a2ffdde83b976b 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 358459d2ef6fffa2775d25b168b8514f55167f38 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 From 48614706954323d458446cc63db1bd408f8d9138 Mon Sep 17 00:00:00 2001 From: varac Date: Fri, 23 Dec 2016 13:45:26 +0100 Subject: Dont pin rspec-core to old version --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 44630f4..226d7ae 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" group :development, :unit_tests do gem "rake" gem "rspec-puppet", "~> 2.1", :require => false - gem "rspec-core", "3.1.7", :require => false + gem "rspec-core" gem "puppetlabs_spec_helper" gem "metadata-json-lint" gem "rspec-puppet-facts" -- cgit v1.2.3 From 5b5a5950c8600cbac53f92c3d2832347aa81f059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Sat, 21 Jan 2017 15:06:41 -0500 Subject: use include instead of inherits --- manifests/reboot_required_notify/jessie.pp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/reboot_required_notify/jessie.pp b/manifests/reboot_required_notify/jessie.pp index 0dd6a18..18e619d 100644 --- a/manifests/reboot_required_notify/jessie.pp +++ b/manifests/reboot_required_notify/jessie.pp @@ -1,4 +1,6 @@ -class apt::reboot_required_notify::jessie ($ensure = present) inherits apt { +class apt::reboot_required_notify::jessie ($ensure = present) { + + include apt if $::operatingsystemmajrelease == 8 and ! $::apt::use_backports { fail('apt::reboot_required_notify requires $apt::use_backports on Jessie') -- cgit v1.2.3 From a7fcc79268052f2090fa09e97a1ac9189daf62a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Sat, 21 Jan 2017 15:59:03 -0500 Subject: fully qualify variables to remove inherits --- manifests/config.pp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 881a091..7705551 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,4 +1,4 @@ -class apt::config inherits apt { +class apt::config { exec { 'update_apt': command => '/usr/bin/apt-get update', @@ -10,7 +10,7 @@ class apt::config inherits apt { $sources_content = $custom_sources_list ? { '' => template( "apt/${::operatingsystem}/sources.list.erb"), - default => $custom_sources_list, + default => $apt::custom_sources_list, } file { # include main and security @@ -53,34 +53,34 @@ class apt::config inherits apt { } } - if ($use_backports and !($::debian_release in ['testing', 'unstable', 'experimental'])) { + if ($apt::use_backports and !($::debian_release in ['testing', 'unstable', 'experimental'])) { apt::sources_list { 'backports': - content => "deb ${debian_url} ${::debian_codename}-backports ${apt::repos}", + content => "deb ${apt::debian_url} ${::debian_codename}-backports ${apt::repos}", } if $include_src { apt::sources_list { 'backports-src': - content => "deb-src ${debian_url} ${::debian_codename}-backports ${apt::repos}", + content => "deb-src ${apt::debian_url} ${::debian_codename}-backports ${apt::repos}", } } } - if $custom_key_dir { - file { "${apt_base_dir}/keys.d": - source => $custom_key_dir, + if $apt::custom_key_dir { + file { "${apt::apt_base_dir}/keys.d": + source => $apt::custom_key_dir, recurse => true, owner => root, group => root, mode => '0755', } exec { 'custom_keys': - command => "find ${apt_base_dir}/keys.d -type f -exec apt-key add '{}' \\;", - subscribe => File["${apt_base_dir}/keys.d"], + command => "find ${apt::apt_base_dir}/keys.d -type f -exec apt-key add '{}' \\;", + subscribe => File["${apt::apt_base_dir}/keys.d"], refreshonly => true, notify => Exec['update_apt']; } - if $custom_preferences != false { + if $apt::custom_preferences != false { Exec['custom_keys'] { before => File['apt_config'], } -- cgit v1.2.3 From 83dd6b478f2799b0d515b577d10c14f24e1f8b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Sat, 21 Jan 2017 16:12:18 -0500 Subject: missed a few variables - fully qualify them --- manifests/config.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 7705551..4b984c7 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -8,7 +8,7 @@ class apt::config { refreshonly => true; } - $sources_content = $custom_sources_list ? { + $sources_content = $apt::custom_sources_list ? { '' => template( "apt/${::operatingsystem}/sources.list.erb"), default => $apt::custom_sources_list, } @@ -58,7 +58,7 @@ class apt::config { 'backports': content => "deb ${apt::debian_url} ${::debian_codename}-backports ${apt::repos}", } - if $include_src { + if $apt::include_src { apt::sources_list { 'backports-src': content => "deb-src ${apt::debian_url} ${::debian_codename}-backports ${apt::repos}", -- cgit v1.2.3 From 904be827acc3cc377123544eaf401f26eb984495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Sat, 21 Jan 2017 16:15:06 -0500 Subject: minor style fixes to comply with CI warnings --- manifests/config.pp | 2 +- manifests/cron/dist_upgrade.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 4b984c7..542fc1f 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -42,7 +42,7 @@ class apt::config { source => [ "puppet:///modules/site_apt/${::fqdn}/03clean_vserver", 'puppet:///modules/site_apt/03clean_vserver', 'puppet:///modules/apt/03clean_vserver' ], - alias => '03clean'; + alias => '03clean'; } } else { diff --git a/manifests/cron/dist_upgrade.pp b/manifests/cron/dist_upgrade.pp index d0d9a98..db36544 100644 --- a/manifests/cron/dist_upgrade.pp +++ b/manifests/cron/dist_upgrade.pp @@ -14,7 +14,7 @@ class apt::cron::dist_upgrade ( cron { 'apt_cron_every_N_hours': command => 'test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt', user => root, - hour => "${cron_hours}", + hour => $cron_hours, minute => 10, require => Package['cron-apt'], } -- cgit v1.2.3 From be883a02b3126d9b934f14bcb721cfe716e57a41 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Tue, 14 Feb 2017 16:39:01 +0000 Subject: Import apt::dpkg_statoverride from https://github.com/example42/puppet-apt. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … at commit 714e393ca4b784b80006e39225d80179e109a8c3, and add copyright and licensing information. --- manifests/dpkg_statoverride.pp | 75 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 manifests/dpkg_statoverride.pp diff --git a/manifests/dpkg_statoverride.pp b/manifests/dpkg_statoverride.pp new file mode 100644 index 0000000..79ef4f1 --- /dev/null +++ b/manifests/dpkg_statoverride.pp @@ -0,0 +1,75 @@ +# = Define: apt::dpkg_statoverride +# +# Override ownership and mode of files +# +# +# == Parameters +# +# [*name*] +# Implicit parameter. +# File path. +# +# [*user*] +# User name (or user id if prepended with '#'). +# +# [*group*] +# Group name (or group id if prepended with '#'). +# +# [*mode*] +# File mode, in octal +# +# [*ensure*] +# Whether to add or delete this configuration +# +# +# == Examples +# +# Usage: +# apt::dpkg_statoverride { '/var/log/puppet': +# user => 'puppet', +# group => 'puppet', +# mode => '750', +# } +# +# == License +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# == Copyright +# +# Copyright 2014-2016 Mathieu Parent +# +define apt::dpkg_statoverride( + $user, + $group, + $mode, + $ensure = present +) { + case $ensure { + 'present': { + exec { "dpkg_statoverride_${name}-add": + command => "dpkg-statoverride --update --add '${user}' '${group}' '${mode}' '${name}'", + unless => "dpkg-statoverride --list '${name}' | grep '${user} ${group} ${mode} ${name}'", + } + } + 'absent': { + exec { "dpkg_statoverride_${name}-add": + command => "dpkg-statoverride --remove '${name}'", + onlyif => "dpkg-statoverride --list '${name}'", + } + } + default: { + fail("Unknown value for \$ensure: '${ensure}'") + } + } +} -- cgit v1.2.3 From 1c31ee4c7240e192fc933c934bb05ea50537bedd Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Fri, 24 Feb 2017 12:26:00 -0500 Subject: Add details about dpkg_statoverride to README Fix 'ressources' typo --- README.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9405bd8..4aa2cc0 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ * [apt::key](#apt-key) * [`apt::key::plain`](#apt-key-plain) * [apt::upgrade_package](#apt-upgrade_package) -* [Resources](#ressources) + * [apt::dpkg_statoverride](#apt-dpkg_statoverride) +* [Resources](#resources) * [File\['apt_config'\]](#fileapt_config) * [Exec\['apt_updated'\]](#execapt_updated) * [Tests](#tests) @@ -602,7 +603,36 @@ to their latest (also, only if they are installed): } -# Resources +## apt::dpkg_statoverride + +Override ownership and mode of files. This define takes the following parameters: + +[*name*] + Implicit parameter. + File path. + +[*user*] + User name (or user id if prepended with '#'). + +[*group*] + Group name (or group id if prepended with '#'). + +[*mode*] + File mode, in octal + +[*ensure*] + Whether to add or delete this configuration + + +Example usage: + + apt::dpkg_statoverride { '/var/log/puppet': + user => 'puppet', + group => 'puppet', + mode => '750', + } + +# Resources ## File['apt_config'] -- cgit v1.2.3 From 16fa78a4fdc21fc1ce8bb4bcb1788c8007e7c373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 24 Feb 2017 15:18:02 -0500 Subject: move from monolithic preferences file to multiple preferences.d files --- manifests/preferences.pp | 63 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/manifests/preferences.pp b/manifests/preferences.pp index d3eb780..787f46f 100644 --- a/manifests/preferences.pp +++ b/manifests/preferences.pp @@ -1,19 +1,56 @@ class apt::preferences { - $pref_contents = $apt::custom_preferences ? { - '' => $::operatingsystem ? { - 'debian' => template("apt/${::operatingsystem}/preferences.erb"), - 'ubuntu' => template("apt/${::operatingsystem}/preferences_${apt::codename}.erb"), - }, - default => $apt::custom_preferences + if $::operatingsystem == "Debian" { + + file { '/etc/apt/preferences.d/stable': + ensure => present, + alias => 'apt_config', + # only update together + content => template('apt/Debian/stable.erb'), + require => File['/etc/apt/sources.list'], + owner => root, group => 0, mode => '0644'; + } + + if $apt::use_volatile { + + file { '/etc/apt/preferences.d/volatile': + ensure => present, + content => template('apt/Debian/volatile.erb'), + require => File['/etc/apt/sources.list'], + owner => root, group => 0, mode => '0644'; + } + } + + if $apt::use_lts { + + file { '/etc/apt/preferences.d/lts': + ensure => present, + content => template('apt/Debian/lts.erb'), + require => File['/etc/apt/sources.list'], + owner => root, group => 0, mode => '0644'; + } + } + + if ($::debian_nextcodename) and ($::debian_nextcodename != "experimental") { + + file { '/etc/apt/preferences.d/nextcodename': + ensure => present, + content => template('apt/Debian/nextcodename.erb'), + require => File['/etc/apt/sources.list'], + owner => root, group => 0, mode => '0644'; + } + } } - file { '/etc/apt/preferences': - ensure => present, - alias => 'apt_config', - # only update together - content => $pref_contents, - require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; + elsif $::operatingsystem == "Ubuntu" { + + file { '/etc/apt/preferences': + ensure => present, + alias => 'apt_config', + # only update together + content => template("apt/Ubuntu/preferences_${apt::codename}.erb"), + require => File['/etc/apt/sources.list'], + owner => root, group => 0, mode => '0644'; + } } } -- cgit v1.2.3 From 7efd1bdbf731d1593e70be5105fd9d178bad54f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 24 Feb 2017 15:19:40 -0500 Subject: add new preferences.d templates --- templates/Debian/fallback.erb | 7 +++++++ templates/Debian/lts.erb | 7 +++++++ templates/Debian/nextcodename.erb | 7 +++++++ templates/Debian/stable.erb | 7 +++++++ templates/Debian/volatile.erb | 7 +++++++ 5 files changed, 35 insertions(+) create mode 100644 templates/Debian/fallback.erb create mode 100644 templates/Debian/lts.erb create mode 100644 templates/Debian/nextcodename.erb create mode 100644 templates/Debian/stable.erb create mode 100644 templates/Debian/volatile.erb diff --git a/templates/Debian/fallback.erb b/templates/Debian/fallback.erb new file mode 100644 index 0000000..1c75e83 --- /dev/null +++ b/templates/Debian/fallback.erb @@ -0,0 +1,7 @@ +# This file is managed by puppet +# all local modifications will be overwritten + +Explanation: Debian fallback +Package: * +Pin: release o=Debian +Pin-Priority: -10 diff --git a/templates/Debian/lts.erb b/templates/Debian/lts.erb new file mode 100644 index 0000000..74281b6 --- /dev/null +++ b/templates/Debian/lts.erb @@ -0,0 +1,7 @@ +# This file is managed by puppet +# all local modifications will be overwritten + +Explanation: Debian <%= codename %>-lts +Package: * +Pin: release o=Debian,n=<%= codename %>-lts +Pin-Priority: 990 diff --git a/templates/Debian/nextcodename.erb b/templates/Debian/nextcodename.erb new file mode 100644 index 0000000..d4f9a40 --- /dev/null +++ b/templates/Debian/nextcodename.erb @@ -0,0 +1,7 @@ +# This file is managed by puppet +# all local modifications will be overwritten + +Explanation: Debian <%= next_codename %> +Package: * +Pin: release o=Debian,n=<%= next_codename %> +Pin-Priority: 2 diff --git a/templates/Debian/stable.erb b/templates/Debian/stable.erb new file mode 100644 index 0000000..df84fce --- /dev/null +++ b/templates/Debian/stable.erb @@ -0,0 +1,7 @@ +# 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 diff --git a/templates/Debian/volatile.erb b/templates/Debian/volatile.erb new file mode 100644 index 0000000..1654abe --- /dev/null +++ b/templates/Debian/volatile.erb @@ -0,0 +1,7 @@ +# This file is managed by puppet +# all local modifications will be overwritten + +Explanation: Debian <%= codename %>-updates +Package: * +Pin: release o=Debian,n=<%= codename %>-updates +Pin-Priority: 990 -- cgit v1.2.3 From 0c189c8bdbbcc46a42f10ddd700d790f40834661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 24 Feb 2017 15:30:26 -0500 Subject: fix variable name --- templates/Debian/nextcodename.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/Debian/nextcodename.erb b/templates/Debian/nextcodename.erb index d4f9a40..0810412 100644 --- a/templates/Debian/nextcodename.erb +++ b/templates/Debian/nextcodename.erb @@ -1,7 +1,7 @@ # This file is managed by puppet # all local modifications will be overwritten -Explanation: Debian <%= next_codename %> +Explanation: Debian <%= debian_nextcodename %> Package: * -Pin: release o=Debian,n=<%= next_codename %> +Pin: release o=Debian,n=<%= debian_nextcodename %> Pin-Priority: 2 -- cgit v1.2.3 From 5e9099b77546a77492402b4003bc9e002bcc4650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 24 Feb 2017 15:32:15 -0500 Subject: preferences.d/stable is the new preferences --- manifests/config.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index 542fc1f..f50d4bc 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -3,7 +3,7 @@ class apt::config { exec { 'update_apt': command => '/usr/bin/apt-get update', require => [ File['/etc/apt/apt.conf.d', - '/etc/apt/preferences', + '/etc/apt/preferences.d/stable', '/etc/apt/sources.list'] ], refreshonly => true; } -- cgit v1.2.3 From dfbfc7a05f7ac6713b4ac1379cfb6e2cefa85093 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Fri, 24 Feb 2017 13:03:59 -0500 Subject: rename preseeded_package into package keep a wrapper in place with a deprecation notice for the old name so that ppl can know about the change and migrate to the new name --- README.md | 11 +++++++---- manifests/package.pp | 25 +++++++++++++++++++++++++ manifests/preseeded_package.pp | 25 +++++-------------------- 3 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 manifests/package.pp diff --git a/README.md b/README.md index 9405bd8..49110ba 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ * [Defines](#defines) * [apt::apt_conf](#apt-apt_conf) * [apt::preferences_snippet](#apt-preferences_snippet) - * [apt::preseeded_package](#apt-preseeded_package) + * [apt::package](#apt-package) * [apt::sources_list](#apt-sources_list) * [apt::key](#apt-key) * [`apt::key::plain`](#apt-key-plain) @@ -155,6 +155,9 @@ Ubuntu support is lagging behind but not absent either. port => '666'; } + * the `apt::preseeded_package` defined type was renamed `apt::package` the + previous name is now deprecated and will be removed in the future. + # Requirements @@ -505,7 +508,7 @@ From apt_preferences(5): characters - otherwise they will be silently ignored. -## apt::preseeded_package +## apt::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 @@ -513,12 +516,12 @@ 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::package { locales: } You can also specify the content of the seed via the content parameter, for example: - apt::preseeded_package { 'apticron': + apt::package { 'apticron': content => 'apticron apticron/notification string root@example.com', } diff --git a/manifests/package.pp b/manifests/package.pp new file mode 100644 index 0000000..b2ae79d --- /dev/null +++ b/manifests/package.pp @@ -0,0 +1,25 @@ +# Install a package with a preseed file to automatically answer some questions. +define apt::package ( + $ensure = 'present', + $seedfile_content = '', +) { + + $seedfile = "/var/cache/local/preseeding/${name}.seeds" + $real_seedfile_content = $seedfile_content ? { + '' => template ( "site_apt/${::debian_codename}/${name}.seeds" ), + default => $seedfile_content, + } + + file { $seedfile: + content => $real_seedfile_content, + mode => '0600', + owner => 'root', + group => 0, + } + + package { $name: + ensure => $ensure, + responsefile => $seedfile, + require => File[$seedfile], + } +} diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp index 29a981e..e1d1dcc 100644 --- a/manifests/preseeded_package.pp +++ b/manifests/preseeded_package.pp @@ -1,26 +1,11 @@ -# Install a package with a preseed file to automatically answer some questions. - +# This is a wrapper that will be removed after a while define apt::preseeded_package ( $ensure = 'present', $content = '', ) { - - $seedfile = "/var/cache/local/preseeding/${name}.seeds" - $real_content = $content ? { - '' => template ( "site_apt/${::debian_codename}/${name}.seeds" ), - default => $content, - } - - file { $seedfile: - content => $real_content, - mode => '0600', - owner => 'root', - group => 0, - } - - package { $name: - ensure => $ensure, - responsefile => $seedfile, - require => File[$seedfile], + warning('apt::preseeded_package is deprecated! you should now use apt::package instead.') + apt::package { $name: + ensure => $ensure, + content => $content, } } -- cgit v1.2.3 From f447904e47c14f287283d8a3de9fb17033ccafdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 24 Feb 2017 15:44:21 -0500 Subject: fix variable name (bis) --- templates/Debian/lts.erb | 4 ++-- templates/Debian/stable.erb | 4 ++-- templates/Debian/volatile.erb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/Debian/lts.erb b/templates/Debian/lts.erb index 74281b6..3ed2f51 100644 --- a/templates/Debian/lts.erb +++ b/templates/Debian/lts.erb @@ -1,7 +1,7 @@ # This file is managed by puppet # all local modifications will be overwritten -Explanation: Debian <%= codename %>-lts +Explanation: Debian <%= debian_codename %>-lts Package: * -Pin: release o=Debian,n=<%= codename %>-lts +Pin: release o=Debian,n=<%= debian_codename %>-lts Pin-Priority: 990 diff --git a/templates/Debian/stable.erb b/templates/Debian/stable.erb index df84fce..0acfc8f 100644 --- a/templates/Debian/stable.erb +++ b/templates/Debian/stable.erb @@ -1,7 +1,7 @@ # This file is managed by puppet # all local modifications will be overwritten -Explanation: Debian <%= codename=scope.lookupvar('::debian_codename') %> +Explanation: Debian <%= debian_codename %> Package: * -Pin: release o=Debian,n=<%= codename %> +Pin: release o=Debian,n=<%= debian_codename %> Pin-Priority: 990 diff --git a/templates/Debian/volatile.erb b/templates/Debian/volatile.erb index 1654abe..5014e01 100644 --- a/templates/Debian/volatile.erb +++ b/templates/Debian/volatile.erb @@ -1,7 +1,7 @@ # This file is managed by puppet # all local modifications will be overwritten -Explanation: Debian <%= codename %>-updates +Explanation: Debian <%= debian_codename %>-updates Package: * -Pin: release o=Debian,n=<%= codename %>-updates +Pin: release o=Debian,n=<%= debian_codename %>-updates Pin-Priority: 990 -- cgit v1.2.3 From 38a2b7900178fa00c8dfd16481c84818d2b9a47a Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Fri, 24 Feb 2017 15:50:32 -0500 Subject: teach apt::package to mange pins for packages --- manifests/package.pp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/manifests/package.pp b/manifests/package.pp index b2ae79d..159d693 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -2,6 +2,8 @@ define apt::package ( $ensure = 'present', $seedfile_content = '', + $pin = '', + $pin_priority = 1000 ) { $seedfile = "/var/cache/local/preseeding/${name}.seeds" @@ -17,9 +19,17 @@ define apt::package ( group => 0, } + if $pin { + apt::preferences_snippet { $name: + ensure => $ensure, + priority => $pin_priority, + pin => $pin, + } + } + package { $name: ensure => $ensure, responsefile => $seedfile, - require => File[$seedfile], + require => [File[$seedfile], Apt::Preferences_snippet[$name]], } } -- cgit v1.2.3 From 3f0a363088c64c905a3fe7f6369d28b770cdf481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 24 Feb 2017 16:30:49 -0500 Subject: fix custom_preferences && refactor how they work --- manifests/init.pp | 9 +--- manifests/params.pp | 23 +++++----- manifests/preferences.pp | 93 ++++++++++++++++++++++++++-------------- manifests/preferences/absent.pp | 7 --- manifests/preferences_snippet.pp | 3 -- 5 files changed, 73 insertions(+), 62 deletions(-) delete mode 100644 manifests/preferences/absent.pp diff --git a/manifests/init.pp b/manifests/init.pp index 26afaeb..3a37f6b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -23,17 +23,10 @@ class apt ( include apt::dot_d_directories include apt::config include apt::install + include apt::preferences include common::moduledir common::module_dir { 'apt': } $apt_base_dir = "${common::moduledir::module_dir_path}/apt" - case $custom_preferences { - false: { - include apt::preferences::absent - } - default: { - include apt::preferences - } - } } diff --git a/manifests/params.pp b/manifests/params.pp index 463cd63..3879c81 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,14 +1,16 @@ class apt::params () { - $use_lts = false - $use_volatile = false - $use_backports = true - $include_src = false - $use_next_release = false - $debian_url = 'http://httpredir.debian.org/debian/' - $security_url = 'http://security.debian.org/' - $ubuntu_url = 'http://archive.ubuntu.com/ubuntu' - $lts_url = $debian_url - $volatile_url = 'http://volatile.debian.org/debian-volatile/' + $use_lts = false + $use_volatile = false + $use_backports = true + $include_src = false + $use_next_release = false + $manage_preferences = true + $custom_preferences = undef + $debian_url = 'http://httpredir.debian.org/debian/' + $security_url = 'http://security.debian.org/' + $ubuntu_url = 'http://archive.ubuntu.com/ubuntu' + $lts_url = $debian_url + $volatile_url = 'http://volatile.debian.org/debian-volatile/' case $::operatingsystem { 'debian': { $repos = 'main contrib non-free' @@ -20,6 +22,5 @@ class apt::params () { fail("Unsupported system '${::operatingsystem}'.") } } - $custom_preferences = '' $custom_key_dir = false } diff --git a/manifests/preferences.pp b/manifests/preferences.pp index 787f46f..548098f 100644 --- a/manifests/preferences.pp +++ b/manifests/preferences.pp @@ -1,56 +1,83 @@ class apt::preferences { - if $::operatingsystem == "Debian" { - - file { '/etc/apt/preferences.d/stable': - ensure => present, - alias => 'apt_config', - # only update together - content => template('apt/Debian/stable.erb'), - require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; + if ($apt::manage_preferences == true) and ($apt::custom_preferences != undef) { + + file { '/etc/apt/preferences.d/custom': + ensure => present, + alias => 'apt_config', + # only update together + content => $custom_preferences, + require => File['/etc/apt/sources.list'], + owner => root, group => 0, mode => '0644'; } + } - if $apt::use_volatile { + elsif $apt::manage_preferences == true { - file { '/etc/apt/preferences.d/volatile': + if $::operatingsystem == "Debian" { + + file { '/etc/apt/preferences.d/stable': ensure => present, - content => template('apt/Debian/volatile.erb'), + alias => 'apt_config', + # only update together + content => template('apt/Debian/stable.erb'), require => File['/etc/apt/sources.list'], owner => root, group => 0, mode => '0644'; } - } - if $apt::use_lts { + if $apt::use_volatile { - file { '/etc/apt/preferences.d/lts': - ensure => present, - content => template('apt/Debian/lts.erb'), - require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; + file { '/etc/apt/preferences.d/volatile': + ensure => present, + content => template('apt/Debian/volatile.erb'), + require => File['/etc/apt/sources.list'], + owner => root, group => 0, mode => '0644'; + } + } + + if $apt::use_lts { + + file { '/etc/apt/preferences.d/lts': + ensure => present, + content => template('apt/Debian/lts.erb'), + require => File['/etc/apt/sources.list'], + owner => root, group => 0, mode => '0644'; + } + } + + if ($::debian_nextcodename) and ($::debian_nextcodename != "experimental") { + + file { '/etc/apt/preferences.d/nextcodename': + ensure => present, + content => template('apt/Debian/nextcodename.erb'), + require => File['/etc/apt/sources.list'], + owner => root, group => 0, mode => '0644'; + } } } - if ($::debian_nextcodename) and ($::debian_nextcodename != "experimental") { + elsif $::operatingsystem == "Ubuntu" { - file { '/etc/apt/preferences.d/nextcodename': - ensure => present, - content => template('apt/Debian/nextcodename.erb'), - require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; + file { '/etc/apt/preferences': + ensure => present, + alias => 'apt_config', + # only update together + content => template("apt/Ubuntu/preferences_${apt::codename}.erb"), + require => File['/etc/apt/sources.list'], + owner => root, group => 0, mode => '0644'; } } } - elsif $::operatingsystem == "Ubuntu" { + elsif $apt::manage_preferences == false { - file { '/etc/apt/preferences': - ensure => present, - alias => 'apt_config', - # only update together - content => template("apt/Ubuntu/preferences_${apt::codename}.erb"), - require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; + file { + [ '/etc/apt/preferences.d/custom', + '/etc/apt/preferences.d/stable', + '/etc/apt/preferences.d/volatile', + '/etc/apt/preferences.d/lts', + '/etc/apt/preferences.d/nextcodename']: + ensure => absent; } } } diff --git a/manifests/preferences/absent.pp b/manifests/preferences/absent.pp deleted file mode 100644 index f32e030..0000000 --- a/manifests/preferences/absent.pp +++ /dev/null @@ -1,7 +0,0 @@ -class apt::preferences::absent { - - file { '/etc/apt/preferences': - ensure => absent, - alias => 'apt_config', - } -} diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp index 8905318..04fb010 100644 --- a/manifests/preferences_snippet.pp +++ b/manifests/preferences_snippet.pp @@ -13,9 +13,6 @@ define apt::preferences_snippet ( } if $ensure == 'present' { - if $apt::custom_preferences == false { - fail('Trying to define a preferences_snippet with $custom_preferences set to false.') - } if $priority == undef { fail("apt::preferences_snippet requires the 'priority' argument to be set") -- cgit v1.2.3 From 1893f692dc430929240e5ec53480444d98055462 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Fri, 24 Feb 2017 16:46:27 -0500 Subject: make use of preseed optional and disabled by default We currently can't use apt::package without preseeding. Also by default the preseed content is grabbed from an implicit template, which makes puppet runs fail for a non-obvious reason. To keep previous functionality, force use of seed file when using the deprecated apt::preseeded_package type. --- manifests/package.pp | 36 ++++++++++++++++++++++-------------- manifests/preseeded_package.pp | 7 ++++--- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/manifests/package.pp b/manifests/package.pp index 159d693..e83ac68 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -1,22 +1,33 @@ # Install a package with a preseed file to automatically answer some questions. define apt::package ( $ensure = 'present', + $use_seed = false, + $seedfile_template = "site_apt/${::debian_codename}/${name}.seeds", $seedfile_content = '', $pin = '', $pin_priority = 1000 ) { - $seedfile = "/var/cache/local/preseeding/${name}.seeds" - $real_seedfile_content = $seedfile_content ? { - '' => template ( "site_apt/${::debian_codename}/${name}.seeds" ), - default => $seedfile_content, + package { $name: + ensure => $ensure, + responsefile => $seedfile, } - file { $seedfile: - content => $real_seedfile_content, - mode => '0600', - owner => 'root', - group => 0, + if $use_seed { + $seedfile = "/var/cache/local/preseeding/${name}.seeds" + $real_seedfile_content = $seedfile_content ? { + '' => template ( $seedfile_template ), + default => $seedfile_content, + } + + file { $seedfile: + content => $real_seedfile_content, + mode => '0600', + owner => 'root', + group => 0, + } + + File[$seedfile] -> Package[$name] } if $pin { @@ -25,11 +36,8 @@ define apt::package ( priority => $pin_priority, pin => $pin, } - } - package { $name: - ensure => $ensure, - responsefile => $seedfile, - require => [File[$seedfile], Apt::Preferences_snippet[$name]], + Apt::Preferences_snippet[$name] -> Package[$name] } + } diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp index e1d1dcc..7db740f 100644 --- a/manifests/preseeded_package.pp +++ b/manifests/preseeded_package.pp @@ -3,9 +3,10 @@ define apt::preseeded_package ( $ensure = 'present', $content = '', ) { - warning('apt::preseeded_package is deprecated! you should now use apt::package instead.') + warning('apt::preseeded_package is deprecated! you should now use apt::package with parameter use_seed set to true instead.') apt::package { $name: - ensure => $ensure, - content => $content, + ensure => $ensure, + use_seed => true, + content => $content, } } -- cgit v1.2.3 From 7687c41a759f8a138a51f922b19d6ab4149df950 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Fri, 24 Feb 2017 17:01:05 -0500 Subject: Adjust README to show new parameter that's needed for preseeding. --- README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 49110ba..eb83437 100644 --- a/README.md +++ b/README.md @@ -511,18 +511,25 @@ From apt_preferences(5): ## apt::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 +answers to debconf. To use preseeding you need to set the `use_seed` parameter +to true. 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::package { locales: } + apt::package { 'locales': + use_seed => true, + } + +You can change what template is used by setting `seedfile_template` to a +template path (same as you would pass to the template() function). -You can also specify the content of the seed via the content parameter, -for example: +You can also specify the content of the seed via the content parameter instead +of using a template, for example: apt::package { 'apticron': - content => 'apticron apticron/notification string root@example.com', + use_seed => true, + content => 'apticron apticron/notification string root@example.com', } -- cgit v1.2.3 From e6b07002d6b53b45012d93a33296b7b7e32f8e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 24 Feb 2017 17:08:12 -0500 Subject: remove preferences.d files when not using them --- manifests/config.pp | 1 - manifests/preferences.pp | 37 +++++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index f50d4bc..50a8ebd 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -3,7 +3,6 @@ class apt::config { exec { 'update_apt': command => '/usr/bin/apt-get update', require => [ File['/etc/apt/apt.conf.d', - '/etc/apt/preferences.d/stable', '/etc/apt/sources.list'] ], refreshonly => true; } diff --git a/manifests/preferences.pp b/manifests/preferences.pp index 548098f..a1e78ee 100644 --- a/manifests/preferences.pp +++ b/manifests/preferences.pp @@ -2,13 +2,19 @@ class apt::preferences { if ($apt::manage_preferences == true) and ($apt::custom_preferences != undef) { - file { '/etc/apt/preferences.d/custom': - ensure => present, - alias => 'apt_config', - # only update together - content => $custom_preferences, - require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; + file { + '/etc/apt/preferences.d/custom': + ensure => present, + alias => 'apt_config', + content => template(${apt::custom_preferences}), + require => File['/etc/apt/sources.list'], + owner => root, group => 0, mode => '0644'; + + [ '/etc/apt/preferences.d/stable', + '/etc/apt/preferences.d/volatile', + '/etc/apt/preferences.d/lts', + '/etc/apt/preferences.d/nextcodename' ]: + ensure => absent; } } @@ -16,13 +22,16 @@ class apt::preferences { if $::operatingsystem == "Debian" { - file { '/etc/apt/preferences.d/stable': - ensure => present, - alias => 'apt_config', - # only update together - content => template('apt/Debian/stable.erb'), - require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; + file { + '/etc/apt/preferences.d/stable': + ensure => present, + alias => 'apt_config', + content => template('apt/Debian/stable.erb'), + require => File['/etc/apt/sources.list'], + owner => root, group => 0, mode => '0644'; + + '/etc/apt/preferences.d/custom': + ensure => absent; } if $apt::use_volatile { -- cgit v1.2.3 From cd84a163d068e5dd368731b51f6934495a30313c Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Fri, 24 Feb 2017 17:09:27 -0500 Subject: README: document new pin/pin_priority parameters to apt::package --- README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eb83437..fd9f587 100644 --- a/README.md +++ b/README.md @@ -511,9 +511,11 @@ From apt_preferences(5): ## apt::package This simplifies installation of packages for which you wish to preseed the -answers to debconf. To use preseeding you need to set the `use_seed` parameter -to true. For example, if you wish to provide a preseed file for the locales -package, you would place the `locales.seed` file in +answers to debconf or pin to a certain version. + +To use preseeding you need to set the `use_seed` parameter to true. 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: @@ -532,6 +534,18 @@ of using a template, for example: content => 'apticron apticron/notification string root@example.com', } +To pin a package to a certain release or version, you need to set the `pin` +parameter to the restriction that you want (this value corresponds to the +'Pin:' line in preferences files). For example this would pin the package +ganeti to the jessie release: + + apt::package { 'ganeti': + pin => 'release o=Debian Backports,a=jessie', + } + +Also, if you want to set a priority number to a package pin, you can set +`pin_priority` to an integer value. The default value of this parameter is +1000, which will install but not downgrade a package. ## apt::sources_list -- cgit v1.2.3 From 9e47b77a2ba0145103da82921b36de4facf59a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 24 Feb 2017 17:28:41 -0500 Subject: add manage_preferences to init.pp --- manifests/init.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/init.pp b/manifests/init.pp index 3a37f6b..25e35ff 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -15,6 +15,7 @@ class apt ( $volatile_url = $apt::params::volatile_url, $ubuntu_url = $apt::params::ubuntu_url, $repos = $apt::params::repos, + $manage_preferences = $apt::params::manage_preferences, $custom_preferences = $apt::params::custom_preferences, $custom_sources_list = '', $custom_key_dir = $apt::params::custom_key_dir, -- cgit v1.2.3 From ef250c00dc9217bca231890899febe27c60b7d92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 24 Feb 2017 17:30:46 -0500 Subject: seems puppet didn't like square brackets --- manifests/preferences.pp | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/manifests/preferences.pp b/manifests/preferences.pp index a1e78ee..455b9ab 100644 --- a/manifests/preferences.pp +++ b/manifests/preferences.pp @@ -6,15 +6,21 @@ class apt::preferences { '/etc/apt/preferences.d/custom': ensure => present, alias => 'apt_config', - content => template(${apt::custom_preferences}), + content => template($apt::custom_preferences), require => File['/etc/apt/sources.list'], owner => root, group => 0, mode => '0644'; - [ '/etc/apt/preferences.d/stable', - '/etc/apt/preferences.d/volatile', - '/etc/apt/preferences.d/lts', - '/etc/apt/preferences.d/nextcodename' ]: - ensure => absent; + '/etc/apt/preferences.d/stable': + ensure => absent; + + '/etc/apt/preferences.d/volatile': + ensure => absent; + + '/etc/apt/preferences.d/lts': + ensure => absent; + + '/etc/apt/preferences.d/nextcodename': + ensure => absent; } } @@ -81,12 +87,20 @@ class apt::preferences { elsif $apt::manage_preferences == false { file { - [ '/etc/apt/preferences.d/custom', - '/etc/apt/preferences.d/stable', - '/etc/apt/preferences.d/volatile', - '/etc/apt/preferences.d/lts', - '/etc/apt/preferences.d/nextcodename']: - ensure => absent; + '/etc/apt/preferences.d/custom': + ensure => absent; + + '/etc/apt/preferences.d/stable': + ensure => absent; + + '/etc/apt/preferences.d/volatile': + ensure => absent; + + '/etc/apt/preferences.d/lts': + ensure => absent; + + '/etc/apt/preferences.d/nextcodename': + ensure => absent; } } } -- cgit v1.2.3 From b34581d9c74cb02eec11278f0b5d028495c005e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 24 Feb 2017 17:38:51 -0500 Subject: ensure old monolithic preferences file is no more --- manifests/preferences.pp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifests/preferences.pp b/manifests/preferences.pp index 455b9ab..ce28d37 100644 --- a/manifests/preferences.pp +++ b/manifests/preferences.pp @@ -1,5 +1,9 @@ class apt::preferences { + file { '/etc/apt/preferences': + ensure => absent; + } + if ($apt::manage_preferences == true) and ($apt::custom_preferences != undef) { file { -- cgit v1.2.3 From 416103f0625d67cb4056fe1d92775d1685966799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 24 Feb 2017 17:49:27 -0500 Subject: update the README with the new preferences.d behavior --- README.md | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4aa2cc0..32c86db 100644 --- a/README.md +++ b/README.md @@ -253,25 +253,19 @@ Example usage: If this variable is set the default repositories list ("main contrib non-free") is overriden. -### custom_preferences +### manage_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). + Setting this variable to `false` will delete all the files in `preferences.d` + managed by Puppet. By default, this parameter is set to `true`. - 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') ) +### custom_preferences - Setting this variable to false before including this class will force the - `apt/preferences` file to be absent: + If the default preferences template doesn't suit your needs, you can create a + template located in your `apt` module, and set `custom_preferences` to your + preferred template: class { 'apt': - custom_preferences => false, + custom_preferences => 'apt/my_super_template.erb', } ### custom_sources_list -- cgit v1.2.3 From 4a261733172f2699b217ea6d43ec9ee09a32c72d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 24 Feb 2017 18:17:34 -0500 Subject: define variables in templates with the right style --- templates/Debian/lts.erb | 4 ++-- templates/Debian/nextcodename.erb | 4 ++-- templates/Debian/stable.erb | 4 ++-- templates/Debian/volatile.erb | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/Debian/lts.erb b/templates/Debian/lts.erb index 3ed2f51..a77835e 100644 --- a/templates/Debian/lts.erb +++ b/templates/Debian/lts.erb @@ -1,7 +1,7 @@ # This file is managed by puppet # all local modifications will be overwritten -Explanation: Debian <%= debian_codename %>-lts +Explanation: Debian <%= @debian_codename %>-lts Package: * -Pin: release o=Debian,n=<%= debian_codename %>-lts +Pin: release o=Debian,n=<%= @debian_codename %>-lts Pin-Priority: 990 diff --git a/templates/Debian/nextcodename.erb b/templates/Debian/nextcodename.erb index 0810412..2bec9ad 100644 --- a/templates/Debian/nextcodename.erb +++ b/templates/Debian/nextcodename.erb @@ -1,7 +1,7 @@ # This file is managed by puppet # all local modifications will be overwritten -Explanation: Debian <%= debian_nextcodename %> +Explanation: Debian <%= @debian_nextcodename %> Package: * -Pin: release o=Debian,n=<%= debian_nextcodename %> +Pin: release o=Debian,n=<%= @debian_nextcodename %> Pin-Priority: 2 diff --git a/templates/Debian/stable.erb b/templates/Debian/stable.erb index 0acfc8f..be05e51 100644 --- a/templates/Debian/stable.erb +++ b/templates/Debian/stable.erb @@ -1,7 +1,7 @@ # This file is managed by puppet # all local modifications will be overwritten -Explanation: Debian <%= debian_codename %> +Explanation: Debian <%= @debian_codename %> Package: * -Pin: release o=Debian,n=<%= debian_codename %> +Pin: release o=Debian,n=<%= @debian_codename %> Pin-Priority: 990 diff --git a/templates/Debian/volatile.erb b/templates/Debian/volatile.erb index 5014e01..47ec2d8 100644 --- a/templates/Debian/volatile.erb +++ b/templates/Debian/volatile.erb @@ -1,7 +1,7 @@ # This file is managed by puppet # all local modifications will be overwritten -Explanation: Debian <%= debian_codename %>-updates +Explanation: Debian <%= @debian_codename %>-updates Package: * -Pin: release o=Debian,n=<%= debian_codename %>-updates +Pin: release o=Debian,n=<%= @debian_codename %>-updates Pin-Priority: 990 -- cgit v1.2.3 From d24b79310523e4823214d6b52883f0f4debc56af Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 16 Apr 2017 21:19:49 -0400 Subject: README: missing sentence end in deprecation notice for preseeded_package The missing dot made the announcement confusing. There are really two different informations in there that should be split. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd9f587..aac4a8e 100644 --- a/README.md +++ b/README.md @@ -155,8 +155,9 @@ Ubuntu support is lagging behind but not absent either. port => '666'; } - * the `apt::preseeded_package` defined type was renamed `apt::package` the - previous name is now deprecated and will be removed in the future. + * the `apt::preseeded_package` defined + type was renamed `apt::package`. the previous name is now deprecated and + will be removed in the future. # Requirements -- cgit v1.2.3 From bbf4bc03fa076ae3984d8eae18e27fd09627f177 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 16 Apr 2017 21:29:30 -0400 Subject: package wrongly documented and used with content parameter There are some references to the old `content` parameter (from preseeded_package) that mistakenly weren't replaced with the new parameter `seedfile_content`. This meant the documentation was wrong and the `preseeded_package` wrapper was erroring out because of an unknown parameter. --- README.md | 6 +++--- manifests/preseeded_package.pp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index aac4a8e..944044b 100644 --- a/README.md +++ b/README.md @@ -527,12 +527,12 @@ following in your manifest: You can change what template is used by setting `seedfile_template` to a template path (same as you would pass to the template() function). -You can also specify the content of the seed via the content parameter instead -of using a template, for example: +You can also specify the content of the seed via the `seedfile_content` +parameter instead of using a template, for example: apt::package { 'apticron': use_seed => true, - content => 'apticron apticron/notification string root@example.com', + seedfile_content => 'apticron apticron/notification string root@example.com', } To pin a package to a certain release or version, you need to set the `pin` diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp index 7db740f..e6fcab1 100644 --- a/manifests/preseeded_package.pp +++ b/manifests/preseeded_package.pp @@ -5,8 +5,8 @@ define apt::preseeded_package ( ) { warning('apt::preseeded_package is deprecated! you should now use apt::package with parameter use_seed set to true instead.') apt::package { $name: - ensure => $ensure, - use_seed => true, - content => $content, + ensure => $ensure, + use_seed => true, + seedfile_content => $content, } } -- cgit v1.2.3 From 9a4adac94a72d8bd8c3d5b4657adac15f43ecd30 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 16 Apr 2017 21:31:50 -0400 Subject: README: slightly reword template usage for apt::package The current wording is not super clear on what type of file should be dropped in `site_apt/...`. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 944044b..3343393 100644 --- a/README.md +++ b/README.md @@ -515,7 +515,7 @@ This simplifies installation of packages for which you wish to preseed the answers to debconf or pin to a certain version. To use preseeding you need to set the `use_seed` parameter to true. For -example, if you wish to provide a preseed file for the locales package, you +example, if you wish to provide a preseed template 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: @@ -525,7 +525,8 @@ following in your manifest: } You can change what template is used by setting `seedfile_template` to a -template path (same as you would pass to the template() function). +template path of your choosing (same as you would pass to the template() +function). You can also specify the content of the seed via the `seedfile_content` parameter instead of using a template, for example: -- cgit v1.2.3 From 8b45a8a34e6c074cddd7a23fb8777fd01f4ce7f0 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 18 Jun 2017 23:13:57 -0400 Subject: stretch was released buster+1's codename is known, and wheezy has been in LTS for some time already. --- lib/facter/util/debian.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/facter/util/debian.rb b/lib/facter/util/debian.rb index 290c17b..5291660 100644 --- a/lib/facter/util/debian.rb +++ b/lib/facter/util/debian.rb @@ -1,7 +1,7 @@ module Facter module Util module Debian - STABLE = 8 + STABLE = 9 CODENAMES = { "5" => "lenny", "6" => "squeeze", @@ -9,9 +9,11 @@ module Facter "8" => "jessie", "9" => "stretch", "10" => "buster", + "11" => "bullseye", } LTS = [ "squeeze", + "wheezy", ] end end -- cgit v1.2.3 From c21d3592ace74cd10e84f3cf712bea719805e1be Mon Sep 17 00:00:00 2001 From: Varac Date: Thu, 22 Jun 2017 10:49:52 +0200 Subject: Use official ruby docker image --- .gitlab-ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 49bf2e3..05430fd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,5 @@ -image: leapcode/ruby +image: ruby:2.1 before_script: - - "[ -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[@]}" .job_template: &job_definition @@ -39,4 +37,3 @@ test:puppet4x: PUPPET_VERSION: "> 4" FACTER_VERSION: '> 2' <<: *job_definition - -- cgit v1.2.3