change: use check mode to verify updates available
This commit is contained in:
@@ -55,68 +55,77 @@
|
|||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
|
||||||
- name: Enable maintenance mode
|
- name: Refresh repositories
|
||||||
ansible.builtin.command: >
|
|
||||||
ha-manager crm-command node-maintenance enable {{ inventory_hostname_short }}
|
|
||||||
|
|
||||||
- name: Wait for LXCs to leave node
|
|
||||||
ansible.builtin.shell: |
|
|
||||||
pct list | awk 'NR>1 && $2=="running" {count++} END {print count+0}'
|
|
||||||
register: lxc_count
|
|
||||||
changed_when: false
|
|
||||||
until: lxc_count.stdout | int == 0
|
|
||||||
retries: 60
|
|
||||||
delay: 15
|
|
||||||
|
|
||||||
- name: Wait for VMs to leave node
|
|
||||||
ansible.builtin.shell: |
|
|
||||||
qm list | awk 'NR>1 && $3=="running" {count++} END {print count+0}'
|
|
||||||
register: vm_count
|
|
||||||
changed_when: false
|
|
||||||
until: vm_count.stdout | int == 0
|
|
||||||
retries: 60
|
|
||||||
delay: 15
|
|
||||||
|
|
||||||
- name: Update packages
|
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
update_cache: true
|
||||||
upgrade: full
|
|
||||||
autoremove: true
|
|
||||||
autoclean: true
|
|
||||||
register: update_packages
|
|
||||||
|
|
||||||
- name: Get version after upgrade
|
- name: Check if upgrades are available
|
||||||
ansible.builtin.shell: pveversion | awk -F'/' '{print $2}'
|
ansible.builtin.apt:
|
||||||
register: pve_new_version
|
upgrade: dist
|
||||||
delegate_to: "{{ groups['nodes'][0] }}"
|
check_mode: true
|
||||||
changed_when: false
|
register: apt_check
|
||||||
|
|
||||||
- when: update_packages.changed
|
- name: Proceed if updates are available
|
||||||
|
when: not apt_check.changed
|
||||||
block:
|
block:
|
||||||
|
|
||||||
- name: Disable Ceph rebalancing
|
- name: Enable maintenance mode
|
||||||
ansible.builtin.command: ceph osd set noout
|
ansible.builtin.command: >
|
||||||
|
ha-manager crm-command node-maintenance enable {{ inventory_hostname_short }}
|
||||||
|
|
||||||
- name: Reboot node
|
- name: Wait for LXCs to leave node
|
||||||
ansible.builtin.reboot:
|
ansible.builtin.shell: |
|
||||||
reboot_timeout: 900
|
pct list | awk 'NR>1 && $2=="running" {count++} END {print count+0}'
|
||||||
post_reboot_delay: 30
|
register: lxc_count
|
||||||
|
changed_when: false
|
||||||
|
until: lxc_count.stdout | int == 0
|
||||||
|
retries: 60
|
||||||
|
delay: 15
|
||||||
|
|
||||||
- name: Enable Ceph rebalancing
|
- name: Wait for VMs to leave node
|
||||||
ansible.builtin.command: ceph osd unset noout
|
ansible.builtin.shell: |
|
||||||
|
qm list | awk 'NR>1 && $3=="running" {count++} END {print count+0}'
|
||||||
|
register: vm_count
|
||||||
|
changed_when: false
|
||||||
|
until: vm_count.stdout | int == 0
|
||||||
|
retries: 60
|
||||||
|
delay: 15
|
||||||
|
|
||||||
- name: Disable maintenance mode
|
- name: Update packages
|
||||||
ansible.builtin.command: >
|
ansible.builtin.apt:
|
||||||
ha-manager crm-command node-maintenance disable {{ inventory_hostname_short }}
|
upgrade: full
|
||||||
|
autoremove: true
|
||||||
|
autoclean: true
|
||||||
|
|
||||||
- name: Wait for Ceph to be healthy
|
- name: Get version after upgrade
|
||||||
ansible.builtin.command: ceph health
|
ansible.builtin.shell: pveversion | awk -F'/' '{print $2}'
|
||||||
register: ceph_status
|
register: pve_new_version
|
||||||
changed_when: false
|
delegate_to: "{{ groups['nodes'][0] }}"
|
||||||
until: "'HEALTH_OK' in ceph_status.stdout"
|
changed_when: false
|
||||||
retries: 60
|
|
||||||
delay: 15
|
- name: Disable Ceph rebalancing
|
||||||
delegate_to: "{{ groups['nodes'][0] }}"
|
ansible.builtin.command: ceph osd set noout
|
||||||
|
|
||||||
|
- name: Reboot node
|
||||||
|
ansible.builtin.reboot:
|
||||||
|
reboot_timeout: 900
|
||||||
|
post_reboot_delay: 30
|
||||||
|
|
||||||
|
- name: Enable Ceph rebalancing
|
||||||
|
ansible.builtin.command: ceph osd unset noout
|
||||||
|
|
||||||
|
- name: Disable maintenance mode
|
||||||
|
ansible.builtin.command: >
|
||||||
|
ha-manager crm-command node-maintenance disable {{ inventory_hostname_short }}
|
||||||
|
|
||||||
|
- name: Wait for Ceph to be healthy
|
||||||
|
ansible.builtin.command: ceph health
|
||||||
|
register: ceph_status
|
||||||
|
changed_when: false
|
||||||
|
until: "'HEALTH_OK' in ceph_status.stdout"
|
||||||
|
retries: 60
|
||||||
|
delay: 15
|
||||||
|
delegate_to: "{{ groups['nodes'][0] }}"
|
||||||
|
|
||||||
rescue:
|
rescue:
|
||||||
|
|
||||||
@@ -153,7 +162,6 @@
|
|||||||
password: "{{ lookup('env', 'NTFY_PASSWORD') }}"
|
password: "{{ lookup('env', 'NTFY_PASSWORD') }}"
|
||||||
force_basic_auth: true
|
force_basic_auth: true
|
||||||
body: |
|
body: |
|
||||||
Proxmox cluster update completed successfully.
|
|
||||||
{% if hostvars[groups['nodes'][0]].pve_current_version.stdout == hostvars[groups['nodes'][0]].pve_new_version.stdout %}
|
{% 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 }})
|
Version unchanged ({{ hostvars[groups['nodes'][0]].pve_new_version.stdout }})
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
Reference in New Issue
Block a user