143d574edf
The override file in Debian based systems will only prevent the service from being started if the service has a configuration file[0] in /etc/init. Since not all services may have a config file, the better way to prevent services from starting as part of the installation process is to use a policy-rc.d file[1]. This change replaces the use of /etc/init/<servicename>.override with the creation of a /usr/sbin/policy-rc.d file durring the installation process. This change also includes an update to the galera module where we were previously utilizing the policy-rc.d method for mysql server. [0] http://manpages.ubuntu.com/manpages/trusty/man5/init.5.html [1] https://people.debian.org/~hmh/invokerc.d-policyrc.d-specification.txt Change-Id: I8e09e1403c554b2b8fae6fe915590d7235ce9b99 Closes-Bug: #1532331 Related-Blueprint: deploy-with-uca-packages
58 lines
2.0 KiB
Puppet
58 lines
2.0 KiB
Puppet
# == Type: tweaks::ubuntu_service_override
|
|
#
|
|
# Disable services from starting when the package is installed on Ubuntu OS
|
|
#
|
|
# == Parameters
|
|
#
|
|
# [*service_name*]
|
|
# The name of the service that is associated with the package being installed.
|
|
# Defaults to $name
|
|
#
|
|
# [*package_name*]
|
|
# The name of the package that is being installed that has a service to be
|
|
# prevented from being started as part of the installation process.
|
|
# Defaults to $name
|
|
#
|
|
define tweaks::ubuntu_service_override (
|
|
$service_name = $name,
|
|
$package_name = $name,
|
|
) {
|
|
if $::operatingsystem == 'Ubuntu' {
|
|
if ! is_pkg_installed($package_name) {
|
|
# https://people.debian.org/~hmh/invokerc.d-policyrc.d-specification.txt
|
|
# use policy-rc.d to really ensure services don't get started on
|
|
# installation as service override files are only used if a job
|
|
# configuration file exists (see man 5 init)
|
|
$policyrc_file = '/usr/sbin/policy-rc.d'
|
|
|
|
# use ensure resource as we only want a single instance of the
|
|
# policy-rc.d file in the catalog
|
|
ensure_resource('file', 'create-policy-rc.d', {
|
|
ensure => present,
|
|
path => $policyrc_file,
|
|
content => "#!/bin/bash\nexit 101",
|
|
mode => '0755',
|
|
owner => 'root',
|
|
group => 'root'
|
|
})
|
|
# use ensure resource as we only want a single remove exec in the catalog
|
|
ensure_resource('exec', 'remove-policy-rc.d', {
|
|
path => [ '/sbin', '/bin', '/usr/bin', '/usr/sbin' ],
|
|
command => "rm -f ${policyrc_file}",
|
|
onlyif => "test -f ${policyrc_file}",
|
|
})
|
|
|
|
File['create-policy-rc.d'] ->
|
|
Package <| name == $package_name |> ->
|
|
Exec['remove-policy-rc.d']
|
|
File['create-policy-rc.d'] ->
|
|
Package <| title == $package_name |> ->
|
|
Exec['remove-policy-rc.d']
|
|
Exec['remove-policy-rc.d'] ->
|
|
Service <| name == $service_name |>
|
|
Exec['remove-policy-rc.d'] ->
|
|
Service <| title == $service_name |>
|
|
}
|
|
}
|
|
}
|