Add watchdog for docker cluster
This commit is contained in:
parent
750dc27d46
commit
26d4a5019b
26
main.yml
26
main.yml
@ -1,14 +1,14 @@
|
||||
---
|
||||
- hosts: iron-man.lan
|
||||
roles:
|
||||
- ssh
|
||||
- ubuntu
|
||||
|
||||
- hosts: prusa.lan
|
||||
roles:
|
||||
- ssh
|
||||
- octoprint
|
||||
- ubuntu
|
||||
#- hosts: iron-man.lan
|
||||
# roles:
|
||||
# - ssh
|
||||
# - ubuntu
|
||||
#
|
||||
#- hosts: prusa.lan
|
||||
# roles:
|
||||
# - ssh
|
||||
# - octoprint
|
||||
# - ubuntu
|
||||
|
||||
- hosts: docker_cluster
|
||||
roles:
|
||||
@ -16,7 +16,7 @@
|
||||
- docker-cluster
|
||||
- ubuntu
|
||||
|
||||
- hosts: router.lan
|
||||
roles:
|
||||
- router
|
||||
#- hosts: router.lan
|
||||
# roles:
|
||||
# - router
|
||||
|
||||
|
19
roles/docker-cluster/tasks/docker-watcher.yml
Normal file
19
roles/docker-cluster/tasks/docker-watcher.yml
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
- name: Create hostfile
|
||||
become: yes
|
||||
template:
|
||||
src: usr/local/sbin/check-docker.j2
|
||||
dest: /usr/local/sbin/check-docker
|
||||
|
||||
- name: Remove file (delete file)
|
||||
become: yes
|
||||
file:
|
||||
path: /usr/local/sbin/check-docker.j2
|
||||
state: absent
|
||||
|
||||
- name: create cron
|
||||
become: yes
|
||||
cron:
|
||||
name: "check docker"
|
||||
minute: "*/15"
|
||||
job: "/usr/local/sbin/check-docker"
|
@ -11,3 +11,4 @@
|
||||
|
||||
- import_tasks: hostfile.yml
|
||||
|
||||
- import_tasks: docker-watcher.yml
|
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker node inspect {{ ansible_hostname }} --format "{{ '{{' }} .Status.State {{ '}}' }}" | grep -q 'ready'
|
||||
|
||||
if [ $? == 1 ]; then
|
||||
echo "Docker is down restarting"
|
||||
service docker restart
|
||||
else
|
||||
echo "Docker is ok"
|
||||
fi
|
Loading…
Reference in New Issue
Block a user