Commit dadd3104 authored by Peter Palfrader's avatar Peter Palfrader

Fix dependency loop in mirror_health when a service is set to absent: the...

Fix dependency loop in mirror_health when a service is set to absent:  the file need not notify the service as the service subscribes to the file if enable is present
parent 689a1da0
...@@ -28,11 +28,11 @@ define mirror_health::service ( ...@@ -28,11 +28,11 @@ define mirror_health::service (
$service_file = "/etc/systemd/system/mirror-health-${check_service}.service" $service_file = "/etc/systemd/system/mirror-health-${check_service}.service"
file { $service_file:
content => template('mirror_health/mirror-health.service.erb'),
notify => [Exec['systemctl daemon-reload'], Service["mirror-health-${check_service}"]],
}
# if we enable the service, we want the files before the service, so we
# subscribe the service to the files.
# if we remove the service, we want the service disabled before the files
# go away, so we say the service needs the files to be handled before.
$service_before = $ensure ? { $service_before = $ensure ? {
present => [], present => [],
default => [ File[$service_file], ], default => [ File[$service_file], ],
...@@ -41,7 +41,6 @@ define mirror_health::service ( ...@@ -41,7 +41,6 @@ define mirror_health::service (
present => [ File[$service_file], ], present => [ File[$service_file], ],
default => [], default => [],
} }
$ensure_service = $ensure ? { $ensure_service = $ensure ? {
present => running, present => running,
absent => stopped, absent => stopped,
...@@ -50,14 +49,21 @@ define mirror_health::service ( ...@@ -50,14 +49,21 @@ define mirror_health::service (
present => true, present => true,
absent => false, absent => false,
} }
file { $service_file:
ensure => $ensure,
content => template('mirror_health/mirror-health.service.erb'),
notify => Exec['systemctl daemon-reload'],
}
service { "mirror-health-${check_service}": service { "mirror-health-${check_service}":
ensure => $ensure_service, ensure => $ensure_service,
enable => $ensure_enable, enable => $ensure_enable,
require => Exec['systemctl daemon-reload'], notify => Exec['systemctl daemon-reload'],
before => $service_before, before => $service_before,
subscribe => $service_subscribe + [ File[ $mirror_health::script ] ], subscribe => $service_subscribe + [ File[ $mirror_health::script ] ],
} }
$hosts_file = "${mirror_health::confdir}/${check_service}.hosts" $hosts_file = "${mirror_health::confdir}/${check_service}.hosts"
$tag = "mirror_health::service::${check_service}::hosts" $tag = "mirror_health::service::${check_service}::hosts"
concat { $hosts_file: concat { $hosts_file:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment