mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Renamed health services
This commit is contained in:
2
roles/health-journalctl/README.md
Normal file
2
roles/health-journalctl/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# health-journalctl
|
||||
Checks journalctl for error messages
|
10
roles/health-journalctl/files/health-journalctl.sh
Normal file
10
roles/health-journalctl/files/health-journalctl.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
echo "Checking journalctl for error messages..."
|
||||
journalctl_errors="$(journalctl --since '1 day ago' --no-pager | grep -i 'error')"
|
||||
if [ ! -z "$journalctl_errors" ]
|
||||
then
|
||||
echo "Some errors where found: $journalctl_errors"
|
||||
exit 1
|
||||
fi
|
||||
echo "All docker containers are healthy."
|
||||
exit 0
|
13
roles/health-journalctl/handlers/main.yml
Normal file
13
roles/health-journalctl/handlers/main.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
- name: "reload health-journalctl.service"
|
||||
systemd:
|
||||
name: health-journalctl.service
|
||||
state: reloaded
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
||||
ignore_errors: true
|
||||
- name: "restart health-journalctl.timer"
|
||||
systemd:
|
||||
name: health-journalctl.timer
|
||||
state: restarted
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
2
roles/health-journalctl/meta/main.yml
Normal file
2
roles/health-journalctl/meta/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- systemd_notifier
|
22
roles/health-journalctl/tasks/main.yml
Normal file
22
roles/health-journalctl/tasks/main.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
- name: "create {{journalctl_health_check_folder}}"
|
||||
file:
|
||||
path: "{{journalctl_health_check_folder}}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: create health-journalctl.sh
|
||||
copy:
|
||||
src: health-journalctl.sh
|
||||
dest: "{{journalctl_health_check_folder}}health-journalctl.sh"
|
||||
|
||||
- name: create health-journalctl.service
|
||||
template:
|
||||
src: health-journalctl.service.j2
|
||||
dest: /etc/systemd/system/health-journalctl.service
|
||||
notify: reload health-journalctl.service
|
||||
|
||||
- name: create health-journalctl.timer
|
||||
template:
|
||||
src: health-journalctl.timer.j2
|
||||
dest: /etc/systemd/system/health-journalctl.timer
|
||||
notify: restart health-journalctl.timer
|
@@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=checking journalctl health
|
||||
OnFailure=systemd-notifier@%n.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash {{journalctl_health_check_folder}}health-journalctl.sh
|
10
roles/health-journalctl/templates/health-journalctl.timer.j2
Normal file
10
roles/health-journalctl/templates/health-journalctl.timer.j2
Normal file
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=starts health-journalctl.service
|
||||
|
||||
[Timer]
|
||||
OnCalendar={{on_calendar_journalctl_health_check}}
|
||||
RandomizedDelaySec={{randomized_delay_sec}}
|
||||
Persistent=false
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
1
roles/health-journalctl/vars/main.yml
Normal file
1
roles/health-journalctl/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
||||
journalctl_health_check_folder: "{{path_administrator_scripts}}health-journalctl/"
|
Reference in New Issue
Block a user