]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Created a params class to hold global data.
authorDan Bode <dan@puppetlabs.com>
Mon, 30 May 2011 17:18:13 +0000 (10:18 -0700)
committerDan Bode <dan@puppetlabs.com>
Mon, 30 May 2011 17:24:58 +0000 (10:24 -0700)
- Removes coupling between global data and
  resources from apt class.
- Makes it easier to organize things into stages.

manifests/init.pp
manifests/params.pp [new file with mode: 0644]
manifests/pin.pp
manifests/release.pp
manifests/source.pp

index c4df481dd35d2377afa5c340362307ead0cb1efc..03ef116193745f4f52f842b27483eb3c79b53bc5 100644 (file)
@@ -19,8 +19,8 @@ class apt(
   $always_apt_update = false
 ) {
 
-       $root = '/etc/apt'
-       $provider = '/usr/bin/apt-get'
+  include apt::params
+
   $refresh_only_apt_update = $always_apt_update? {
     true => false,
     false => true
@@ -29,19 +29,19 @@ class apt(
   package { "python-software-properties": }
 
        file { "sources.list":
-               name => "${root}/sources.list",
                ensure => present,
                owner => root,
                group => root,
                mode => 644,
        }
+    name => "${apt::params::root}/sources.list",
 
        file { "sources.list.d":
-               name => "${root}/sources.list.d",
                ensure => directory,
                owner => root,
                group => root,
        }
+    name => "${apt::params::root}/sources.list.d",
 
   exec { "apt_update":
     command => "${apt::params::provider} update",
diff --git a/manifests/params.pp b/manifests/params.pp
new file mode 100644 (file)
index 0000000..3c39288
--- /dev/null
@@ -0,0 +1,4 @@
+class apt::params {
+  $root = '/etc/apt'
+  $provider = '/usr/bin/apt-get'
+}
index e8b251f7c882c60a413ecafa60509fb1d1230b99..d13193f315fc654109f5b7ab9a172f8a3afd9761 100644 (file)
@@ -6,15 +6,14 @@ define apt::pin(
        $priority = 0
 ) {
 
-       include apt
-
        file { "${name}.pref":
-               name => "${apt::root}/preferences.d/${name}",
                ensure => file,
                owner => root,
                group => root,
                mode => 644,
                content => "# ${name}\nPackage: ${packages}\nPin: release a=${name}\nPin-Priority: ${priority}",
        }
+  include apt::params
 
+    name => "${apt::params::root}/preferences.d/${name}",
 }
index cdd3da025dc5fdbff472a7371e58e24c82c63c60..7e00dba642e79483624272f521c6c58ee4d01332 100644 (file)
@@ -3,12 +3,13 @@
 define apt::release (
 
 ) {
-       include apt
 
-       file { "${apt::root}/apt.conf.d/01release":
                owner => root,
                group => root,
                mode => 644,
                content => "APT::Default-Release \"${name}\";"
        }
+  include apt::params
+
+  file { "${apt::params::root}/apt.conf.d/01release":
 }
index d6d93e488691be5ce66cf176071d306a9ddeaad8..7dee0a985f4fa96f10cf73a5efdb5f21c0e96688 100644 (file)
@@ -12,10 +12,7 @@ define apt::source(
        $pin = false
 ) {
 
-       include apt
-
        file { "${name}.list":
-               name => "${apt::root}/sources.list.d/${name}.list",
                ensure => file,
                owner => root,
                group => root,
@@ -28,13 +25,11 @@ define apt::source(
        }
 
        exec { "${name} apt update":
-               command => "${apt::provider} update",
                subscribe => File["${name}.list"],
                refreshonly => true,
        }
 
        if $required_packages != false {
-               exec { "${apt::provider} -y install ${required_packages}":
                        subscribe => File["${name}.list"],
                        refreshonly => true,
                }
@@ -46,5 +41,9 @@ define apt::source(
                        before => File["${name}.list"],
                }
        }
+  include apt::params
 
+    name => "${apt::params::root}/sources.list.d/${name}.list",
+    command => "${apt::params::provider} update",
+    exec { "${apt::params::provider} -y install ${required_packages}":
 }