1 # base class for Debian's mirror-health checker
2 # @param url URL to check for freshness on each host (normally a Release file)
3 # @param health_url URL to the health marker
4 define mirror_health::service (
7 String $this_host_service_name = $::fqdn,
8 String $check_service = $name,
9 Integer $check_interval = 60,
10 Enum['present','absent'] $ensure = 'present',
14 $service_file = "/etc/systemd/system/mirror-health-${check_service}.service"
17 content => template('mirror_health/mirror-health.service.erb'),
18 notify => [Exec['systemctl daemon-reload'], Service["mirror-health-${check_service}"]],
21 $service_before = $ensure ? {
23 default => [ File[$service_file], ],
25 $service_subscribe = $ensure ? {
26 present => [ File[$service_file], ],
30 $ensure_service = $ensure ? {
34 $ensure_enable = $ensure ? {
38 service { "mirror-health-${check_service}":
39 ensure => $ensure_service,
40 enable => $ensure_enable,
41 require => Exec['systemctl daemon-reload'],
42 before => $service_before,
43 subscribe => $service_subscribe + [ File[ $mirror_health::script ] ],
46 $hosts_file = "${mirror_health::confdir}/${check_service}.hosts"
47 $tag = "mirror_health::service::${check_service}::hosts"
50 ensure_newline => true,
52 notify => Service["mirror-health-${check_service}"],
54 @@concat::fragment { "mirror_health::service::${check_service}::hosts::${this_host_service_name}":
56 target => $hosts_file,
57 content => $this_host_service_name,
59 Concat::Fragment <<| tag == $tag |>>