Debian Codegraph @

ansible_collections/dellemc/openmanage/roles/idrac_gather_facts/molecule/sensorsintrusion-10628/converge.yml

raw symbols SCIP
1 ---
2 - name: Converge idrac_gather_facts for Sensors Intrusion
3 hosts: all
4 gather_facts: false
5 vars:
6 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
7 username: "{{ lookup('env', 'IDRAC_USER') }}"
8 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
9 idrac_port: "{{ lookup('env', 'IDRAC_PORT') }}"
10 validate_certs: false
11 target:
12 - Sensors_Intrusion
13 idrac_gather_facts_uri_method: "GET"
14 idrac_gather_facts_uri_headers:
15 Accept: "application/json"
16 Content-Type: "application/json"
17 OData-Version: "4.0"
18 idrac_gather_facts_uri_body_format: "json"
19 idrac_gather_facts_uri_status_code:
20 - 200
21 - 400
22 - 401
23 - 404
24 - -1
25 idrac_gather_facts_uri_return_content: true
26 diff_data: {}
27 exclude_keys: []
28
29 tasks:
30
31 - name: Find the chassis API
32 ansible.builtin.include_tasks:
33 ../../tests/asserts/_check_chassis_url.yml
34
35 - name: Gather Facts for the Sensors Intrusion component
36 ansible.builtin.include_role:
37 name: "idrac_gather_facts"
38
39 - name: Assert sensor battery dict for length
40 ansible.builtin.assert:
41 that:
42 - intrusion_sensor | length > 0
43 when: intrusion_result.status == 200
44
45 - name: Fetching Sensor Battery info
46 ansible.builtin.uri:
47 url: "https://{{ hostname }}{{ api_chassis }}?$select=PhysicalSecurity/IntrusionSensor"
48 validate_certs: false
49 method: "{{ idrac_gather_facts_uri_method }}"
50 user: "{{ username }}"
51 password: "{{ password }}"
52 headers: "{{ idrac_gather_facts_uri_headers }}"
53 body_format: "{{ idrac_gather_facts_uri_body_format }}"
54 status_code: "{{ idrac_gather_facts_uri_status_code }}"
55 return_content: "{{ idrac_gather_facts_uri_return_content }}"
56 no_log: false
57 register: sensorintrusion_result
58
59 - name: Response filter
60 ansible.builtin.set_fact:
61 api_response:
62 "{{ sensorintrusion_result.json | ansible.utils.remove_keys(target=['@odata.context',
63 '@odata.id', '@odata.type', '@odata.etag']) }}"
64 vars:
65 jquery: "Oem.Dell.DellSystem"
66 when: sensorintrusion_result is defined and
67 sensorintrusion_result.status == 200
68
69 - name: Set the keys diff
70 ansible.builtin.set_fact:
71 diff_keys: "{{ intrusion_sensor.keys() | list | symmetric_difference((api_response.keys() | list)) }}"
72 when: api_response is defined
73
74 - name: Set a diff of dict
75 ansible.builtin.set_fact:
76 diff_data: "{{ diff_data | combine({item: intrusion_sensor[item]}) }}"
77 loop: "{{ intrusion_sensor.keys() }}"
78 when:
79 - diff_keys is defined
80 - diff_keys | length == 0
81 - intrusion_sensor[item] != api_response[item]
82 - item not in exclude_keys
83
84 - name: Assert the difference in Keys
85 ansible.builtin.assert:
86 that:
87 - (diff_keys | length) == 0
88 - (diff_data | length) == 0
89 fail_msg: "The response from the role does not match | Diff Keys : {{ diff_keys }} Diff Data : {{ diff_data }}"
90 success_msg: "The response from the role matches | Diff Keys : {{ diff_keys }} Diff Data : {{ diff_data }}"
91 when: diff_keys is defined and diff_data is defined