From: Dan Bode Date: Mon, 30 May 2011 17:18:13 +0000 (-0700) Subject: Created a params class to hold global data. X-Git-Tag: 0.0.1~30 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=d8a1e4ee9d97a956c1823d644c715e98d9c5d27f;p=puppet-modules%2Fpuppetlabs-apt.git Created a params class to hold global data. - Removes coupling between global data and resources from apt class. - Makes it easier to organize things into stages. --- diff --git a/manifests/init.pp b/manifests/init.pp index c4df481..03ef116 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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 index 0000000..3c39288 --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,4 @@ +class apt::params { + $root = '/etc/apt' + $provider = '/usr/bin/apt-get' +} diff --git a/manifests/pin.pp b/manifests/pin.pp index e8b251f..d13193f 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -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}", } diff --git a/manifests/release.pp b/manifests/release.pp index cdd3da0..7e00dba 100644 --- a/manifests/release.pp +++ b/manifests/release.pp @@ -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": } diff --git a/manifests/source.pp b/manifests/source.pp index d6d93e4..7dee0a9 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -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}": }