diff --git a/_ansible/node002.yml b/_ansible/node002.yml index e77ae33..76f34fb 100644 --- a/_ansible/node002.yml +++ b/_ansible/node002.yml @@ -6,6 +6,7 @@ - coder - forgejo - forgejo-runner + - healthcheck - homebox - influxdb - jellyfin diff --git a/healthcheck/Dockerfile b/_ansible/roles/healthcheck/files/Dockerfile similarity index 100% rename from healthcheck/Dockerfile rename to _ansible/roles/healthcheck/files/Dockerfile diff --git a/healthcheck/data/http b/_ansible/roles/healthcheck/files/data/http similarity index 100% rename from healthcheck/data/http rename to _ansible/roles/healthcheck/files/data/http diff --git a/healthcheck/data/mail b/_ansible/roles/healthcheck/files/data/mail similarity index 86% rename from healthcheck/data/mail rename to _ansible/roles/healthcheck/files/data/mail index 0df8515..650815d 100755 --- a/healthcheck/data/mail +++ b/_ansible/roles/healthcheck/files/data/mail @@ -1,8 +1,5 @@ #!/usr/bin/sh -# Reduce pings to 60 minutes -[ $(date +'%M') -eq '00' ] || exit - cd /opt/ || exit hc_url="https://hc-ping.com/$MAIL_HC_UID" diff --git a/healthcheck/data/mailcheck.template.mail b/_ansible/roles/healthcheck/files/data/mailcheck.template.mail similarity index 100% rename from healthcheck/data/mailcheck.template.mail rename to _ansible/roles/healthcheck/files/data/mailcheck.template.mail diff --git a/healthcheck/data/matrix b/_ansible/roles/healthcheck/files/data/matrix similarity index 100% rename from healthcheck/data/matrix rename to _ansible/roles/healthcheck/files/data/matrix diff --git a/healthcheck/data/template.msmtprc b/_ansible/roles/healthcheck/files/data/template.msmtprc similarity index 100% rename from healthcheck/data/template.msmtprc rename to _ansible/roles/healthcheck/files/data/template.msmtprc diff --git a/healthcheck/docker-compose.yml b/_ansible/roles/healthcheck/files/docker-compose.yml similarity index 93% rename from healthcheck/docker-compose.yml rename to _ansible/roles/healthcheck/files/docker-compose.yml index 5ef0298..145445c 100644 --- a/healthcheck/docker-compose.yml +++ b/_ansible/roles/healthcheck/files/docker-compose.yml @@ -7,8 +7,7 @@ x-common-elements: image: healthcheck restart: never env_file: - - .env - - .secret.env + - service.env volumes: - ./data/:/opt diff --git a/healthcheck/healthcheck@.service b/_ansible/roles/healthcheck/files/healthcheck@.service similarity index 100% rename from healthcheck/healthcheck@.service rename to _ansible/roles/healthcheck/files/healthcheck@.service diff --git a/healthcheck/healthcheck@.timer b/_ansible/roles/healthcheck/files/healthcheck@.timer similarity index 100% rename from healthcheck/healthcheck@.timer rename to _ansible/roles/healthcheck/files/healthcheck@.timer diff --git a/_ansible/roles/healthcheck/tasks/main.yml b/_ansible/roles/healthcheck/tasks/main.yml new file mode 100644 index 0000000..01a3cc9 --- /dev/null +++ b/_ansible/roles/healthcheck/tasks/main.yml @@ -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 diff --git a/_ansible/roles/healthcheck/vars/main.yml b/_ansible/roles/healthcheck/vars/main.yml new file mode 100644 index 0000000..7383d2d --- /dev/null +++ b/_ansible/roles/healthcheck/vars/main.yml @@ -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 }}" diff --git a/_ansible/roles/tandoor/vars/main.yml b/_ansible/roles/tandoor/vars/main.yml index 69ba476..c42560d 100644 --- a/_ansible/roles/tandoor/vars/main.yml +++ b/_ansible/roles/tandoor/vars/main.yml @@ -15,7 +15,7 @@ svc_env: ALLOWED_HOSTS: recipes.serguzim.me SECRET_KEY: "{{ vault_tandoor.secret_key }}" - TIMEZONE: "{{ timezone }}" + TZ: "{{ timezone }}" DB_ENGINE: django.db.backends.postgresql DB_OPTIONS: "{\"sslmode\": \"require\"}"