]> gitweb.fluxo.info Git - puppet-apt.git/commitdiff
Refactor: manage .d directories when using sources_list and apt_conf
authorGabriel Filion <lelutin@gmail.com>
Mon, 9 Apr 2012 05:33:13 +0000 (01:33 -0400)
committerGabriel Filion <lelutin@gmail.com>
Mon, 9 Apr 2012 05:38:30 +0000 (01:38 -0400)
The .d directories are only managed by the main 'apt' class. However,
both 'sources_list' and 'apt_conf' defines depend on those directories.
So in practice, the defines have an implicit need for those directories
to be somehow managed.

Let's turn this into an explicit relation, and include the directories
in the defines.

This makes it possible to use both defines without having to include the
main 'apt' class. (maybe when using puppet apply?)

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
manifests/apt_conf.pp
manifests/dot_d_directories.pp [new file with mode: 0644]
manifests/init.pp
manifests/sources_list.pp

index c484ec398fe81ecc9035705db002d49b497d58b6..03ae1ac4508f7512d3ed01300870e42d6aade826 100644 (file)
@@ -12,6 +12,8 @@ define apt::apt_conf(
     fail("Only one of \$source or \$content must specified for apt_conf ${name}")
   }
 
+  include apt::dot_d_directories
+
   file { "/etc/apt/apt.conf.d/${name}":
     ensure => $ensure,
     notify => Exec["refresh_apt"],
diff --git a/manifests/dot_d_directories.pp b/manifests/dot_d_directories.pp
new file mode 100644 (file)
index 0000000..742aad4
--- /dev/null
@@ -0,0 +1,22 @@
+class apt::dot_d_directories {
+
+  # watch .d directories and ensure they are present
+  file {
+    "/etc/apt/apt.conf.d":
+      ensure => directory,
+      checksum => mtime,
+      notify => Exec['refresh_apt'];
+    "/etc/apt/sources.list.d":
+      ensure => directory,
+      checksum => mtime,
+      notify => Exec['refresh_apt'];
+  }
+
+  exec {
+    # "&& sleep 1" is workaround for older(?) clients
+    'refresh_apt':
+      command => '/usr/bin/apt-get update && sleep 1',
+      refreshonly => true,
+  }
+
+}
index b5be91fc6ed5989fcfdc896aaa7d127f461ceb1f..0d58c6154c744af7c2ed8f8dbb1a2e37ee390114 100644 (file)
@@ -128,21 +128,7 @@ class apt {
       require => [ Apt_conf['02show_upgraded'], Apt_conf['03clean'] ];
   }
 
-  # watch .d directories and ensure they are present
-  file { "/etc/apt/apt.conf.d": ensure => directory, checksum => mtime; }
-  file { "/etc/apt/sources.list.d":
-    ensure => directory,
-    checksum => mtime,
-    notify => Exec['refresh_apt'],
-  }
-
-  exec {
-    # "&& sleep 1" is workaround for older(?) clients
-    'refresh_apt':
-      command => '/usr/bin/apt-get update && sleep 1',
-      refreshonly => true,
-      subscribe => [ File['/etc/apt/apt.conf.d'], Config_file['/etc/apt/sources.list'] ];
-  }
+  include apt::dot_d_directories
 
   ## This package should really always be current
   package { "debian-archive-keyring": ensure => latest }
index 86b35a7adb451e1071bf5ad5e57173f08b7b28b3..edf7f227d1eb25f66c2a64e1b620338deba13901 100644 (file)
@@ -11,6 +11,8 @@ define apt::sources_list (
     fail("Only one of \$source or \$content must specified for apt_sources_snippet ${name}")
   }
 
+  include apt::dot_d_directories
+
   file { "/etc/apt/sources.list.d/${name}":
     ensure => $ensure,
     owner => root, group => 0, mode => 0644;