From 92d2d7be5f99920c67245d02c1ce76288967db62 Mon Sep 17 00:00:00 2001 From: varac Date: Sun, 20 Jan 2013 17:32:02 +0100 Subject: added custom fact apt_running --- lib/facter/apt_running.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 lib/facter/apt_running.rb diff --git a/lib/facter/apt_running.rb b/lib/facter/apt_running.rb new file mode 100644 index 0000000..e8f2156 --- /dev/null +++ b/lib/facter/apt_running.rb @@ -0,0 +1,7 @@ +Facter.add("apt_running") do + setcode do + #Facter::Util::Resolution.exec('/usr/bin/dpkg -s mysql-server >/dev/null 2>&1 && echo true || echo false') + Facter::Util::Resolution.exec('pgrep apt-get >/dev/null 2>&1 && echo true || echo false') + end +end + -- cgit v1.2.3 From f16a0727dce187d07389388da8b816f7b520205d Mon Sep 17 00:00:00 2001 From: varac Date: Fri, 1 Feb 2013 11:01:23 +0100 Subject: Install unattended-upgrades after Exec[refresh_apt] Before, including apt::unattended_upgrades on a host without the unattended-upgrades package would fail on the first run, because the module tries to install the package before apt is finally configured. This commit does: - introduce the option $refresh_apt for apt::apt_conf (Defaults to true). Can be used to not trigger Exec['refresh_apt'] - install the unattended-upgrades package after a final Exec['refresh_apt']. To not run into a loop, it calls Apt_conf['50unattended-upgrades'] with the option refresh_apt => false, which is also not needed for the configuration --- manifests/apt_conf.pp | 11 +++++++++-- manifests/unattended_upgrades.pp | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/manifests/apt_conf.pp b/manifests/apt_conf.pp index d78fb9b..f446c69 100644 --- a/manifests/apt_conf.pp +++ b/manifests/apt_conf.pp @@ -1,7 +1,8 @@ define apt::apt_conf( $ensure = 'present', $source = '', - $content = undef ) + $content = undef, + $refresh_apt = true ) { if $source == '' and $content == undef { @@ -22,7 +23,6 @@ define apt::apt_conf( owner => root, group => 0, mode => '0644', - notify => Exec['refresh_apt'], } if $source { @@ -35,4 +35,11 @@ define apt::apt_conf( content => $content, } } + + if $refresh_apt { + File["/etc/apt/apt.conf.d/${name}"] { + notify => Exec['refresh_apt'], + } + } + } diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index c538831..b9d19c3 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -2,16 +2,21 @@ class apt::unattended_upgrades { package { 'unattended-upgrades': ensure => present, - require => undef, + require => Exec[refresh_apt] } apt_conf { '50unattended-upgrades': - source => [ - "puppet:///modules/site_apt/${::lsbdistcodename}/50unattended-upgrades", - 'puppet:///modules/site_apt/50unattended-upgrades', - "puppet:///modules/apt/${::lsbdistcodename}/50unattended-upgrades", - 'puppet:///modules/apt/50unattended-upgrades' ], - require => Package['unattended-upgrades'], + source => [ + "puppet:///modules/site_apt/${::lsbdistcodename}/50unattended-upgrades", + 'puppet:///modules/site_apt/50unattended-upgrades', + "puppet:///modules/apt/${::lsbdistcodename}/50unattended-upgrades", + 'puppet:///modules/apt/50unattended-upgrades' ], + require => Package['unattended-upgrades'], + refresh_apt => false + } + + Apt_conf['50unattended-upgrades'] { + notify => undef } if $apt::custom_preferences != false { -- cgit v1.2.3 From c8a28eb80ec87e65d5cacb2d109d4c0bcbbc76db Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 14 Mar 2013 20:01:35 +0100 Subject: apt keys: always deploy before Exec[refresh_apt], also with $custom_preferences --- manifests/init.pp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 020c1cc..0f60efb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -128,7 +128,11 @@ class apt( } if $custom_preferences != false { Exec['custom_keys'] { - before => File['apt_config'], + before => [ Exec[refresh_apt], File['apt_config'] ] + } + } else { + Exec['custom_keys'] { + before => Exec[refresh_apt] } } } -- cgit v1.2.3 From 7e8113b3fcf6f251ca9d5e2f39f43fd024058c97 Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 14 Mar 2013 22:19:33 +0100 Subject: deploy /etc/apt/preferences before File['apt_config'] --- manifests/preferences.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/preferences.pp b/manifests/preferences.pp index 9ed24c1..5cfaff2 100644 --- a/manifests/preferences.pp +++ b/manifests/preferences.pp @@ -14,7 +14,8 @@ class apt::preferences { # only update together content => $pref_contents, require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; + owner => root, group => 0, mode => '0644', + before => File['apt_config']; } } -- cgit v1.2.3 From 6bf7a6ab5d6e63f75c94f49aa0f12959e954efa8 Mon Sep 17 00:00:00 2001 From: varac Date: Fri, 15 Mar 2013 20:28:25 +0100 Subject: Revert "deploy /etc/apt/preferences before File['apt_config']" This reverts commit 7e8113b3fcf6f251ca9d5e2f39f43fd024058c97. see https://leap.se/code/issues/1990 for the miserious details. --- manifests/preferences.pp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/manifests/preferences.pp b/manifests/preferences.pp index 5cfaff2..9ed24c1 100644 --- a/manifests/preferences.pp +++ b/manifests/preferences.pp @@ -14,8 +14,7 @@ class apt::preferences { # only update together content => $pref_contents, require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644', - before => File['apt_config']; + owner => root, group => 0, mode => '0644'; } } -- cgit v1.2.3