Ensure proper removal of the client package
Signed-off-by: Ken Barber <ken@bob.sh>
This commit is contained in:
parent
fa82eec94b
commit
3ba3b6df54
1 changed files with 33 additions and 22 deletions
|
@ -1,30 +1,41 @@
|
|||
# PRIVATE CLASS: do not call directly
|
||||
class postgresql::server::install {
|
||||
$package_ensure = $postgresql::server::package_ensure
|
||||
$package_name = $postgresql::server::package_name
|
||||
$package_ensure = $postgresql::server::package_ensure
|
||||
$package_name = $postgresql::server::package_name
|
||||
$client_package_name = $postgresql::server::client_package_name
|
||||
|
||||
if($::operatingsystem == "Ubuntu" and $_package_ensure) {
|
||||
exec { "apt-get-autoremove-postgresql-server":
|
||||
command => "apt-get autoremove --force --yes ${package_name}",
|
||||
onlyif => "dpkg -l ${package_name} | grep -e '^ii'",
|
||||
# This is necessary to ensure that the extra client package that was
|
||||
# installed automatically by the server package is removed and all
|
||||
# of its dependencies are removed also. Without this later installation
|
||||
# of the native Ubuntu packages will fail.
|
||||
if($::operatingsystem == "Ubuntu" and $package_ensure == 'absent') {
|
||||
# This is an exec, because we want to invoke autoremove.
|
||||
#
|
||||
# An alternative would be to have a full list of packages, but that seemed
|
||||
# more problematic to maintain, not to mention the conflict with the
|
||||
# client class will create duplicate resources.
|
||||
exec { "apt-get-autoremove-postgresql-client":
|
||||
command => "apt-get autoremove --purge --yes ${client_package_name}",
|
||||
onlyif => "dpkg -l ${client_package_name} | grep -e '^ii'",
|
||||
logoutput => on_failure,
|
||||
}
|
||||
} else {
|
||||
$_package_ensure = $package_ensure ? {
|
||||
true => 'present',
|
||||
false => 'purged',
|
||||
'absent' => 'purged',
|
||||
default => $package_ensure,
|
||||
}
|
||||
|
||||
package { 'postgresql-server':
|
||||
ensure => $_package_ensure,
|
||||
name => $package_name,
|
||||
|
||||
# This is searched for to create relationships with the package repos, be
|
||||
# careful about its removal
|
||||
tag => 'postgresql',
|
||||
path => '/usr/bin:/bin:/usr/sbin/:/sbin',
|
||||
}
|
||||
}
|
||||
|
||||
$_package_ensure = $package_ensure ? {
|
||||
true => 'present',
|
||||
false => 'purged',
|
||||
'absent' => 'purged',
|
||||
default => $package_ensure,
|
||||
}
|
||||
|
||||
package { 'postgresql-server':
|
||||
ensure => $_package_ensure,
|
||||
name => $package_name,
|
||||
|
||||
# This is searched for to create relationships with the package repos, be
|
||||
# careful about its removal
|
||||
tag => 'postgresql',
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue