]> gitweb.fluxo.info Git - puppet-apt.git/commitdiff
Add apt_conf_snippet and use it where possible
authorGabriel Filion <lelutin@gmail.com>
Sun, 24 Oct 2010 13:07:34 +0000 (09:07 -0400)
committerGabriel Filion <lelutin@gmail.com>
Sun, 24 Oct 2010 13:17:09 +0000 (09:17 -0400)
With the new define, it's easy to add an apt.conf snippet in apt.conf.d
It accepts either 'sources' to get a static file or 'content' to define
content inline or with the help of a template.

Put it to use where we create files in apt.conf.d

Finally, fix the dependancy to the apt_config file (however, I don't see
the need for this dependancy)

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
files/02show_upgraded [new file with mode: 0644]
files/03clean [new file with mode: 0644]
manifests/apt_conf_snippet.pp [new file with mode: 0644]
manifests/init.pp
manifests/proxy-client.pp
manifests/unattended_upgrades.pp
templates/20proxy.erb [new file with mode: 0644]

diff --git a/files/02show_upgraded b/files/02show_upgraded
new file mode 100644 (file)
index 0000000..870a3a9
--- /dev/null
@@ -0,0 +1 @@
+APT::Get::Show-Upgraded true;
diff --git a/files/03clean b/files/03clean
new file mode 100644 (file)
index 0000000..335823d
--- /dev/null
@@ -0,0 +1 @@
+DSelect::Clean auto;
diff --git a/manifests/apt_conf_snippet.pp b/manifests/apt_conf_snippet.pp
new file mode 100644 (file)
index 0000000..77b88ae
--- /dev/null
@@ -0,0 +1,29 @@
+define apt::apt_conf_snippet(
+  $ensure = 'present',
+  $source = '',
+  $content = undef
+){
+  if $source == '' and $content == undef {
+    fail("One of \$source or \$content must be specified for apt_conf_snippet ${name}")
+  }
+  if $source != '' and $content != undef {
+    fail("Only one of \$source or \$content must specified for apt_conf_snippet ${name}")
+  }
+
+  if $source {
+    file { "/etc/apt/apt.conf.d/${name}":
+      ensure => $ensure,
+      source => $source,
+      notify => Exec["refresh_apt"],
+      owner => root, group => 0, mode => 0600;
+    }
+  }
+  else {
+    file { "/etc/apt/apt.conf.d/${name}":
+      ensure => $ensure,
+      content => $content,
+      notify => Exec["refresh_apt"],
+      owner => root, group => 0, mode => 0600;
+    }
+  }
+}
index 145bba648319c109d8280135e04ed642aea6ee80..0e4bd5ccac4e181b04893e1bbbb14ba427f403f9 100644 (file)
@@ -23,7 +23,8 @@ class apt {
     '': {
       config_file {
         # include main, security and backports
-        # additional sources could be included via an array
+        # additional sources should be included via the custom_sources_template
+        # define
         "/etc/apt/sources.list":
           content => template( "apt/$operatingsystem/sources.list.erb"),
           require => Package['lsb'];
@@ -37,11 +38,17 @@ class apt {
     }
   }
 
-  config_file {
-    # little default settings which keep the system sane
-    "/etc/apt/apt.conf.d/from_puppet":
-      content => "APT::Get::Show-Upgraded true;\nDSelect::Clean $real_apt_clean;\n",
-      before => Concatenated_file['/etc/apt/preferences'];
+  # 01autoremove already present by default
+  apt_conf_snippet{ "02show_upgraded":
+    source => ["puppet:///modules/site-apt/${fqdn}/02show_upgraded",
+               "puppet:///modules/site-apt/02show_upgraded",
+               "puppet:///modules/apt/02show_upgraded"]
+  }
+
+  apt_conf_snippet{ "03clean":
+    source => ["puppet:///modules/site-apt/${fqdn}/03clean",
+               "puppet:///modules/site-apt/03clean",
+               "puppet:///modules/apt/03clean"]
   }
 
   case $custom_preferences {
index ea0a29c86f146ca05943f09f64d7eb5dc52eeadf..30bda8a665ea61572a0ffc29b712d930cf8658f7 100644 (file)
@@ -10,9 +10,7 @@ class apt::proxy-client {
     default => $apt_proxy_port
   }
 
-  file { "/etc/apt/apt.conf.d/20proxy":
-    ensure => present,
-    content => "Acquire::http { Proxy \"http://$real_apt_proxy:$real_apt_proxy_port\"; };\n",
-    owner => root, group => 0, mode => 0644;
+  apt_conf_snippet { "20proxy":
+    content => template("apt/20proxy.erb"),
   }
 }
index e1080a09706db61671770198d4db1462d59174a6..6a0c685b488aa4e2d258c243baf08ca21f0445c9 100644 (file)
@@ -4,14 +4,11 @@ class apt::unattended_upgrades {
     require => undef,
   }
 
-  config_file {
-    "/etc/apt/apt.conf.d/50unattended-upgrades": 
-    source  => ["puppet:///modules/site-apt/50unattended-upgrades", 
-               "puppet:///modules/apt/50unattended-upgrades" ], 
+  apt_conf_snippet { "50unattended-upgrades":
+    source  => ["puppet:///modules/site-apt/50unattended-upgrades",
+               "puppet:///modules/apt/50unattended-upgrades" ],
 
-    # err: Could not run Puppet configuration client: Could not find dependent Config_file[apt_config] for Config_file[/etc/apt/apt.conf.d/50unattended-upgrades] at /etc/puppet/modules/apt/manifests/unattended_upgrades.pp:14
-      
-    #before => Config_file[apt_config],
+    before => Concatenated_file[apt_config],
     require => Package['unattended-upgrades'],
   }
 }
diff --git a/templates/20proxy.erb b/templates/20proxy.erb
new file mode 100644 (file)
index 0000000..e72319f
--- /dev/null
@@ -0,0 +1 @@
+Acquire::http { Proxy "http://<%= real_apt_proxy %>:<%= real_apt_proxy_port %>"; };