Use ensure_packages to avoid problems with puppet redeclaring resources
[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         ensure_packages(['python3-requests'], { ensure => 'installed' })
9
10         # XXX: avoid duplicating this?
11         file { '/usr/local/sbin/mirror-health':
12                 source => 'puppet:///modules/roles/mirror_health/mirror-health',
13                 owner  => 'root',
14                 group  => 'root',
15                 mode   => '0555',
16                 notify  => Service["mirror-health-${check_service}"],
17         }
18
19         file { "/etc/systemd/system/mirror-health-${check_service}.service":
20                 owner   => 'root',
21                 group   => 'root',
22                 mode    => '0444',
23                 content => template('roles/mirror-health.service.erb'),
24                 notify  => [Exec['systemctl daemon-reload'], Service["mirror-health-${check_service}"]],
25         }
26
27         file { "/etc/systemd/system/multi-user.target.wants/mirror-health-${check_service}.service":
28                 ensure => 'link',
29                 target => "../mirror-health-${check_service}.service",
30                 notify => Exec['systemctl daemon-reload'],
31         }
32
33         service { "mirror-health-${check_service}":
34                 require => Exec['systemctl daemon-reload'],
35                 ensure  => running,
36         }
37 }