Renamed health services

This commit is contained in:
2023-11-16 15:32:29 +01:00
parent 04f69aefde
commit d9d6c8060a
47 changed files with 162 additions and 162 deletions

View File

@@ -0,0 +1,20 @@
#!/bin/sh
docker_ps_grep_unhealthy="$(docker ps --filter health=unhealthy --format '{{.Names}}')"
docker_ps_grep_exited="$(docker ps --filter status=exited --format '{{.Names}}')"
exitcode=0
if [ ! -z "$docker_ps_grep_unhealthy" ]
then
echo "Some docker containers are unhealthy: $docker_ps_grep_unhealthy"
exitcode=1
fi
if [ ! -z "$docker_ps_grep_exited" ]
then
echo "Some docker containers exited: $docker_ps_grep_exited"
exitcode=2
fi
if [ "$exitcode" -ne "0" ]
then
exit $exitcode
fi
echo "All docker containers are healthy."
exit

View File

@@ -0,0 +1,12 @@
- name: "reload health-docker.service"
systemd:
name: health-docker.service
state: reloaded
enabled: yes
daemon_reload: yes
- name: "restart health-docker.timer"
systemd:
name: health-docker.timer
state: restarted
enabled: yes
daemon_reload: yes

View File

@@ -0,0 +1,2 @@
dependencies:
- systemd_notifier

View File

@@ -0,0 +1,20 @@
- name: "create {{docker_health_check_folder}}"
file:
path: "{{docker_health_check_folder}}"
state: directory
mode: 0755
- name: create health-docker.sh
copy:
src: health-docker.sh
dest: "{{docker_health_check_folder}}health-docker.sh"
- name: create health-docker.service
template: src=health-docker.service.j2 dest=/etc/systemd/system/health-docker.service
notify: reload health-docker.service
- name: create health-docker.timer
template:
src: health-docker.timer.j2
dest: "/etc/systemd/system/health-docker.timer"
notify: restart health-docker.timer

View File

@@ -0,0 +1,7 @@
[Unit]
Description=Checking docker health
OnFailure=systemd-notifier@%n.service
[Service]
Type=oneshot
ExecStart=/bin/bash {{docker_health_check_folder}}health-docker.sh

View File

@@ -0,0 +1,10 @@
[Unit]
Description=starts health-docker.service
[Timer]
OnCalendar={{on_calendar_docker_health_check}}
RandomizedDelaySec={{randomized_delay_sec}}
Persistent=false
[Install]
WantedBy=timers.target

View File

@@ -0,0 +1 @@
docker_health_check_folder: "{{path_administrator_scripts}}health-docker/"