93567aef4a
when updating or installing newer packages with apt::force and you have changed previous configuration files aptitude or apt-get will prompt what to do. You can suppress that by pre-define the action with cfg_files parameter (new, old or unchanged and its backward compatible if not defined). With a second optional parameter cfg_missing you can force your provider to install missing configuration files as well. Signed-off-by: Martin Seener <martin@seener.de> apt::force: Changed selectors used in force.pp to case statements; refs #module-1306 Signed-off-by: Martin Seener <martin@seener.de> apt::force: rspec: fixed the failing tests and added validate_re for cfg_files and validate_bool for cfg_missing. Also removed default values for both case statements and only allow pre-defined values or true/false. Furthermore enhanced the README refs #module-1306 Was able to fix the failing rspec tests for the patch. Thanks to Morgan Haskel. Signed-off-by: Martin Seener <martin@seener.de> Despite the puppetlabs-stdlib documentation says validation_re supports 3 arguments the tests failed telling that only 2 are supported. Fixed this by removing the 3 optional argument; refs #modules-1306 Signed-off-by: Martin Seener <martin.seener@barzahlen.de> apt::force: updated readme refs #module-1306 Signed-off-by: Martin Seener <martin@seener.de>
59 lines
1.8 KiB
Puppet
59 lines
1.8 KiB
Puppet
# force.pp
|
|
# force a package from a specific release
|
|
|
|
define apt::force(
|
|
$release = false,
|
|
$version = false,
|
|
$timeout = 300,
|
|
$cfg_files = 'none',
|
|
$cfg_missing = false,
|
|
) {
|
|
|
|
validate_re($cfg_files, ['^new', '^old', '^unchanged', '^none'])
|
|
validate_bool($cfg_missing)
|
|
|
|
$provider = $apt::params::provider
|
|
|
|
$version_string = $version ? {
|
|
false => undef,
|
|
default => "=${version}",
|
|
}
|
|
|
|
$release_string = $release ? {
|
|
false => undef,
|
|
default => "-t ${release}",
|
|
}
|
|
|
|
case $cfg_files {
|
|
'new': { $config_files = '-o Dpkg::Options::="--force-confnew"' }
|
|
'old': { $config_files = '-o Dpkg::Options::="--force-confold"' }
|
|
'unchanged': { $config_files = '-o Dpkg::Options::="--force-confdef"' }
|
|
'none': { $config_files = '' }
|
|
}
|
|
|
|
case $cfg_missing {
|
|
true: { $config_missing = '-o Dpkg::Options::="--force-confmiss"' }
|
|
false: { $config_missing = '' }
|
|
}
|
|
|
|
if $version == false {
|
|
if $release == false {
|
|
$install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'"
|
|
} else {
|
|
# If installed version and candidate version differ, this check returns 1 (false).
|
|
$install_check = "/usr/bin/test \$(/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1"
|
|
}
|
|
} else {
|
|
if $release == false {
|
|
$install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'"
|
|
} else {
|
|
$install_check = "/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -q 'Installed: ${version}'"
|
|
}
|
|
}
|
|
|
|
exec { "${provider} -y ${config_files} ${config_missing} ${release_string} install ${name}${version_string}":
|
|
unless => $install_check,
|
|
logoutput => 'on_failure',
|
|
timeout => $timeout,
|
|
}
|
|
}
|