mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-26 06:31:04 +01:00
Implemented docker health check
This commit is contained in:
parent
dd8db239d6
commit
ad4a6f8bc0
@ -0,0 +1,7 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Check docker status
|
||||||
|
OnFailure=systemd-email@%n.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/bin/bash /home/administrator/scripts/docker-health-check/docker-health-check.sh
|
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
docker_ps_grep_unhealthy="$(docker ps | grep unhealthy)"
|
||||||
|
if [ -z "$docker_ps_grep_unhealthy" ]
|
||||||
|
then
|
||||||
|
echo "All docker containers are healthy."
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
echo "Some docker containers are unhealthy: $docker_ps_grep_unhealthy"
|
||||||
|
exit 1
|
||||||
|
fi
|
@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=starts docker-health-check.service
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=10:00
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
12
roles/native-docker-health-check/handlers/main.yml
Normal file
12
roles/native-docker-health-check/handlers/main.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
- name: "restart docker-health-check.service"
|
||||||
|
systemd:
|
||||||
|
name: docker-health-check.service
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
||||||
|
- name: "restart docker-health-check.timer"
|
||||||
|
systemd:
|
||||||
|
name: docker-health-check.timer
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
2
roles/native-docker-health-check/meta/main.yml
Normal file
2
roles/native-docker-health-check/meta/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
dependencies:
|
||||||
|
- native-systemd-email
|
22
roles/native-docker-health-check/tasks/main.yml
Normal file
22
roles/native-docker-health-check/tasks/main.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
- name: "create /home/administrator/scripts/docker-health-check/"
|
||||||
|
file:
|
||||||
|
path: "/home/administrator/scripts/docker-health-check"
|
||||||
|
state: directory
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: create docker-health-check.sh
|
||||||
|
copy:
|
||||||
|
src: docker-health-check.sh
|
||||||
|
dest: "/home/administrator/scripts/docker-health-check/docker-health-check.sh"
|
||||||
|
|
||||||
|
- name: create docker-health-check.service
|
||||||
|
copy:
|
||||||
|
src: docker-health-check.service
|
||||||
|
dest: "/etc/systemd/system/docker-health-check.service"
|
||||||
|
notify: restart docker-health-check.service
|
||||||
|
|
||||||
|
- name: create docker-health-check.timer
|
||||||
|
copy:
|
||||||
|
src: docker-health-check.timer
|
||||||
|
dest: "/etc/systemd/system/docker-health-check.timer"
|
||||||
|
notify: restart docker-health-check.timer
|
@ -1,3 +1,4 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
- native-docker-volume-backup
|
- native-docker-volume-backup
|
||||||
- native-user-administrator
|
- native-user-administrator
|
||||||
|
- native-docker-health-check
|
||||||
|
Loading…
Reference in New Issue
Block a user