This commit is contained in:
2026-02-15 12:16:09 +02:00
parent 43750e3549
commit cec2fd3fae
2 changed files with 61 additions and 27 deletions

View File

@@ -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"

View File

@@ -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: