1554
This commit is contained in:
@@ -254,6 +254,118 @@
|
|||||||
register: rmq_cleanup_success
|
register: rmq_cleanup_success
|
||||||
changed_when: (rmq_cleanup_success.json is defined) and (rmq_cleanup_success.json.routed | default(false) | bool)
|
changed_when: (rmq_cleanup_success.json is defined) and (rmq_cleanup_success.json.routed | default(false) | bool)
|
||||||
|
|
||||||
|
- name: Success | Pause before NetBox wrapup custom fields
|
||||||
|
ansible.builtin.pause:
|
||||||
|
seconds: 1
|
||||||
|
delegate_to: localhost
|
||||||
|
changed_when: false
|
||||||
|
when: journal_success_payload is defined
|
||||||
|
|
||||||
|
- name: Success | Publish action_state done
|
||||||
|
when: journal_success_payload is defined
|
||||||
|
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': 'done' }} | to_json }}"
|
||||||
|
payload_encoding: "string"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Success | Pause before NetBox wrapup custom fields
|
||||||
|
ansible.builtin.pause:
|
||||||
|
seconds: 1
|
||||||
|
delegate_to: localhost
|
||||||
|
changed_when: false
|
||||||
|
when: journal_success_payload is defined
|
||||||
|
|
||||||
|
- name: Success | Clear action_restart_timestamp
|
||||||
|
when: journal_success_payload is defined
|
||||||
|
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': '' }} | to_json }}"
|
||||||
|
payload_encoding: "string"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Success | Pause before NetBox wrapup custom fields
|
||||||
|
ansible.builtin.pause:
|
||||||
|
seconds: 1
|
||||||
|
delegate_to: localhost
|
||||||
|
changed_when: false
|
||||||
|
when: journal_success_payload is defined
|
||||||
|
|
||||||
|
- name: Success | Clear action_next
|
||||||
|
when: journal_success_payload is defined
|
||||||
|
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_next', 'task_result': '' }} | to_json }}"
|
||||||
|
payload_encoding: "string"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Success | Pause before NetBox wrapup custom fields
|
||||||
|
ansible.builtin.pause:
|
||||||
|
seconds: 1
|
||||||
|
delegate_to: localhost
|
||||||
|
changed_when: false
|
||||||
|
when: journal_success_payload is defined
|
||||||
|
|
||||||
|
- name: Success | Clear action_next_timestamp
|
||||||
|
when: journal_success_payload is defined
|
||||||
|
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_next_timestamp', 'task_result': '' }} | to_json }}"
|
||||||
|
payload_encoding: "string"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
# Mismatch: reachable & banner read, but not equal to target_version
|
# Mismatch: reachable & banner read, but not equal to target_version
|
||||||
- name: Build mismatch journal payload
|
- name: Build mismatch journal payload
|
||||||
when: nc_probe.rc == 0 and banner_probe.rc == 0 and not (version_match | bool)
|
when: nc_probe.rc == 0 and banner_probe.rc == 0 and not (version_match | bool)
|
||||||
@@ -289,6 +401,34 @@
|
|||||||
register: rmq_j_mismatch
|
register: rmq_j_mismatch
|
||||||
changed_when: (rmq_j_mismatch.json is defined) and (rmq_j_mismatch.json.routed | default(false) | bool)
|
changed_when: (rmq_j_mismatch.json is defined) and (rmq_j_mismatch.json.routed | default(false) | bool)
|
||||||
|
|
||||||
|
- name: Failure | Pause before action_state failed
|
||||||
|
ansible.builtin.pause:
|
||||||
|
seconds: 1
|
||||||
|
delegate_to: localhost
|
||||||
|
changed_when: false
|
||||||
|
when: journal_mismatch_payload is defined
|
||||||
|
|
||||||
|
- name: Failure | Publish action_state failed (mismatch)
|
||||||
|
when: journal_mismatch_payload is defined
|
||||||
|
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
|
||||||
|
|
||||||
# SSH error path: TCP OK, but SSH failed
|
# SSH error path: TCP OK, but SSH failed
|
||||||
- name: Build failure journal payload (ssh error) + mark retry
|
- name: Build failure journal payload (ssh error) + mark retry
|
||||||
when: nc_probe.rc == 0 and banner_probe.rc != 0
|
when: nc_probe.rc == 0 and banner_probe.rc != 0
|
||||||
@@ -375,6 +515,34 @@
|
|||||||
register: rmq_j_gaveup
|
register: rmq_j_gaveup
|
||||||
changed_when: (rmq_j_gaveup.json is defined) and (rmq_j_gaveup.json.routed | default(false) | bool)
|
changed_when: (rmq_j_gaveup.json is defined) and (rmq_j_gaveup.json.routed | default(false) | bool)
|
||||||
|
|
||||||
|
- name: Failure | Pause before action_state failed (gave up)
|
||||||
|
ansible.builtin.pause:
|
||||||
|
seconds: 1
|
||||||
|
delegate_to: localhost
|
||||||
|
changed_when: false
|
||||||
|
when: journal_gaveup_payload is defined
|
||||||
|
|
||||||
|
- name: Failure | Publish action_state failed (gave up)
|
||||||
|
when: journal_gaveup_payload is defined
|
||||||
|
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: Stop host after final gave-up
|
- name: Stop host after final gave-up
|
||||||
when: journal_gaveup_payload is defined
|
when: journal_gaveup_payload is defined
|
||||||
ansible.builtin.meta: end_host
|
ansible.builtin.meta: end_host
|
||||||
|
|||||||
@@ -870,6 +870,28 @@
|
|||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
when: is_run_by_effective == 'scheduler'
|
when: is_run_by_effective == 'scheduler'
|
||||||
|
|
||||||
|
|
||||||
|
- name: Scheduler | Compute action_restart_timestamp (unix seconds) when rebootin == 0
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
action_restart_timestamp: "{{ lookup('pipe','date -u +%s') | int }}"
|
||||||
|
changed_when: false
|
||||||
|
delegate_to: localhost
|
||||||
|
when:
|
||||||
|
- is_run_by_effective == 'scheduler'
|
||||||
|
- reboot_seconds is defined
|
||||||
|
- (reboot_seconds | int) == 0
|
||||||
|
|
||||||
|
- name: Scheduler | Compute action_restart_timestamp (unix seconds) when reboot scheduled
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
action_restart_timestamp: "{{ (lookup('pipe','date -u +%s') | int) + (reboot_seconds | int) }}"
|
||||||
|
changed_when: false
|
||||||
|
delegate_to: localhost
|
||||||
|
when:
|
||||||
|
- is_run_by_effective == 'scheduler'
|
||||||
|
- reboot_seconds is defined
|
||||||
|
- (reboot_seconds | int) > 0
|
||||||
|
|
||||||
|
|
||||||
- name: Scheduler | Compute action_restart_timestamp (unix seconds) when reboot scheduled
|
- name: Scheduler | Compute action_restart_timestamp (unix seconds) when reboot scheduled
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
action_restart_timestamp: "{{ (lookup('pipe','date -u +%s') | int) + (reboot_seconds | int) }}"
|
action_restart_timestamp: "{{ (lookup('pipe','date -u +%s') | int) + (reboot_seconds | int) }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user