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