diff --git a/files/ansible-playbooks/sot-updater-upgradecmd.yml b/files/ansible-playbooks/sot-updater-upgradecmd.yml index 87de53a..fdd36b8 100644 --- a/files/ansible-playbooks/sot-updater-upgradecmd.yml +++ b/files/ansible-playbooks/sot-updater-upgradecmd.yml @@ -1,4 +1,3 @@ ---- # sot-updater.yml — Read fw on Dev1 + Dev2, publish to NetBox via Rabbit (telemetry mode) - name: Read fw on Dev1 + Dev2, publish NetBox custom fields (full base, AIRPINGs, soft-fail telemetry) @@ -37,6 +36,9 @@ rmq_exchange: "{{ lookup('env','RMQ_EXCHANGE') | default('controls', true) }}" control_queue: "{{ lookup('env','CONTROLQUEUE') | default('queue_controls', true) }}" + # === NEW (surgical): requeue attempt counter from environment, default 0 === + requeue_attempt: "{{ (lookup('env','REQUEUE_ATTEMPT') | default('0', true)) | int }}" + pre_tasks: - name: "NB preflight | Verify script exists" delegate_to: localhost @@ -239,6 +241,7 @@ - nb_script.stat.exists - nb_ip_changed | default(false) - (nb_preflight.rc | default(1)) == 0 # <— extra safety + - (requeue_attempt | int) < 3 # <— NEW: limit to 3 tries delegate_to: localhost uri: url: "http://{{ rmq_host }}:{{ rmq_port }}/api/exchanges/app/deviceconfig.delayed/publish" @@ -254,9 +257,15 @@ body: properties: content_type: "application/json" - headers: { x-delay: 3000 } + # === NEW (surgical): 20s delay instead of 3s === + headers: { x-delay: 20000 } routing_key: "deviceconfig" - payload: "{{ {'inscope_device': (ansible_hostname | default(inventory_hostname)), 'task_name': 'sot-updater'} | to_json }}" + # === NEW (surgical): include attempt counter in payload === + payload: "{{ { + 'inscope_device': (ansible_hostname | default(inventory_hostname)), + 'task_name': 'sot-updater', + 'attempt': ((requeue_attempt | int) + 1) + } | to_json }}" payload_encoding: "string" register: rmq_requeue changed_when: false @@ -267,6 +276,7 @@ - nb_script.stat.exists - nb_ip_changed | default(false) - (nb_preflight.rc | default(1)) == 0 # <— extra safety + - (requeue_attempt | int) < 3 # <— NEW: only if we actually published delegate_to: localhost ansible.builtin.debug: msg: