diff --git a/modules/profile/manifests/github_runner/service.pp b/modules/profile/manifests/github_runner/service.pp index 131d777..e1cbf2b 100644 --- a/modules/profile/manifests/github_runner/service.pp +++ b/modules/profile/manifests/github_runner/service.pp @@ -11,6 +11,7 @@ $github_runner_user = $user $github_runner_group = $group $systemd_file = '/etc/systemd/system/actions-runner.service' + $service_check_file = '/usr/local/bin/actions-runner-check.sh' file { $systemd_file: ensure => file, content => template('profile/github_runner/actions-runner.service.erb'), @@ -20,6 +21,14 @@ notify => Exec['daemon-reload'], } + file { $service_check_file: + ensure => file, + content => template('profile/github_runner/actions-runner-check.sh.erb'), + owner => $user, + group => $group, + mode => 'a+x', + } + exec { 'daemon-reload': command => '/usr/bin/systemctl daemon-reload', refreshonly => true, @@ -46,4 +55,17 @@ user => 'root', minute => '*/5', } + + cron { 'check-status': + command => [ + 'bash', + $service_check_file, + ].join(' '), + environment => [ + 'PATH=/bin:/usr/bin:/usr/sbin:/usr/local/bin', + "MAILTO=${mailto}" + ], + user => 'root', + minute => '*/5', + } } diff --git a/modules/profile/templates/github_runner/actions-runner-check.sh.erb b/modules/profile/templates/github_runner/actions-runner-check.sh.erb new file mode 100644 index 0000000..32e1612 --- /dev/null +++ b/modules/profile/templates/github_runner/actions-runner-check.sh.erb @@ -0,0 +1,11 @@ +#!/bin/bash + +SERVICE="actions-runner" + +# Check if the service is active +if ! systemctl is-active --quiet $SERVICE; then + ih-aws autoscaling mark-unhealthy +fi +if systemctl is-failed --quiet $SERVICE; then + ih-aws autoscaling mark-unhealthy +fi