add: start phase 2

This commit is contained in:
2026-06-18 20:33:10 +00:00
parent fbcbab5040
commit 8d76623e3a

View File

@@ -6,7 +6,6 @@
hosts: opnsense hosts: opnsense
any_errors_fatal: true any_errors_fatal: true
gather_facts: false gather_facts: false
tasks: tasks:
- block: - block:
@@ -58,10 +57,19 @@
fw_current_version: "{{ _firmware_status.json.product_version | default('unknown') }}" fw_current_version: "{{ _firmware_status.json.product_version | default('unknown') }}"
fw_new_version: "{{ _firmware_status.json.upgrade_packages | selectattr('name', 'equalto', 'opnsense') | map(attribute='new_version') | first | default('') }}" fw_new_version: "{{ _firmware_status.json.upgrade_packages | selectattr('name', 'equalto', 'opnsense') | map(attribute='new_version') | first | default('') }}"
needs_reboot: "{{ true if _firmware_status.json.needs_reboot == '1' else false }}" needs_reboot: "{{ true if _firmware_status.json.needs_reboot == '1' else false }}"
# 'pending' means updates exist; will be overwritten to success/rolled_back total_vips: "{{ _vip_status.json.rowCount }}"
# If it stays 'pending' after the run, a pre-update check failed mismatched_vips: "{{ _vip_status.json.rows | rejectattr('status', 'equalto', expected_role) | list | length }}"
in_maintenance: "{{ _vip_status.json.carp.maintenancemode }}"
update_result: "{{ 'pending' if _firmware_status.json.status == 'update' else 'skipped' }}" update_result: "{{ 'pending' if _firmware_status.json.status == 'update' else 'skipped' }}"
- name: "Assert all VIPs are {{ expected_role }} and CARP is active (no maintenance)"
ansible.builtin.assert:
that:
- firmware_status == 'update'
- total_vips > 0
- mismatched_vips == 0
- not in_maintenance
- name: Display firmware status - name: Display firmware status
ansible.builtin.debug: ansible.builtin.debug:
msg: >- msg: >-
@@ -69,49 +77,28 @@
({{ fw_current_version }} ({{ fw_current_version }}
{% if fw_new_version %} → {{ fw_new_version }} (reboot: {{ needs_reboot }}){% endif %}) {% if fw_new_version %} → {{ fw_new_version }} (reboot: {{ needs_reboot }}){% endif %})
- name: Warn — major upgrade skipped, handle manually rescue:
- name: Send notification
ansible.builtin.debug: ansible.builtin.debug:
msg: >- msg: "End of workflow, sending notification"
NOTICE: {{ inventory_hostname }} has a MAJOR upgrade available
({{ fw_new_version }}). This playbook handles minor updates only.
when: firmware_status == 'upgrade'
# ############################################################### - name: "Phase 2 | Update backup node (TrueNAS, no snapshot)"
# - name: "Phase 2 | Update backup node (TrueNAS, no snapshot)" hosts: opnsense_backup
# hosts: opnsense_backup gather_facts: false
# gather_facts: false tasks:
# tasks: - block:
# - name: Skip — no minor updates available on backup
# ansible.builtin.meta: end_host
# when: firmware_status != 'update'
# # Safety: confirm backup is actually in BACKUP role before touching it - name: Enable CARP maintenance mode
# - name: Verify backup node CARP role ansible.builtin.uri:
# ansible.builtin.uri: url: "https://{{ opnsense_host }}/api/diagnostics/interface/carp_status/maintenance"
# url: "https://{{ opnsense_host }}/api/carp/status/get" method: POST
# method: GET 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: _carp
# # Abort if node is unexpectedly MASTER — updating it would disrupt traffic
# failed_when: _carp.json.status | upper != 'BACKUP'
# # Maintenance mode prevents the backup from attempting to take over
# # during its own reboot (avoids CARP flapping)
# - name: Enable CARP maintenance mode
# ansible.builtin.uri:
# url: "https://{{ opnsense_host }}/api/carp/status/maintenancemode"
# method: POST
# user: "{{ opnsense_api_key }}"
# password: "{{ opnsense_api_secret }}"
# force_basic_auth: true
# validate_certs: false
# body_format: json
# body: {}
# - name: Trigger firmware update # - name: Trigger firmware update
# ansible.builtin.uri: # ansible.builtin.uri: