Add healthcheck to ansible
This commit is contained in:
parent
68463c03f1
commit
1cb92e3825
13 changed files with 68 additions and 6 deletions
|
@ -6,6 +6,7 @@
|
||||||
- coder
|
- coder
|
||||||
- forgejo
|
- forgejo
|
||||||
- forgejo-runner
|
- forgejo-runner
|
||||||
|
- healthcheck
|
||||||
- homebox
|
- homebox
|
||||||
- influxdb
|
- influxdb
|
||||||
- jellyfin
|
- jellyfin
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
#!/usr/bin/sh
|
#!/usr/bin/sh
|
||||||
|
|
||||||
# Reduce pings to 60 minutes
|
|
||||||
[ $(date +'%M') -eq '00' ] || exit
|
|
||||||
|
|
||||||
cd /opt/ || exit
|
cd /opt/ || exit
|
||||||
|
|
||||||
hc_url="https://hc-ping.com/$MAIL_HC_UID"
|
hc_url="https://hc-ping.com/$MAIL_HC_UID"
|
|
@ -7,8 +7,7 @@ x-common-elements:
|
||||||
image: healthcheck
|
image: healthcheck
|
||||||
restart: never
|
restart: never
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- service.env
|
||||||
- .secret.env
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/:/opt
|
- ./data/:/opt
|
||||||
|
|
46
_ansible/roles/healthcheck/tasks/main.yml
Normal file
46
_ansible/roles/healthcheck/tasks/main.yml
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
---
|
||||||
|
- name: Deploy {{ svc.name }}
|
||||||
|
tags:
|
||||||
|
- healthcheck
|
||||||
|
block:
|
||||||
|
- import_tasks: steps/create-service-directory.yml
|
||||||
|
|
||||||
|
- name: Copy the docker-compose file
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: docker-compose.yml
|
||||||
|
dest: "{{ (service_path, 'docker-compose.yml') | path_join }}"
|
||||||
|
mode: '0644'
|
||||||
|
- name: Copy the Dockerfile
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: Dockerfile
|
||||||
|
dest: "{{ (service_path, 'Dockerfile') | path_join }}"
|
||||||
|
mode: '0644'
|
||||||
|
- name: Copy the data files
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: data
|
||||||
|
dest: "{{ service_path }}"
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Copy the system service
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: healthcheck@.service
|
||||||
|
dest: "/etc/systemd/system/healthcheck@.service"
|
||||||
|
mode: '0644'
|
||||||
|
become: true
|
||||||
|
- name: Copy the system timer
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: healthcheck@.timer
|
||||||
|
dest: "/etc/systemd/system/healthcheck@.timer"
|
||||||
|
mode: '0644'
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- import_tasks: steps/template-service-env.yml
|
||||||
|
|
||||||
|
- name: Build service
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: docker compose build --pull
|
||||||
|
chdir: "{{ service_path }}"
|
||||||
|
when:
|
||||||
|
- "'local-dev' != inventory_hostname"
|
||||||
|
register: cmd_result
|
||||||
|
changed_when: True
|
19
_ansible/roles/healthcheck/vars/main.yml
Normal file
19
_ansible/roles/healthcheck/vars/main.yml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
svc:
|
||||||
|
name: healthcheck
|
||||||
|
|
||||||
|
svc_env:
|
||||||
|
USER_AGENT: "healthcheck-bot for serguzim.net"
|
||||||
|
|
||||||
|
HTTP_HC_UID: "{{ vault_healthcheck.hc_uid.http }}"
|
||||||
|
|
||||||
|
MATRIX_SERVER: "https://matrix.msrg.cc"
|
||||||
|
MATRIX_SERVER_FEDTESTER: "msrg.cc"
|
||||||
|
MATRIX_HC_UID: "{{ vault_healthcheck.hc_uid.matrix }}"
|
||||||
|
MATRIX_TOKEN: "{{ vault_healthcheck.matrix.token }}"
|
||||||
|
MATRIX_ROOM: "{{ vault_healthcheck.matrix.room }}"
|
||||||
|
|
||||||
|
MAIL_HC_UID: "{{ vault_healthcheck.hc_uid.mail }}"
|
||||||
|
MAIL_HOST: "{{ mailer.host }}"
|
||||||
|
MAIL_PORT: "{{ mailer.port }}"
|
||||||
|
MAIL_USER: "{{ vault_healthcheck.mailer.user }}"
|
||||||
|
MAIL_PASS: "{{ vault_healthcheck.mailer.pass }}"
|
|
@ -15,7 +15,7 @@ svc_env:
|
||||||
|
|
||||||
ALLOWED_HOSTS: recipes.serguzim.me
|
ALLOWED_HOSTS: recipes.serguzim.me
|
||||||
SECRET_KEY: "{{ vault_tandoor.secret_key }}"
|
SECRET_KEY: "{{ vault_tandoor.secret_key }}"
|
||||||
TIMEZONE: "{{ timezone }}"
|
TZ: "{{ timezone }}"
|
||||||
|
|
||||||
DB_ENGINE: django.db.backends.postgresql
|
DB_ENGINE: django.db.backends.postgresql
|
||||||
DB_OPTIONS: "{\"sslmode\": \"require\"}"
|
DB_OPTIONS: "{\"sslmode\": \"require\"}"
|
||||||
|
|
Reference in a new issue