2026-08-03 12:26:42 +08:00
|
|
|
---
|
2026-08-12 17:29:53 +08:00
|
|
|
- name: Validate known health-check profiles
|
2026-08-03 12:26:42 +08:00
|
|
|
ansible.builtin.assert:
|
|
|
|
|
that:
|
2026-08-12 17:29:53 +08:00
|
|
|
- item in healthcheck_profile_scripts
|
|
|
|
|
fail_msg: "Unsupported healthcheck_profile: {{ item }}"
|
|
|
|
|
loop: "{{ healthcheck_profiles }}"
|
2026-08-03 12:26:42 +08:00
|
|
|
|
|
|
|
|
- name: Install health-check directories
|
|
|
|
|
ansible.builtin.file:
|
|
|
|
|
path: "{{ item.path }}"
|
|
|
|
|
state: directory
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: "{{ item.mode }}"
|
|
|
|
|
loop:
|
|
|
|
|
- path: "{{ healthcheck_install_root }}"
|
|
|
|
|
mode: "0755"
|
|
|
|
|
- path: "{{ healthcheck_state_dir }}"
|
|
|
|
|
mode: "0750"
|
|
|
|
|
- path: "{{ healthcheck_log_dir }}"
|
|
|
|
|
mode: "0750"
|
|
|
|
|
|
|
|
|
|
- name: Install common health-check library
|
|
|
|
|
ansible.builtin.template:
|
|
|
|
|
src: health-common.sh.j2
|
|
|
|
|
dest: "{{ healthcheck_install_root }}/health-common.sh"
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: "0755"
|
|
|
|
|
|
2026-08-12 17:29:53 +08:00
|
|
|
- name: Install service health-check scripts
|
2026-08-03 12:26:42 +08:00
|
|
|
ansible.builtin.template:
|
2026-08-12 17:29:53 +08:00
|
|
|
src: "{{ healthcheck_profile_scripts[item] }}.j2"
|
|
|
|
|
dest: "{{ healthcheck_install_root }}/{{ healthcheck_profile_scripts[item] }}"
|
2026-08-03 12:26:42 +08:00
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: "0755"
|
2026-08-12 17:29:53 +08:00
|
|
|
loop: "{{ healthcheck_profiles }}"
|
2026-08-03 12:26:42 +08:00
|
|
|
|
|
|
|
|
- name: Install health-check dispatcher
|
|
|
|
|
ansible.builtin.template:
|
|
|
|
|
src: healthcheck-runner.sh.j2
|
|
|
|
|
dest: "{{ healthcheck_install_root }}/run"
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: "0755"
|
|
|
|
|
|
|
|
|
|
- name: Install health-check systemd unit
|
|
|
|
|
ansible.builtin.template:
|
|
|
|
|
src: vps-healthcheck.service.j2
|
|
|
|
|
dest: "/etc/systemd/system/{{ healthcheck_service_name }}.service"
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: "0644"
|
|
|
|
|
notify: Reload systemd
|
|
|
|
|
|
|
|
|
|
- name: Install persistent health-check timer
|
|
|
|
|
ansible.builtin.template:
|
|
|
|
|
src: vps-healthcheck.timer.j2
|
|
|
|
|
dest: "/etc/systemd/system/{{ healthcheck_service_name }}.timer"
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: "0644"
|
|
|
|
|
notify: Reload systemd
|
|
|
|
|
|
|
|
|
|
- name: Install health-check log rotation
|
|
|
|
|
ansible.builtin.template:
|
|
|
|
|
src: logrotate-vps-healthcheck.j2
|
|
|
|
|
dest: /etc/logrotate.d/vps-healthcheck
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: "0644"
|
|
|
|
|
|
|
|
|
|
- name: Enable health-check timer
|
|
|
|
|
ansible.builtin.systemd_service:
|
|
|
|
|
name: "{{ healthcheck_service_name }}.timer"
|
|
|
|
|
enabled: true
|
|
|
|
|
state: started
|
|
|
|
|
daemon_reload: true
|
|
|
|
|
|
|
|
|
|
- name: Flush health-check systemd changes
|
|
|
|
|
ansible.builtin.meta: flush_handlers
|