forked from jakub/ansible
Refactor health check playbook to ensure script existence before upload and simplify task structure
This commit is contained in:
@@ -1,17 +1,24 @@
|
|||||||
---
|
---
|
||||||
- name: Upload and run stack health checks
|
- name: Upload and run stack health checks
|
||||||
hosts: proxmox
|
hosts: proxmox
|
||||||
become: true
|
gather_facts: false
|
||||||
|
become: false
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
health_script_path: /data/compose/nextcloud/stack-health.sh
|
health_script_path: /data/compose/nextcloud/stack-health.sh
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: Ensure script exists (upload if missing)
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ health_script_path }}"
|
||||||
|
register: hs
|
||||||
|
|
||||||
- name: Upload stack-health.sh
|
- name: Upload stack-health.sh
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: files/stack-health.sh
|
src: files/stack-health.sh
|
||||||
dest: "{{ health_script_path }}"
|
dest: "{{ health_script_path }}"
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
|
when: not hs.stat.exists
|
||||||
|
|
||||||
- name: Run stack-health.sh
|
- name: Run stack-health.sh
|
||||||
ansible.builtin.shell: "{{ health_script_path }}"
|
ansible.builtin.shell: "{{ health_script_path }}"
|
||||||
@@ -23,7 +30,7 @@
|
|||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "{{ health.stdout | default('no stdout') }}"
|
msg: "{{ health.stdout | default('no stdout') }}"
|
||||||
|
|
||||||
- name: Fail if checks failed (rc != 0)
|
- name: Fail if checks failed
|
||||||
ansible.builtin.fail:
|
ansible.builtin.fail:
|
||||||
msg: "Health checks failed"
|
msg: "Health checks failed"
|
||||||
when: health.rc != 0
|
when: health.rc != 0
|
||||||
Reference in New Issue
Block a user