From cec2fd3faeb2bb7234a9d0f64323cd4acfa8c22a Mon Sep 17 00:00:00 2001 From: pavel Date: Sun, 15 Feb 2026 12:16:09 +0200 Subject: [PATCH] 1216 --- .../update-indoor-scheduler.yml | 2 +- .../update-indoor6-stable.yml | 86 +++++++++++++------ 2 files changed, 61 insertions(+), 27 deletions(-) diff --git a/files/ansible-playbooks/update-indoor-scheduler.yml b/files/ansible-playbooks/update-indoor-scheduler.yml index 51fcea9..9a82fc8 100644 --- a/files/ansible-playbooks/update-indoor-scheduler.yml +++ b/files/ansible-playbooks/update-indoor-scheduler.yml @@ -92,6 +92,6 @@ changed_when: false -- import_playbook: update-indoor6-stable.yml +- import_playbook: update-indoor6-stable.patched.yml vars: is_run_by: "scheduler" diff --git a/files/ansible-playbooks/update-indoor6-stable.yml b/files/ansible-playbooks/update-indoor6-stable.yml index 7d113c1..d5e6f4d 100644 --- a/files/ansible-playbooks/update-indoor6-stable.yml +++ b/files/ansible-playbooks/update-indoor6-stable.yml @@ -952,32 +952,6 @@ action_restart_timestamp: "{{ (lookup('pipe', 'date +%s') | int) + (_reboot_seconds | int) }}" changed_when: false - - name: Scheduler mode publish action_restart_timestamp custom field to control queue - when: is_run_by_effective == 'scheduler' - delegate_to: localhost - ansible.builtin.uri: - url: "http://{{ rmq_host }}:{{ rmq_port }}/api/exchanges/{{ rmq_vhost|urlencode }}/{{ rmq_exchange|urlencode }}/publish" - method: POST - user: "{{ rmq_user }}" - password: "{{ rmq_pass }}" - force_basic_auth: true - status_code: 200 - headers: - content-type: "application/json" - body_format: json - body: - properties: - content_type: "application/json" - routing_key: "{{ control_queue }}" - payload: "{{ { - 'inscope_device': (ansible_hostname | default(inventory_hostname)), - 'task_name': 'custom_field_set', - 'task_add1': 'action_restart_timestamp', - 'task_result': (action_restart_timestamp | string) - } | to_json }}" - payload_encoding: "string" - changed_when: false - - name: Build human-readable reboot phrase delegate_to: localhost ansible.builtin.set_fact: @@ -1475,6 +1449,40 @@ changed_when: true ignore_errors: true + - name: Scheduler mode compute reboot_applied flag (gate for action_restart_timestamp) + when: is_run_by_effective == 'scheduler' + delegate_to: localhost + ansible.builtin.set_fact: + reboot_applied_cf: "{{ (dev2_reboot_sched is defined) and (dev2_reboot_sched.rc is defined) and ((dev2_reboot_sched.rc | int) == 0) }}" + changed_when: false + + - name: Scheduler mode publish action_restart_timestamp custom field to control queue + when: is_run_by_effective == 'scheduler' and (reboot_applied_cf | default(false)) + delegate_to: localhost + ansible.builtin.uri: + url: "http://{{ rmq_host }}:{{ rmq_port }}/api/exchanges/{{ rmq_vhost|urlencode }}/{{ rmq_exchange|urlencode }}/publish" + method: POST + user: "{{ rmq_user }}" + password: "{{ rmq_pass }}" + force_basic_auth: true + status_code: 200 + headers: + content-type: "application/json" + body_format: json + body: + properties: + content_type: "application/json" + routing_key: "{{ control_queue }}" + payload: "{{ { + 'inscope_device': (ansible_hostname | default(inventory_hostname)), + 'task_name': 'custom_field_set', + 'task_add1': 'action_restart_timestamp', + 'task_result': (action_restart_timestamp | string) + } | to_json }}" + payload_encoding: "string" + changed_when: false + + - name: Build 'indoor-restart-scheduled' tag payload ansible.builtin.set_fact: tag_restart_sched_payload: @@ -1705,6 +1713,32 @@ - "journal={{ (_journal | default([])) | join(' || ') }}" post_tasks: + - name: Scheduler mode report failure to NetBox when update needed but reboot not applied + when: is_run_by_effective == 'scheduler' and (((not (version_match | default(false))) or (force_upgrade | default(false)))) and (not ((dev2_reboot_sched is defined) and (dev2_reboot_sched.rc is defined) and ((dev2_reboot_sched.rc | int) == 0))) + delegate_to: localhost + ansible.builtin.uri: + url: "http://{{ rmq_host }}:{{ rmq_port }}/api/exchanges/{{ rmq_vhost|urlencode }}/{{ rmq_exchange|urlencode }}/publish" + method: POST + user: "{{ rmq_user }}" + password: "{{ rmq_pass }}" + force_basic_auth: true + status_code: 200 + headers: + content-type: "application/json" + body_format: json + body: + properties: + content_type: "application/json" + routing_key: "{{ control_queue }}" + payload: "{{ { + 'inscope_device': (ansible_hostname | default(inventory_hostname)), + 'task_name': 'custom_field_set', + 'task_add1': 'action_state', + 'task_result': 'failed' + } | to_json }}" + payload_encoding: "string" + changed_when: false + - name: Cleanup (always) block: - ansible.builtin.debug: