X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fmirror_health%2Fmanifests%2Fservice.pp;h=24c6d0da72688d1d0a8c7710d0104981f570b5d1;hb=dadd310402bb0fe101164395dcb22deb064b35a1;hp=f0df429cc64546d555f4d3636da8417d4ef4c725;hpb=7349d0632d78e3edd1c10d95a310e71e19e2c0d5;p=mirror%2Fdsa-puppet.git diff --git a/modules/mirror_health/manifests/service.pp b/modules/mirror_health/manifests/service.pp index f0df429cc..24c6d0da7 100644 --- a/modules/mirror_health/manifests/service.pp +++ b/modules/mirror_health/manifests/service.pp @@ -1,10 +1,25 @@ -# base class for Debian's mirror-health checker +# service instance for Debian's mirror-health checker +# +# for each defined service, a daemon will regularly check if the +# local version of matches the majority version among the +# set of all hosts that define a . +# +# the result of this check is then exposed via +# # @param url URL to check for freshness on each host (normally a Release file) # @param health_url URL to the health marker +# @param this_host_service_name this host's service name for this service. +# Other nodes will connect to this hostname to +# fetch url for checking. +# If this is undef, other hosts will not +# check this host. +# @param check_service name of this service +# @param check_interval how often to check +# @param ensure present or absent define mirror_health::service ( String $url, String $health_url, - String $this_host_service_name = $::fqdn, + Optional[String] $this_host_service_name = undef, String $check_service = $name, Integer $check_interval = 60, Enum['present','absent'] $ensure = 'present', @@ -13,11 +28,11 @@ define mirror_health::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 ? { present => [], default => [ File[$service_file], ], @@ -26,7 +41,6 @@ define mirror_health::service ( present => [ File[$service_file], ], default => [], } - $ensure_service = $ensure ? { present => running, absent => stopped, @@ -35,14 +49,21 @@ define mirror_health::service ( present => true, 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}": ensure => $ensure_service, enable => $ensure_enable, - require => Exec['systemctl daemon-reload'], + notify => Exec['systemctl daemon-reload'], before => $service_before, subscribe => $service_subscribe + [ File[ $mirror_health::script ] ], } + $hosts_file = "${mirror_health::confdir}/${check_service}.hosts" $tag = "mirror_health::service::${check_service}::hosts" concat { $hosts_file: @@ -51,10 +72,12 @@ define mirror_health::service ( mode => '0444', notify => Service["mirror-health-${check_service}"], } - @@concat::fragment { "mirror_health::service::${check_service}::hosts::${this_host_service_name}": - tag => $tag, - target => $hosts_file, - content => $this_host_service_name, + if $this_host_service_name and $ensure == 'present' { + @@concat::fragment { "mirror_health::service::${check_service}::hosts::${this_host_service_name}": + tag => $tag, + target => $hosts_file, + content => $this_host_service_name, + } } Concat::Fragment <<| tag == $tag |>> }