1644
This commit is contained in:
@@ -1231,6 +1231,135 @@
|
||||
non_ts_diff_found: true
|
||||
changed_when: false
|
||||
|
||||
# ----------------------- Dev1 bandwidth shaping → bw_up / bw_down -----------------------
|
||||
- name: Dev1 | Read bw_up from ifb0 shaping
|
||||
delegate_to: localhost
|
||||
shell: |
|
||||
sshpass -p '{{ dev1_pass }}' ssh {{ ssh_opts_common }} \
|
||||
"{{ dev1_user }}@{{ ansible_host|default(inventory_hostname) }}" \
|
||||
"tc -d class show dev ifb0 2>/dev/null | grep 'root burst' | awk -F' ' '{ print \$12 }'"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: dev1_bw_up_raw
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
ignore_errors: true
|
||||
|
||||
- name: Dev1 | Normalize bw_up value
|
||||
delegate_to: localhost
|
||||
set_fact:
|
||||
bw_up_value: >-
|
||||
{{
|
||||
(dev1_bw_up_raw.stdout | default('') | trim)
|
||||
if ((dev1_bw_up_raw.stdout | default('') | trim | length) > 0)
|
||||
else 'unavailable'
|
||||
}}
|
||||
changed_when: false
|
||||
|
||||
- name: Scan tracking | Dev1 bw_up outcome
|
||||
delegate_to: localhost
|
||||
set_fact:
|
||||
scan_ok: "{{ scan_ok + (['bw_up'] if ((bw_up_value | default('unavailable')) != 'unavailable') else []) }}"
|
||||
scan_fail: "{{ scan_fail + (['bw_up=unavailable'] if ((bw_up_value | default('unavailable')) == 'unavailable') else []) }}"
|
||||
changed_when: false
|
||||
|
||||
- name: Publish Dev1 bw_up custom field
|
||||
when:
|
||||
- (not (nb_baseline_ok | default(false))) or ((bw_up_value) != (nb_custom_fields_current.get('bw_up')))
|
||||
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': 'bw_up',
|
||||
'task_result': bw_up_value
|
||||
} | to_json }}"
|
||||
payload_encoding: "string"
|
||||
changed_when: false
|
||||
|
||||
- name: Delta tracking | Mark changed bw_up
|
||||
when:
|
||||
- (not (nb_baseline_ok | default(false))) or ((bw_up_value) != (nb_custom_fields_current.get('bw_up')))
|
||||
delegate_to: localhost
|
||||
set_fact:
|
||||
non_ts_diff_found: true
|
||||
changed_when: false
|
||||
|
||||
- name: Dev1 | Read bw_down from eth0 shaping
|
||||
delegate_to: localhost
|
||||
shell: |
|
||||
sshpass -p '{{ dev1_pass }}' ssh {{ ssh_opts_common }} \
|
||||
"{{ dev1_user }}@{{ ansible_host|default(inventory_hostname) }}" \
|
||||
"tc -d qdisc show dev eth0 2>/dev/null | grep 'root' | awk -F' ' '{ print \$10 }'"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: dev1_bw_down_raw
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
ignore_errors: true
|
||||
|
||||
- name: Dev1 | Normalize bw_down value
|
||||
delegate_to: localhost
|
||||
set_fact:
|
||||
bw_down_value: >-
|
||||
{{
|
||||
(dev1_bw_down_raw.stdout | default('') | trim)
|
||||
if ((dev1_bw_down_raw.stdout | default('') | trim | length) > 0)
|
||||
else 'unavailable'
|
||||
}}
|
||||
changed_when: false
|
||||
|
||||
- name: Scan tracking | Dev1 bw_down outcome
|
||||
delegate_to: localhost
|
||||
set_fact:
|
||||
scan_ok: "{{ scan_ok + (['bw_down'] if ((bw_down_value | default('unavailable')) != 'unavailable') else []) }}"
|
||||
scan_fail: "{{ scan_fail + (['bw_down=unavailable'] if ((bw_down_value | default('unavailable')) == 'unavailable') else []) }}"
|
||||
changed_when: false
|
||||
|
||||
- name: Publish Dev1 bw_down custom field
|
||||
when:
|
||||
- (not (nb_baseline_ok | default(false))) or ((bw_down_value) != (nb_custom_fields_current.get('bw_down')))
|
||||
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': 'bw_down',
|
||||
'task_result': bw_down_value
|
||||
} | to_json }}"
|
||||
payload_encoding: "string"
|
||||
changed_when: false
|
||||
|
||||
- name: Delta tracking | Mark changed bw_down
|
||||
when:
|
||||
- (not (nb_baseline_ok | default(false))) or ((bw_down_value) != (nb_custom_fields_current.get('bw_down')))
|
||||
delegate_to: localhost
|
||||
set_fact:
|
||||
non_ts_diff_found: true
|
||||
changed_when: false
|
||||
|
||||
# ----------------------- Dev1 hostname (for Dev2 mismatch check) -----------------------
|
||||
- name: Dev1 | Read kernel hostname
|
||||
delegate_to: localhost
|
||||
|
||||
Reference in New Issue
Block a user