change: clearer ntfy notification
This commit is contained in:
@@ -21,11 +21,6 @@
|
|||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: "'HEALTH_OK' not in ceph_health.stdout"
|
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:
|
rescue:
|
||||||
|
|
||||||
- name: Send no ready notification
|
- name: Send no ready notification
|
||||||
@@ -69,6 +64,11 @@
|
|||||||
when: apt_check.changed
|
when: apt_check.changed
|
||||||
block:
|
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
|
- name: Enable maintenance mode
|
||||||
ansible.builtin.command: >
|
ansible.builtin.command: >
|
||||||
ha-manager crm-command node-maintenance enable {{ inventory_hostname_short }}
|
ha-manager crm-command node-maintenance enable {{ inventory_hostname_short }}
|
||||||
@@ -96,13 +96,6 @@
|
|||||||
upgrade: full
|
upgrade: full
|
||||||
autoremove: true
|
autoremove: true
|
||||||
autoclean: 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
|
- name: Disable Ceph rebalancing
|
||||||
ansible.builtin.command: ceph osd set noout
|
ansible.builtin.command: ceph osd set noout
|
||||||
|
|
||||||
@@ -118,6 +111,17 @@
|
|||||||
ansible.builtin.command: >
|
ansible.builtin.command: >
|
||||||
ha-manager crm-command node-maintenance disable {{ inventory_hostname_short }}
|
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
|
- name: Wait for Ceph to be healthy
|
||||||
ansible.builtin.command: ceph health
|
ansible.builtin.command: ceph health
|
||||||
register: ceph_status
|
register: ceph_status
|
||||||
@@ -138,7 +142,7 @@
|
|||||||
force_basic_auth: true
|
force_basic_auth: true
|
||||||
body: Update failed on {{ inventory_hostname_short }}
|
body: Update failed on {{ inventory_hostname_short }}
|
||||||
headers:
|
headers:
|
||||||
Title: "Proxmox Update Failed"
|
Title: "Proxmox VE Update Failed"
|
||||||
Priority: "5"
|
Priority: "5"
|
||||||
Tags: "x"
|
Tags: "x"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
@@ -154,6 +158,10 @@
|
|||||||
hosts: localhost
|
hosts: localhost
|
||||||
tasks:
|
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
|
- name: Send success notification
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: "{{ ntfy_url }}/{{ ntfy_topic }}"
|
url: "{{ ntfy_url }}/{{ ntfy_topic }}"
|
||||||
@@ -162,15 +170,23 @@
|
|||||||
password: "{{ lookup('env', 'NTFY_PASSWORD') }}"
|
password: "{{ lookup('env', 'NTFY_PASSWORD') }}"
|
||||||
force_basic_auth: true
|
force_basic_auth: true
|
||||||
body: |
|
body: |
|
||||||
{% if hostvars[groups['nodes'][0]].pve_current_version.stdout == hostvars[groups['nodes'][0]].pve_new_version.stdout %}
|
{% set updated_nodes = [] %}
|
||||||
Version unchanged ({{ hostvars[groups['nodes'][0]].pve_new_version.stdout }})
|
{% 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 %}
|
{% else %}
|
||||||
Old version: {{ pve_current_version.stdout }}
|
The following nodes were updated:
|
||||||
New version: {{ pve_new_version.stdout }}
|
{% for node in updated_nodes %}
|
||||||
|
- {{ hostvars[node].inventory_hostname_short }}: {{ hostvars[node].update_report.old }} → {{ hostvars[node].update_report.new }}
|
||||||
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
headers:
|
headers:
|
||||||
Title: "Proxmox Update Completed"
|
Title: "Proxmox VE Update Report"
|
||||||
Priority: "3"
|
Priority: "{{ '2' if not updates_performed else '3' }}"
|
||||||
Tags: "white_check_mark"
|
Tags: "white_check_mark"
|
||||||
when: ntfy_url is defined
|
when: ntfy_url is defined
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user