From d007a403330c553d925b1b4888d93962a5f83f99 Mon Sep 17 00:00:00 2001 From: Jerome Charaoui Date: Mon, 11 May 2015 10:49:27 -0400 Subject: Replace debian_*() parser functions with facts * Removes dependency on lsb-release and/or Facter >1.7 (values are based on $::lsbdistcodename, when available) * Simplifies maintenance: only lib/facter/util/* require updates as new releases are made Caveats: * apt::codename is removed; to override debian_* facts, set the FACTER_debian_codename environment variable for puppet * If tracking unstable, make sure lsb-release is installed, as other methods can't tell between testing and unstable --- manifests/apticron.pp | 2 +- manifests/init.pp | 16 ---------------- manifests/listchanges.pp | 2 +- manifests/params.pp | 3 +-- manifests/preferences.pp | 4 ++-- manifests/preseeded_package.pp | 2 +- 6 files changed, 6 insertions(+), 23 deletions(-) (limited to 'manifests') diff --git a/manifests/apticron.pp b/manifests/apticron.pp index 54d7b71..9c94f9c 100644 --- a/manifests/apticron.pp +++ b/manifests/apticron.pp @@ -1,6 +1,6 @@ class apt::apticron( $ensure_version = 'installed', - $config = "apt/${::operatingsystem}/apticron_${::lsbdistcodename}.erb", + $config = "apt/${::operatingsystem}/apticron_${::debian_codename}.erb", $email = 'root', $diff_only = '1', $listchanges_profile = 'apticron', diff --git a/manifests/init.pp b/manifests/init.pp index 68856cc..5aaa13a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,7 +4,6 @@ # See LICENSE for the full license granted to you. class apt( - $codename = $apt::params::codename, $use_lts = $apt::params::use_lts, $use_volatile = $apt::params::use_volatile, $include_src = $apt::params::include_src, @@ -41,21 +40,6 @@ class apt( require => undef, } - include lsb - - # init $release, $next_release, $next_codename, $release_version - case $codename { - 'n/a': { - fail("Unknown lsbdistcodename reported by facter: '$::lsbdistcodename', please fix this by setting this variable in your manifest.") - } - default: { - $release = debian_release($codename) - } - } - $release_version = debian_release_version($codename) - $next_codename = debian_nextcodename($codename) - $next_release = debian_nextrelease($release) - $sources_content = $custom_sources_list ? { '' => template( "apt/${::operatingsystem}/sources.list.erb"), default => $custom_sources_list diff --git a/manifests/listchanges.pp b/manifests/listchanges.pp index 0c163ae..e64bb1b 100644 --- a/manifests/listchanges.pp +++ b/manifests/listchanges.pp @@ -1,6 +1,6 @@ class apt::listchanges( $ensure_version = 'installed', - $config = "apt/${::operatingsystem}/listchanges_${::lsbdistcodename}.erb", + $config = "apt/${::operatingsystem}/listchanges_${::debian_codename}.erb", $frontend = 'mail', $email = 'root', $confirm = '0', diff --git a/manifests/params.pp b/manifests/params.pp index f977c27..da531db 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,12 +1,11 @@ class apt::params () { - $codename = $::lsbdistcodename $use_lts = false $use_volatile = false $include_src = false $use_next_release = false $debian_url = 'http://httpredir.debian.org/debian/' $security_url = 'http://security.debian.org/' - $backports_url = $::lsbdistcodename ? { + $backports_url = $::debian_codename ? { 'squeeze' => 'http://backports.debian.org/debian-backports/', default => $debian_url } diff --git a/manifests/preferences.pp b/manifests/preferences.pp index 9ed24c1..6982ca0 100644 --- a/manifests/preferences.pp +++ b/manifests/preferences.pp @@ -2,8 +2,8 @@ class apt::preferences { $pref_contents = $apt::custom_preferences ? { '' => $::operatingsystem ? { - 'debian' => template("apt/${::operatingsystem}/preferences_${apt::codename}.erb"), - 'ubuntu' => template("apt/${::operatingsystem}/preferences_${apt::codename}.erb"), + 'debian' => template("apt/${::operatingsystem}/preferences_${::debian_codename}.erb"), + 'ubuntu' => template("apt/${::operatingsystem}/preferences_${::ubuntu_codename}.erb"), }, default => $apt::custom_preferences } diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp index 9bca8b1..3ef0687 100644 --- a/manifests/preseeded_package.pp +++ b/manifests/preseeded_package.pp @@ -4,7 +4,7 @@ define apt::preseeded_package ( ) { $seedfile = "/var/cache/local/preseeding/${name}.seeds" $real_content = $content ? { - '' => template ( "site_apt/${::lsbdistcodename}/${name}.seeds" ), + '' => template ( "site_apt/${::debian_codename}/${name}.seeds" ), default => $content } -- cgit v1.2.3 From e714859a10776123afe77bbd15d9f7a02ea9682f Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Fri, 9 Oct 2015 16:59:33 -0400 Subject: Make it possible to specify own template. Micah found an issue with usage of config_content: if you call template('...') yourself and pass that on to config_content, then your template gets evaluated without all of the variables. This means that you don't hava access to blacklisted_packages, mail_recipient or mailonlyonerror. To make it possible to use a different template while still having access to those variables, let's make it possible to change the template name that we're using. --- manifests/unattended_upgrades.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'manifests') diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index 6cb0518..ffb5fad 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -1,5 +1,6 @@ class apt::unattended_upgrades ( $config_content = undef, + $config_template = 'apt/50unattended-upgrades.erb', $mailonlyonerror = true, $mail_recipient = 'root', $blacklisted_packages = [], @@ -11,7 +12,7 @@ class apt::unattended_upgrades ( } $file_content = $config_content ? { - undef => template('apt/50unattended-upgrades.erb'), + undef => template($config_template), default => $config_content } -- cgit v1.2.3 From bfa973a66896208e2cf0bea37ec15a4f950f09bd Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Fri, 4 Dec 2015 12:33:35 -0500 Subject: Use $ubuntu_url as default value of $backports_url on Ubuntu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ubuntu shouldn't be using debian backports by default. This was written by Anoine Beaupré, but split from the commit "move backports to snippets" since the change is unrelated and needs to be more visible in the commit history. --- manifests/params.pp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'manifests') diff --git a/manifests/params.pp b/manifests/params.pp index 9c85b6f..28da13e 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -6,13 +6,16 @@ class apt::params () { $use_next_release = false $debian_url = 'http://httpredir.debian.org/debian/' $security_url = 'http://security.debian.org/' + $ubuntu_url = 'http://archive.ubuntu.com/ubuntu' $backports_url = $::debian_codename ? { 'squeeze' => 'http://backports.debian.org/debian-backports/', - default => $debian_url + default => $::operatingsystem ? { + 'Ubuntu' => $ubuntu_url, + default => $debian_url, + } } $lts_url = $debian_url $volatile_url = 'http://volatile.debian.org/debian-volatile/' - $ubuntu_url = 'http://archive.ubuntu.com/ubuntu' $repos = 'auto' $custom_preferences = '' $disable_update = false -- cgit v1.2.3 From e4a9222d861ae05a8d9d0a43f2ed4aa0be229390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Thu, 11 Jun 2015 11:04:46 -0400 Subject: move backports to snippets this allows for third party modules to enable this on the fly --- manifests/init.pp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'manifests') diff --git a/manifests/init.pp b/manifests/init.pp index fc93eb3..4f5dd25 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -46,7 +46,7 @@ class apt( default => $custom_sources_list } file { - # include main, security and backports + # include main and security # additional sources should be included via the apt::sources_list define '/etc/apt/sources.list': content => $sources_content, @@ -98,6 +98,21 @@ class apt( # backports uses the normal archive key now package { 'debian-backports-keyring': ensure => absent } + if $use_backports { + if ($release != "testing" and $release != "unstable" and $release != "experimental") { + apt::sources_list { + "${codename}-backports": + content => "deb $backports_url ${codename}-backports ${apt::real_repos}", + } + if $include_src { + apt::sources_list { + "${codename}-backports-src": + content => "deb-src $backports_url ${codename}-backports ${apt::real_repos}", + } + } + } + } + include common::moduledir common::module_dir { 'apt': } $apt_base_dir = "${common::moduledir::module_dir_path}/apt" -- cgit v1.2.3 From f492e5840b3d2122e347ead5d1c240e794120d0e Mon Sep 17 00:00:00 2001 From: Jerome Charaoui Date: Fri, 9 Oct 2015 13:50:43 -0400 Subject: Switch old $release and $codename local variables to new debian_* facts --- manifests/init.pp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'manifests') diff --git a/manifests/init.pp b/manifests/init.pp index 4f5dd25..16593c7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -99,15 +99,15 @@ class apt( package { 'debian-backports-keyring': ensure => absent } if $use_backports { - if ($release != "testing" and $release != "unstable" and $release != "experimental") { + if (${::debian_release} != "testing" and ${::debian_release} != "unstable" and ${::debian_release} != "experimental") { apt::sources_list { - "${codename}-backports": - content => "deb $backports_url ${codename}-backports ${apt::real_repos}", + 'backports': + content => "deb $backports_url ${::debian_codename}-backports ${apt::real_repos}", } if $include_src { apt::sources_list { - "${codename}-backports-src": - content => "deb-src $backports_url ${codename}-backports ${apt::real_repos}", + 'backports-src': + content => "deb-src $backports_url ${::debian_codename}-backports ${apt::real_repos}", } } } -- cgit v1.2.3 From 4d3b720308964c027674bb08c49f142b4684ff58 Mon Sep 17 00:00:00 2001 From: Jerome Charaoui Date: Fri, 9 Oct 2015 14:08:46 -0400 Subject: Simplify conditional expressions --- manifests/init.pp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'manifests') diff --git a/manifests/init.pp b/manifests/init.pp index 16593c7..2660612 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -98,17 +98,15 @@ class apt( # backports uses the normal archive key now package { 'debian-backports-keyring': ensure => absent } - if $use_backports { - if (${::debian_release} != "testing" and ${::debian_release} != "unstable" and ${::debian_release} != "experimental") { + if ($use_backports and !($::debian_release in ['testing', 'unstable', 'experimental'])) { + apt::sources_list { + 'backports': + content => "deb $backports_url ${::debian_codename}-backports ${apt::real_repos}", + } + if $include_src { apt::sources_list { - 'backports': - content => "deb $backports_url ${::debian_codename}-backports ${apt::real_repos}", - } - if $include_src { - apt::sources_list { - 'backports-src': - content => "deb-src $backports_url ${::debian_codename}-backports ${apt::real_repos}", - } + 'backports-src': + content => "deb-src $backports_url ${::debian_codename}-backports ${apt::real_repos}", } } } -- cgit v1.2.3 From 2942cd0dd88ec3a1d38197d148af9952a397b67c Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Fri, 4 Dec 2015 14:29:36 -0500 Subject: remove requirement on lsb package for sources.list file Managing requirements for installing the lsb package has proven over time to make no sense. The best approach to this is to require lsb-release to be installed alongside puppet, since otherwise there are so much facts that get no value during the run and you end up needing to run puppet twice to get the real end result. Also, since we're not including a class that is actually installing the 'lsb' package, that require line makes it so that including the apt module doesn't work, and there's no documentation in the README about needing to provide a package{'lsb':} resource with the apt class. Because of all that, it makes more sense to just get rid of that require line and mark lsb as a pre-requirement in the README file. --- manifests/init.pp | 1 - 1 file changed, 1 deletion(-) (limited to 'manifests') diff --git a/manifests/init.pp b/manifests/init.pp index 2660612..6732ade 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -50,7 +50,6 @@ class apt( # additional sources should be included via the apt::sources_list define '/etc/apt/sources.list': content => $sources_content, - require => Package['lsb'], notify => Exec['refresh_apt'], owner => root, group => 0, -- cgit v1.2.3