1614
This commit is contained in:
@@ -1985,6 +1985,59 @@
|
|||||||
payload_encoding: "string"
|
payload_encoding: "string"
|
||||||
changed_when: false
|
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 -----------------------
|
# ----------------------- Final journal: scan status -----------------------
|
||||||
- name: Journal final scan status (success / partial / fail)
|
- name: Journal final scan status (success / partial / fail)
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|||||||
Reference in New Issue
Block a user