From 4204847fdd423dfaff0dafb5130080a30003921f Mon Sep 17 00:00:00 2001 From: nadir Date: Thu, 8 Nov 2012 10:07:38 +0100 Subject: added $apt_disable_update to disable "apt-get update" during puppetruns --- manifests/dist_upgrade.pp | 2 +- manifests/init.pp | 5 +++++ manifests/upgrade_package.pp | 13 ++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/manifests/dist_upgrade.pp b/manifests/dist_upgrade.pp index 9e26769..347ccc7 100644 --- a/manifests/dist_upgrade.pp +++ b/manifests/dist_upgrade.pp @@ -1,6 +1,6 @@ class apt::dist_upgrade { - include apt::update + if $apt::disable_update = false { include apt::update } exec { 'apt_dist-upgrade': command => "/usr/bin/apt-get -q -y -o 'DPkg::Options::=--force-confold' dist-upgrade", diff --git a/manifests/init.pp b/manifests/init.pp index 2ae691f..794347f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -40,6 +40,11 @@ class apt { '' => 'http://archive.ubuntu.com/ubuntu', default => "${apt_ubuntu_url}", } + $disable_update = $apt_disable_update ? { + '' => false, + default => $apt_disable_update + } + case $operatingsystem { 'debian': { $repos = $apt_repos ? { diff --git a/manifests/upgrade_package.pp b/manifests/upgrade_package.pp index 9202624..2ce6932 100644 --- a/manifests/upgrade_package.pp +++ b/manifests/upgrade_package.pp @@ -1,6 +1,8 @@ define apt::upgrade_package ($version = "") { - include apt::update + if $apt::disable_update == false { + include apt::update + } $version_suffix = $version ? { '' => '', @@ -24,10 +26,11 @@ define apt::upgrade_package ($version = "") { 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 => [ - Exec['apt_updated'], - Package['apt-show-versions', 'dctrl-tools'], - ], + require => $apt::disable_update ? { + true => Package['apt-show-versions', 'dctrl-tools'], + default => [ Exec['apt_updated'], + Package['apt-show-versions', 'dctrl-tools'] ], + } } } -- cgit v1.2.3 From 4718ae27c9e58e97baf520629ab154bc66acda6e Mon Sep 17 00:00:00 2001 From: nadir Date: Thu, 8 Nov 2012 10:16:09 +0100 Subject: updated README to explain $apt_disable_update --- README | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README b/README index be80c62..1d43284 100644 --- a/README +++ b/README @@ -155,6 +155,15 @@ $apt_repos If this variable is set the default repositories list ("main contrib non-free") is overriden. +$apt_disable_update +------------------- + +Disable "apt-get update" which is normally triggered by apt::upgrade_package +and apt::dist_upgrade. +Note that nodes can be updated once a day by using + APT::Periodic::Update-Package-Lists "1"; +in i.e. /etc/apt/apt.conf.d/80_apt_update_daily. + Classes ======= -- cgit v1.2.3 From 3a473dafd5887cb77b0b764dd951d9581b69f160 Mon Sep 17 00:00:00 2001 From: nadir Date: Tue, 18 Dec 2012 22:31:00 +0100 Subject: comparing variabled should use double quotes (interestingly, it does work with only one too) --- manifests/dist_upgrade.pp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/dist_upgrade.pp b/manifests/dist_upgrade.pp index 347ccc7..47b1cff 100644 --- a/manifests/dist_upgrade.pp +++ b/manifests/dist_upgrade.pp @@ -1,6 +1,8 @@ class apt::dist_upgrade { - if $apt::disable_update = false { include apt::update } + if $apt::disable_update == false { + include apt::update + } exec { 'apt_dist-upgrade': command => "/usr/bin/apt-get -q -y -o 'DPkg::Options::=--force-confold' dist-upgrade", -- cgit v1.2.3 From e66823269e7799d88e5f071b32bd3415c1e477ce Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Tue, 18 Dec 2012 16:41:10 -0500 Subject: switch default $debian_url to use http.debian.net which is more accurate and up-to-date than cdn.debian.net --- manifests/init.pp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 2ae691f..581f058 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -21,7 +21,7 @@ class apt { } $debian_url = $apt_debian_url ? { - '' => 'http://cdn.debian.net/debian/', + '' => 'http://http.debian.net/debian/', default => "${apt_debian_url}", } $security_url = $apt_security_url ? { @@ -68,6 +68,9 @@ class apt { $codename = $lsbdistcodename $release = $lsbdistrelease } + 'n/a': { + fail("Unknown lsbdistcodename reported by facter: '$lsbdistcodename', please fix this by setting this variable in your manifest.") + } default: { $codename = $lsbdistcodename $release = debian_release($codename) -- cgit v1.2.3 From 7de392c40e0037c2abdf6d659f28212b265a1eb3 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Tue, 18 Dec 2012 16:45:38 -0500 Subject: On a sid system, $lsbdistcodename is reports 'n/a', this doesn't work because the module looks for a template based on the $lsbdistcodename, so you get this error: Could not find template 'apt/Debian/preferences_n/a.erb' The slash in 'n/a' appears to be a path (confusing!) So I've set an error message when 'n/a' is encountered, encouraging the user to set the $lsbdistcodename. I was not confident in the idea of pointing any occurrence of 'n/a' to the sid templates, as I could imagine a case where this might occur on a non-sid system where the lsbdistcodename isn't properly detected --- manifests/init.pp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 2ae691f..802da3a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -68,6 +68,9 @@ class apt { $codename = $lsbdistcodename $release = $lsbdistrelease } + 'n/a': { + fail("Unknown lsbdistcodename reported by facter: '$lsbdistcodename', please fix this by setting this variable in your manifest.") + } default: { $codename = $lsbdistcodename $release = debian_release($codename) -- cgit v1.2.3 From 37e40416d2aa7614cfbcd4330d4cd543f9874093 Mon Sep 17 00:00:00 2001 From: nadir Date: Wed, 19 Dec 2012 18:30:29 +0100 Subject: exec{'apt_dist-upgrade'} just requires Exec['apt_updated'] if apt::disable_update if false --- manifests/dist_upgrade.pp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/dist_upgrade.pp b/manifests/dist_upgrade.pp index 47b1cff..ed25b0b 100644 --- a/manifests/dist_upgrade.pp +++ b/manifests/dist_upgrade.pp @@ -7,7 +7,10 @@ class apt::dist_upgrade { exec { 'apt_dist-upgrade': command => "/usr/bin/apt-get -q -y -o 'DPkg::Options::=--force-confold' dist-upgrade", refreshonly => true, - require => Exec['apt_updated'], + require => $apt::disable_update ? { + true => undef, + default => Exec['apt_updated'], + } } } -- cgit v1.2.3