Make apt::preferences_snippet place files in /etc/apt/preferences.d
Since Debian Squeeze, apt supports a .d directory for preferences (pinning). Simplify management by just placing files inside this .d directory. This removes the need for concat and concat::fragment resources, so removes the dependency on the concat module. It also removes the need for a moduledir that was needed for the concat module magic, so we also get rid of the dependency on the common module. Signed-off-by: Gabriel Filion <lelutin@gmail.com>
This commit is contained in:
parent
978378623d
commit
8229505ecb
4 changed files with 16 additions and 26 deletions
4
README
4
README
|
@ -18,8 +18,6 @@ Ubuntu support is lagging behind but not absent either.
|
||||||
This module needs:
|
This module needs:
|
||||||
|
|
||||||
- the lsb module: git://labs.riseup.net/shared-lsb
|
- the lsb module: git://labs.riseup.net/shared-lsb
|
||||||
- the common module: git://labs.riseup.net/shared-common
|
|
||||||
- the concat module: git://labs.riseup.net/shared-concat
|
|
||||||
|
|
||||||
By default, on normal hosts, this module sets the configuration option
|
By default, on normal hosts, this module sets the configuration option
|
||||||
DSelect::Clean to 'auto'. On virtual servers, the value is set by default to
|
DSelect::Clean to 'auto'. On virtual servers, the value is set by default to
|
||||||
|
@ -383,7 +381,7 @@ upgrade_package { "perl":
|
||||||
Resources
|
Resources
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Concat[apt_config]
|
File['apt_config']
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
Use this resource to depend on or add to a completed apt configuration
|
Use this resource to depend on or add to a completed apt configuration
|
||||||
|
|
|
@ -138,10 +138,6 @@ class apt {
|
||||||
# backports uses the normal archive key now
|
# backports uses the normal archive key now
|
||||||
package { "debian-backports-keyring": ensure => absent }
|
package { "debian-backports-keyring": ensure => absent }
|
||||||
|
|
||||||
include common::moduledir
|
|
||||||
$apt_base_dir = "${common::moduledir::module_dir_path}/apt"
|
|
||||||
modules_dir { apt: }
|
|
||||||
|
|
||||||
if $custom_key_dir {
|
if $custom_key_dir {
|
||||||
file { "${apt_base_dir}/keys.d":
|
file { "${apt_base_dir}/keys.d":
|
||||||
source => "$custom_key_dir",
|
source => "$custom_key_dir",
|
||||||
|
@ -155,7 +151,7 @@ class apt {
|
||||||
}
|
}
|
||||||
if $custom_preferences != false {
|
if $custom_preferences != false {
|
||||||
Exec["custom_keys"] {
|
Exec["custom_keys"] {
|
||||||
before => Concat[apt_config],
|
before => File['apt_config'],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
class apt::preferences {
|
class apt::preferences {
|
||||||
|
|
||||||
concat::fragment{"apt_preferences_header":
|
$pref_contents = $custom_preferences ? {
|
||||||
content => $custom_preferences ? {
|
'' => $operatingsystem ? {
|
||||||
'' => $operatingsystem ? {
|
'debian' => template("apt/${operatingsystem}/preferences_${codename}.erb"),
|
||||||
'debian' => template("apt/${operatingsystem}/preferences_${codename}.erb"),
|
'ubuntu' => template("apt/${operatingsystem}/preferences_${codename}.erb"),
|
||||||
'ubuntu' => template("apt/${operatingsystem}/preferences_${codename}.erb"),
|
|
||||||
},
|
|
||||||
default => $custom_preferences
|
|
||||||
},
|
},
|
||||||
order => 00,
|
default => $custom_preferences
|
||||||
target => '/etc/apt/preferences',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
concat{'/etc/apt/preferences':
|
file { '/etc/apt/preferences':
|
||||||
alias => apt_config,
|
ensure => present,
|
||||||
|
alias => 'apt_config',
|
||||||
# only update together
|
# only update together
|
||||||
|
content => $pref_contents,
|
||||||
require => File["/etc/apt/sources.list"],
|
require => File["/etc/apt/sources.list"],
|
||||||
owner => root, group => 0, mode => 0644;
|
owner => root, group => 0, mode => 0644;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,9 @@ define apt::preferences_snippet(
|
||||||
fail("apt::preferences_snippet requires either a 'pin' or 'release' argument, not both")
|
fail("apt::preferences_snippet requires either a 'pin' or 'release' argument, not both")
|
||||||
}
|
}
|
||||||
|
|
||||||
include apt::preferences
|
file { "/etc/apt/preferences.d/${name}":
|
||||||
|
|
||||||
concat::fragment{"apt_preference_${name}":
|
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
target => '/etc/apt/preferences',
|
owner => root, group => 0, mode => 0644;
|
||||||
}
|
}
|
||||||
|
|
||||||
# This should really work in the same manner as sources_list and apt_conf
|
# This should really work in the same manner as sources_list and apt_conf
|
||||||
|
@ -37,19 +35,19 @@ define apt::preferences_snippet(
|
||||||
'': {
|
'': {
|
||||||
case $release {
|
case $release {
|
||||||
'': {
|
'': {
|
||||||
Concat::Fragment["apt_preference_${name}"]{
|
File["/etc/apt/preferences.d/${name}"]{
|
||||||
content => template("apt/preferences_snippet.erb")
|
content => template("apt/preferences_snippet.erb")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
Concat::Fragment["apt_preference_${name}"]{
|
File["/etc/apt/preferences.d/${name}"]{
|
||||||
content => template("apt/preferences_snippet_release.erb")
|
content => template("apt/preferences_snippet_release.erb")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
Concat::Fragment["apt_preference_${name}"]{
|
File["/etc/apt/preferences.d/${name}"]{
|
||||||
source => $source
|
source => $source
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue