From d43fbb632cbb5d55a71b87f052eb16e16a43aca8 Mon Sep 17 00:00:00 2001 From: pavel Date: Thu, 5 Feb 2026 16:14:37 +0200 Subject: [PATCH] 1614 --- files/ansible-playbooks/sot-updater.yml | 53 +++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/files/ansible-playbooks/sot-updater.yml b/files/ansible-playbooks/sot-updater.yml index 421f61c..b69b16a 100644 --- a/files/ansible-playbooks/sot-updater.yml +++ b/files/ansible-playbooks/sot-updater.yml @@ -1985,6 +1985,59 @@ payload_encoding: "string" changed_when: false + # ----------------------- SOT timestamp (container local time) → sot_ts ----------------------- + - name: SOT ts | Get container timestamp + delegate_to: localhost + shell: "date '+%y%m%d-%H%M%S'" + args: + executable: /bin/bash + register: sot_ts_cmd + changed_when: false + failed_when: false + + - name: SOT ts | Set sot_ts value + delegate_to: localhost + set_fact: + sot_ts_value: "{{ sot_ts_cmd.stdout | default('') | trim }}" + changed_when: false + + - name: SOT ts | Debug + delegate_to: localhost + debug: + msg: + - "sot_ts_value={{ sot_ts_value | default('unset') }}" + + - name: Scan tracking | sot_ts outcome + delegate_to: localhost + set_fact: + scan_ok: "{{ scan_ok + (['sot_ts'] if ((sot_ts_value | default('') | length) > 0) else []) }}" + scan_fail: "{{ scan_fail + (['sot_ts=unavailable'] if ((sot_ts_value | default('') | length) == 0) else []) }}" + changed_when: false + + - name: Publish sot_ts + delegate_to: localhost + 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': 'sot_ts', + 'task_result': (sot_ts_value if (sot_ts_value|length>0) else 'unavailable') + } | to_json }}" + payload_encoding: "string" + changed_when: false + + # ----------------------- Final journal: scan status ----------------------- - name: Journal final scan status (success / partial / fail) delegate_to: localhost