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.
This commit is contained in:
parent
636ae8541d
commit
d8a1e4ee9d
5 changed files with 17 additions and 14 deletions
|
@ -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",
|
||||
|
|
4
manifests/params.pp
Normal file
4
manifests/params.pp
Normal file
|
@ -0,0 +1,4 @@
|
|||
class apt::params {
|
||||
$root = '/etc/apt'
|
||||
$provider = '/usr/bin/apt-get'
|
||||
}
|
|
@ -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}",
|
||||
}
|
||||
|
|
|
@ -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":
|
||||
}
|
||||
|
|
|
@ -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}":
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue