]> gitweb.fluxo.info Git - puppet-apt.git/commitdiff
Install unattended-upgrades after Exec[refresh_apt]
authorvarac <varacanero@zeromail.org>
Fri, 1 Feb 2013 10:01:23 +0000 (11:01 +0100)
committervarac <varacanero@zeromail.org>
Fri, 1 Feb 2013 14:52:29 +0000 (15:52 +0100)
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
manifests/unattended_upgrades.pp

index d78fb9be0a4e892dabbad14db45775492bc51290..f446c694c512b5499ebebf98b7f9de291111305d 100644 (file)
@@ -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'],
+    }
+  }
+
 }
index c538831cb41a6ae8b2b4e88139d70667c4b5a9ef..b9d19c30bff0d46d3b0420bbb74d21822a0ffbc4 100644 (file)
@@ -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 {