74 lines
2.3 KiB
YAML
74 lines
2.3 KiB
YAML
|
|
---
|
||
|
|
# Everything here answers "is the service healthy" and records the answer.
|
||
|
|
# The Uptime Kuma specifics that used to surround it — an embedded Python script
|
||
|
|
# that created monitors over the API, a /tmp credentials file, token extraction,
|
||
|
|
# and a systemd Environment= rewrite — are gone. What reports where is now one
|
||
|
|
# variable, healthcheck_push_url. See the role README.
|
||
|
|
- name: Create healthcheck script directory
|
||
|
|
ansible.builtin.file:
|
||
|
|
path: "{{ healthcheck_script_dir }}"
|
||
|
|
state: directory
|
||
|
|
owner: root
|
||
|
|
group: root
|
||
|
|
mode: '0755'
|
||
|
|
|
||
|
|
- name: Create forgejo-runner healthcheck script
|
||
|
|
ansible.builtin.template:
|
||
|
|
src: healthcheck.sh.j2
|
||
|
|
dest: "{{ healthcheck_script_path }}"
|
||
|
|
owner: root
|
||
|
|
group: root
|
||
|
|
mode: '0755'
|
||
|
|
validate: "bash -n %s"
|
||
|
|
|
||
|
|
- name: Create healthcheck systemd service
|
||
|
|
ansible.builtin.template:
|
||
|
|
src: healthcheck.service.j2
|
||
|
|
dest: "/etc/systemd/system/{{ healthcheck_service_name }}.service"
|
||
|
|
owner: root
|
||
|
|
group: root
|
||
|
|
mode: '0644'
|
||
|
|
|
||
|
|
- name: Create healthcheck systemd timer
|
||
|
|
ansible.builtin.template:
|
||
|
|
src: healthcheck.timer.j2
|
||
|
|
dest: "/etc/systemd/system/{{ healthcheck_service_name }}.timer"
|
||
|
|
owner: root
|
||
|
|
group: root
|
||
|
|
mode: '0644'
|
||
|
|
|
||
|
|
- name: Reload systemd for healthcheck units
|
||
|
|
systemd:
|
||
|
|
daemon_reload: yes
|
||
|
|
|
||
|
|
- name: Enable and start healthcheck timer
|
||
|
|
systemd:
|
||
|
|
name: "{{ healthcheck_service_name }}.timer"
|
||
|
|
enabled: yes
|
||
|
|
state: started
|
||
|
|
|
||
|
|
- name: Test healthcheck script
|
||
|
|
command: "{{ healthcheck_script_path }}"
|
||
|
|
register: healthcheck_test
|
||
|
|
changed_when: false
|
||
|
|
|
||
|
|
- name: Verify healthcheck script works
|
||
|
|
assert:
|
||
|
|
that:
|
||
|
|
- healthcheck_test.rc == 0
|
||
|
|
fail_msg: "Healthcheck script failed to execute properly"
|
||
|
|
|
||
|
|
- name: Display deployment summary
|
||
|
|
debug:
|
||
|
|
msg: |
|
||
|
|
Forgejo Runner deployed successfully!
|
||
|
|
|
||
|
|
Runner Name: forgejo-runner-box
|
||
|
|
Instance: {{ forgejo_instance_url }}
|
||
|
|
Working Directory: {{ forgejo_runner_dir }}
|
||
|
|
Service: forgejo-runner.service ({{ runner_active.stdout }})
|
||
|
|
|
||
|
|
Healthcheck Monitor: {{ healthcheck_service_name }}
|
||
|
|
Healthcheck Interval: Every {{ healthcheck_interval_seconds }}s
|
||
|
|
Reporting to: {{ healthcheck_push_url | default('', true) | regex_replace('/api/push/.*', '/api/push/***') | default('(nowhere - set healthcheck_push_url)', true) }}
|