1 # service instance for Debian's mirror-health checker
3 # for each defined service, a daemon will regularly check if the
4 # local version of <url> matches the majority version among the
5 # set of all hosts that define a <service_name>.
7 # the result of this check is then exposed via <health_url>
9 # @param url URL to check for freshness on each host (normally a Release file)
10 # @param health_url URL to the health marker
11 # @param this_host_service_name this host's service name for this service.
12 # Other nodes will connect to this hostname to
13 # fetch url for checking.
14 # If this is undef, other hosts will not
16 # @param check_service name of this service
17 # @param check_interval how often to check
18 # @param ensure present or absent
19 define mirror_health::service (
22 Optional[String] $this_host_service_name = undef,
23 String $check_service = $name,
24 Integer $check_interval = 60,
25 Enum['present','absent'] $ensure = 'present',
29 $service_file = "/etc/systemd/system/mirror-health-${check_service}.service"
32 content => template('mirror_health/mirror-health.service.erb'),
33 notify => [Exec['systemctl daemon-reload'], Service["mirror-health-${check_service}"]],
36 $service_before = $ensure ? {
38 default => [ File[$service_file], ],
40 $service_subscribe = $ensure ? {
41 present => [ File[$service_file], ],
45 $ensure_service = $ensure ? {
49 $ensure_enable = $ensure ? {
53 service { "mirror-health-${check_service}":
54 ensure => $ensure_service,
55 enable => $ensure_enable,
56 require => Exec['systemctl daemon-reload'],
57 before => $service_before,
58 subscribe => $service_subscribe + [ File[ $mirror_health::script ] ],
61 $hosts_file = "${mirror_health::confdir}/${check_service}.hosts"
62 $tag = "mirror_health::service::${check_service}::hosts"
65 ensure_newline => true,
67 notify => Service["mirror-health-${check_service}"],
69 if $this_host_service_name and $ensure == 'present' {
70 @@concat::fragment { "mirror_health::service::${check_service}::hosts::${this_host_service_name}":
72 target => $hosts_file,
73 content => $this_host_service_name,
76 Concat::Fragment <<| tag == $tag |>>