This commit is contained in:
2025-11-06 07:55:38 +02:00
parent e064ffbeb2
commit ed5eb19017

View File

@@ -185,6 +185,11 @@
- "IP changed: {{ nb_ip_changed|default(false) }}" - "IP changed: {{ nb_ip_changed|default(false) }}"
- "Reason: {{ nb_change_reason|default('none') }}" - "Reason: {{ nb_change_reason|default('none') }}"
- name: "NB preflight | Compute next_attempt"
delegate_to: localhost
set_fact:
next_attempt: "{{ (requeue_attempt | int) + 1 }}"
# --- Requeue control: only 3 attempts, 300s apart --- # --- Requeue control: only 3 attempts, 300s apart ---
- name: "NB preflight | Publish delayed requeue (300s) if needed" - name: "NB preflight | Publish delayed requeue (300s) if needed"
when: when:
@@ -205,12 +210,12 @@
body: body:
properties: properties:
content_type: "application/json" content_type: "application/json"
headers: { x-delay: 300000 } # 300 seconds = 5 minutes headers: { x-delay: 300000 }
routing_key: "deviceconfig" routing_key: "deviceconfig"
payload: "{{ { payload: "{{ {
'inscope_device': (ansible_hostname | default(inventory_hostname)), 'inscope_device': (ansible_hostname | default(inventory_hostname)),
'task_name': 'sot-updater', 'task_name': 'sot-updater',
'attempt': ((requeue_attempt | int) + 1) 'attempt': next_attempt
} | to_json }}" } | to_json }}"
payload_encoding: "string" payload_encoding: "string"
register: rmq_requeue register: rmq_requeue
@@ -225,7 +230,7 @@
delegate_to: localhost delegate_to: localhost
debug: debug:
msg: msg:
- "Requeue published (attempt {{ requeue_attempt+1 }})" - "Requeue published (attempt {{ (requeue_attempt | int) + 1 }})"
- "HTTP: {{ rmq_requeue.status|default('n/a') }}" - "HTTP: {{ rmq_requeue.status|default('n/a') }}"
- "JSON: {{ rmq_requeue.json|default('<none>') }}" - "JSON: {{ rmq_requeue.json|default('<none>') }}"