Add health checking support for mirrors
[mirror/dsa-puppet.git] / modules / roles / manifests / mirror_health.pp
diff --git a/modules/roles/manifests/mirror_health.pp b/modules/roles/manifests/mirror_health.pp
new file mode 100644 (file)
index 0000000..3b0d149
--- /dev/null
@@ -0,0 +1,32 @@
+class roles::mirror_health (
+       $check_hosts    = [],
+       $check_service  = '',
+       $url            = '',
+       $check_interval = 60,
+) {
+       package { 'python3-requests':
+               ensure   => installed,
+       }
+
+        # XXX: avoid duplicating this?
+       file { '/usr/local/sbin/mirror-health':
+               source => 'puppet:///modules/roles/mirror_health/mirror-health',
+               owner  => 'root',
+               group  => 'root',
+               mode   => '0555',
+       }
+
+        file { "/etc/systemd/system/mirror-health-${check_service}.service":
+               owner   => 'root',
+               group   => 'root',
+               mode    => '0444',
+                content => template('roles/mirror-health.service.erb'),
+                notify  => Exec['systemctl daemon-reload'],
+        }
+
+        file { "/etc/systemd/system/multi-user.target.wants/mirror-health-${check_service}.service":
+               ensure => 'link',
+               target => "../mirror-health-${check_service}.service",
+               notify => Exec['systemctl daemon-reload'],
+       }
+}