2a0413bb07bf55dfec5f2b1cada43fe7edbabd67
[mirror/dsa-puppet.git] / modules / roles / manifests / mirror_health.pp
1 define roles::mirror_health (
2         $check_hosts    = [],
3         $check_service  = '',
4         $url            = '',
5         $check_interval = 60,
6 ) {
7         package { 'python3-requests':
8                 ensure   => installed,
9         }
10
11         # XXX: avoid duplicating this?
12         file { '/usr/local/sbin/mirror-health':
13                 source => 'puppet:///modules/roles/mirror_health/mirror-health',
14                 owner  => 'root',
15                 group  => 'root',
16                 mode   => '0555',
17                 notify  => Service["mirror-health-${check_service}"],
18         }
19
20         file { "/etc/systemd/system/mirror-health-${check_service}.service":
21                 owner   => 'root',
22                 group   => 'root',
23                 mode    => '0444',
24                 content => template('roles/mirror-health.service.erb'),
25                 notify  => [Exec['systemctl daemon-reload'], Service["mirror-health-${check_service}"]],
26         }
27
28         file { "/etc/systemd/system/multi-user.target.wants/mirror-health-${check_service}.service":
29                 ensure => 'link',
30                 target => "../mirror-health-${check_service}.service",
31                 notify => Exec['systemctl daemon-reload'],
32         }
33
34         service { "mirror-health-${check_service}":
35                 ensure => running,
36         }
37 }