From eccd9407270fd09fe888a156bc23f3be4137289d Mon Sep 17 00:00:00 2001 From: Vezpi Date: Tue, 14 Jul 2026 19:40:26 +0000 Subject: [PATCH] change: notification body --- .../opnsense/update_opnsense_ha_cluster.yml | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/ansible/opnsense/update_opnsense_ha_cluster.yml b/ansible/opnsense/update_opnsense_ha_cluster.yml index 6548f64..47b0ea3 100644 --- a/ansible/opnsense/update_opnsense_ha_cluster.yml +++ b/ansible/opnsense/update_opnsense_ha_cluster.yml @@ -391,6 +391,10 @@ vars: master: "{{ groups['opnsense_master'][0] }}" backup: "{{ groups['opnsense_backup'][0] }}" + m: "{{ hostvars[master] }}" + b: "{{ hostvars[backup] }}" + same_operation: "{{ m.firmware_status == b.firmware_status }}" + ansible.builtin.uri: url: "{{ ntfy_url }}/{{ ntfy_topic }}" method: POST @@ -398,13 +402,32 @@ password: "{{ lookup('env', 'NTFY_PASSWORD') }}" force_basic_auth: true body: | - OPNsense HA cluster {{ firmware_action }} completed successfully. - {% for host in [master, backup] %} - {% set h = hostvars[host] %} - {{ h.main_role }} ({{ host }}): {% if h.skip_update %}already on {{ h.firmware_current_version }}, skipped{% else %}{{ h.firmware_current_version }} → {{ h.firmware_target_value }}{% endif %}{{ "\n" if not loop.last else "" }} - {% endfor %} + {%- if same_operation -%} + {%- if m.skip_update | default(false) -%} + Both nodes already on {{ m.firmware_current_version }}, no action taken. + {%- else -%} + OPNsense cluster: {{ m.firmware_current_version }} → {{ m.firmware_target_value }} ({{ m.firmware_status }}) + {%- endif -%} + {%- else -%} + {%- if m.skip_update | default(false) -%} + MASTER ({{ master }}): already on {{ m.firmware_current_version }}, no action taken. + {%- else -%} + MASTER ({{ master }}): {{ m.firmware_current_version }} → {{ m.firmware_target_value }} ({{ m.firmware_status }}) + {%- endif %} + {{ '\n' }} + {%- if b.skip_update | default(false) -%} + BACKUP ({{ backup }}): already on {{ b.firmware_current_version }}, no action taken. + {%- else -%} + BACKUP ({{ backup }}): {{ b.firmware_current_version }} → {{ b.firmware_target_value }} ({{ b.firmware_status }}) + {%- endif -%} + {%- endif -%} headers: - Title: "OPNsense {{ firmware_action }} completed" - Priority: "default" - Tags: "white_check_mark" + Title: | + {%- if m.skip_update | default(false) and b.skip_update | default(false) -%} + OPNsense cluster — no {{ _action }} available + {%- else -%} + OPNsense cluster {{ _action }} completed + {%- endif -%} + Priority: "{{ 'min' if (m.skip_update | default(false) and b.skip_update | default(false)) else 'default' }}" + Tags: "{{ 'information_source' if (m.skip_update | default(false) and b.skip_update | default(false)) else 'white_check_mark' }}" when: ntfy_url is defined \ No newline at end of file