change: clearer ntfy notification

This commit is contained in:
2026-06-08 07:43:52 +00:00
parent 568c514d3f
commit 8f2494d080

View File

@@ -21,11 +21,6 @@
changed_when: false
failed_when: "'HEALTH_OK' not in ceph_health.stdout"
- name: Get version before upgrade
ansible.builtin.shell: pveversion | awk -F'/' '{print $2}'
register: pve_current_version
changed_when: false
rescue:
- name: Send no ready notification
@@ -69,6 +64,11 @@
when: apt_check.changed
block:
- name: Get version before upgrade
ansible.builtin.shell: pveversion | awk -F'/' '{print $2}'
register: pve_current_version
changed_when: false
- name: Enable maintenance mode
ansible.builtin.command: >
ha-manager crm-command node-maintenance enable {{ inventory_hostname_short }}
@@ -96,13 +96,6 @@
upgrade: full
autoremove: true
autoclean: true
- name: Get version after upgrade
ansible.builtin.shell: pveversion | awk -F'/' '{print $2}'
register: pve_new_version
delegate_to: "{{ groups['nodes'][0] }}"
changed_when: false
- name: Disable Ceph rebalancing
ansible.builtin.command: ceph osd set noout
@@ -118,6 +111,17 @@
ansible.builtin.command: >
ha-manager crm-command node-maintenance disable {{ inventory_hostname_short }}
- name: Get version after upgrade
ansible.builtin.shell: pveversion | awk -F'/' '{print $2}'
register: pve_new_version
changed_when: false
- name: Save update report
ansible.builtin.set_fact:
update_report:
old: "{{ pve_old_version.stdout }}"
new: "{{ pve_new_version.stdout }}"
- name: Wait for Ceph to be healthy
ansible.builtin.command: ceph health
register: ceph_status
@@ -138,7 +142,7 @@
force_basic_auth: true
body: Update failed on {{ inventory_hostname_short }}
headers:
Title: "Proxmox Update Failed"
Title: "Proxmox VE Update Failed"
Priority: "5"
Tags: "x"
delegate_to: localhost
@@ -154,6 +158,10 @@
hosts: localhost
tasks:
- name: Determine if updates occurred
ansible.builtin.set_fact:
updates_performed: "{{ groups['nodes'] | map('extract', hostvars) | selectattr('update_report', 'defined') | list | length > 0 }}"
- name: Send success notification
ansible.builtin.uri:
url: "{{ ntfy_url }}/{{ ntfy_topic }}"
@@ -162,15 +170,23 @@
password: "{{ lookup('env', 'NTFY_PASSWORD') }}"
force_basic_auth: true
body: |
{% if hostvars[groups['nodes'][0]].pve_current_version.stdout == hostvars[groups['nodes'][0]].pve_new_version.stdout %}
Version unchanged ({{ hostvars[groups['nodes'][0]].pve_new_version.stdout }})
{% set updated_nodes = [] %}
{% for node in groups['nodes'] %}
{% if hostvars[node].update_report is defined %}
{% set _ = updated_nodes.append(node) %}
{% endif %}
{% endfor %}
{% if updated_nodes | length == 0 %}
No updates available on the cluster.
{% else %}
Old version: {{ pve_current_version.stdout }}
New version: {{ pve_new_version.stdout }}
The following nodes were updated:
{% for node in updated_nodes %}
- {{ hostvars[node].inventory_hostname_short }}: {{ hostvars[node].update_report.old }} → {{ hostvars[node].update_report.new }}
{% endfor %}
{% endif %}
headers:
Title: "Proxmox Update Completed"
Priority: "3"
Title: "Proxmox VE Update Report"
Priority: "{{ '2' if not updates_performed else '3' }}"
Tags: "white_check_mark"
when: ntfy_url is defined