change: method to wait for the update
This commit is contained in:
@@ -114,7 +114,6 @@
|
|||||||
headers:
|
headers:
|
||||||
Title: "OPNsense update aborted"
|
Title: "OPNsense update aborted"
|
||||||
Priority: "default"
|
Priority: "default"
|
||||||
Tags: "x"
|
|
||||||
run_once: true
|
run_once: true
|
||||||
when: ntfy_url is defined
|
when: ntfy_url is defined
|
||||||
|
|
||||||
@@ -223,30 +222,18 @@
|
|||||||
password: "{{ lookup('env', 'NTFY_PASSWORD') }}"
|
password: "{{ lookup('env', 'NTFY_PASSWORD') }}"
|
||||||
force_basic_auth: true
|
force_basic_auth: true
|
||||||
body: |
|
body: |
|
||||||
TODO
|
Current version: {{ firmware_current_version }}
|
||||||
# Current version: {{ firmware_current_version }}
|
Update to {{ firmware_new_version }} failed on {{ inventory_hostname }} ({{ main_role }}).
|
||||||
# {% if firmware_status != "update" %}
|
No snapshot have been taken before the update.
|
||||||
# {% if firmware_status == "upgrade" %}
|
|
||||||
# Upgrade to {{ firmware_upgrade_version }} available, relaunch the playbook manually to proceed.
|
|
||||||
# {% else %}
|
|
||||||
# No updates available on the cluster.
|
|
||||||
# {% endif %}
|
|
||||||
# {% elif in_maintenance %}
|
|
||||||
# The node {{ inventory_hostname }} is in CARP maintenance mode.
|
|
||||||
# {% elif mismatched_vips > 0 %}
|
|
||||||
# Some VIP are not {{ main_role }} on {{ ansible_host }}.
|
|
||||||
# {% else %}
|
|
||||||
# No VIPs are managed.
|
|
||||||
# {% endif %}
|
|
||||||
headers:
|
headers:
|
||||||
Title: "OPNsense update failed on {{ inventory_hostname }}"
|
Title: "OPNsense update failed on {{ inventory_hostname }}"
|
||||||
Priority: "default"
|
Priority: "high"
|
||||||
Tags: "x"
|
Tags: "x"
|
||||||
run_once: true
|
run_once: true
|
||||||
when: ntfy_url is defined
|
when: ntfy_url is defined
|
||||||
|
|
||||||
- ansible.builtin.fail:
|
- ansible.builtin.fail:
|
||||||
msg: "Update aborted"
|
msg: "Update failed"
|
||||||
|
|
||||||
- name: "Phase 3 | Update master node (Proxmox, with snapshot)"
|
- name: "Phase 3 | Update master node (Proxmox, with snapshot)"
|
||||||
hosts: opnsense_master
|
hosts: opnsense_master
|
||||||
@@ -289,7 +276,7 @@
|
|||||||
force_basic_auth: true
|
force_basic_auth: true
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
|
||||||
- name: Wait for packages to update
|
- name: Check if the update is running
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: "https://{{ opnsense_host }}/api/core/firmware/running"
|
url: "https://{{ opnsense_host }}/api/core/firmware/running"
|
||||||
method: GET
|
method: GET
|
||||||
@@ -298,16 +285,18 @@
|
|||||||
force_basic_auth: true
|
force_basic_auth: true
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
register: _update_running
|
register: _update_running
|
||||||
until: _update_running.json.status != 'busy'
|
|
||||||
retries: 300
|
- name: Assert the update is running
|
||||||
delay: 15
|
ansible.builtin.assert:
|
||||||
|
that: _update_running.json.status == 'busy'
|
||||||
|
quiet: true
|
||||||
|
|
||||||
- name: Wait for node to go offline
|
- name: Wait for node to go offline
|
||||||
ansible.builtin.wait_for:
|
ansible.builtin.wait_for:
|
||||||
host: "{{ ansible_host }}"
|
host: "{{ ansible_host }}"
|
||||||
port: "{{ opnsense_https_port }}"
|
port: "{{ opnsense_https_port }}"
|
||||||
state: stopped
|
state: stopped
|
||||||
timeout: 60
|
timeout: 3600
|
||||||
when: needs_reboot
|
when: needs_reboot
|
||||||
|
|
||||||
- name: Wait for node to come back online
|
- name: Wait for node to come back online
|
||||||
@@ -319,18 +308,22 @@
|
|||||||
delay: 30
|
delay: 30
|
||||||
when: needs_reboot
|
when: needs_reboot
|
||||||
|
|
||||||
- name: Wait for API to be fully responsive
|
- name: Check firmware version
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: "https://{{ opnsense_host }}/api/core/firmware/status"
|
url: "https://{{ opnsense_host }}/api/core/firmware/check"
|
||||||
method: GET
|
method: POST
|
||||||
user: "{{ opnsense_api_key }}"
|
user: "{{ opnsense_api_key }}"
|
||||||
password: "{{ opnsense_api_secret }}"
|
password: "{{ opnsense_api_secret }}"
|
||||||
force_basic_auth: true
|
force_basic_auth: true
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
register: _post_status
|
register: _post_firmware_check
|
||||||
until: _post_status.status == 200
|
until: _post_firmware_check.json.product_version | default('unknown') == firmware_new_version
|
||||||
retries: 20
|
retries: 300
|
||||||
delay: 10
|
delay: 15
|
||||||
|
|
||||||
|
- name: Assert the node has been updated
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
|
||||||
- name: Check VIP status
|
- name: Check VIP status
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
@@ -359,6 +352,7 @@
|
|||||||
vmid: "{{ proxmox_vmid }}"
|
vmid: "{{ proxmox_vmid }}"
|
||||||
state: rollback
|
state: rollback
|
||||||
snapname: "{{ proxmox_snap_name }}"
|
snapname: "{{ proxmox_snap_name }}"
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Send Ntfy notification
|
- name: Send Ntfy notification
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
@@ -368,24 +362,12 @@
|
|||||||
password: "{{ lookup('env', 'NTFY_PASSWORD') }}"
|
password: "{{ lookup('env', 'NTFY_PASSWORD') }}"
|
||||||
force_basic_auth: true
|
force_basic_auth: true
|
||||||
body: |
|
body: |
|
||||||
TODO
|
Current version: {{ firmware_current_version }}
|
||||||
# Current version: {{ firmware_current_version }}
|
Update to {{ firmware_new_version }} failed on {{ inventory_hostname }} ({{ main_role }}).
|
||||||
# {% if firmware_status != "update" %}
|
A snapshot have been taken before the update and the VM has been rollback.
|
||||||
# {% if firmware_status == "upgrade" %}
|
|
||||||
# Upgrade to {{ firmware_upgrade_version }} available, relaunch the playbook manually to proceed.
|
|
||||||
# {% else %}
|
|
||||||
# No updates available on the cluster.
|
|
||||||
# {% endif %}
|
|
||||||
# {% elif in_maintenance %}
|
|
||||||
# The node {{ inventory_hostname }} is in CARP maintenance mode.
|
|
||||||
# {% elif mismatched_vips > 0 %}
|
|
||||||
# Some VIP are not {{ main_role }} on {{ ansible_host }}.
|
|
||||||
# {% else %}
|
|
||||||
# No VIPs are managed.
|
|
||||||
# {% endif %}
|
|
||||||
headers:
|
headers:
|
||||||
Title: "OPNsense update failed on {{ inventory_hostname }}"
|
Title: "OPNsense update failed on {{ inventory_hostname }}"
|
||||||
Priority: "default"
|
Priority: "high"
|
||||||
Tags: "x"
|
Tags: "x"
|
||||||
run_once: true
|
run_once: true
|
||||||
when: ntfy_url is defined
|
when: ntfy_url is defined
|
||||||
|
|||||||
Reference in New Issue
Block a user