Debian Codegraph @

ansible_collections/dellemc/openmanage/roles/idrac_gather_facts/molecule/sensorsbattery-10618/converge.yml

raw symbols SCIP
1 ---
2 - name: Converge idrac_gather_facts for Sensors Battery
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_Battery
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 system API
32 ansible.builtin.include_tasks:
33 ../../tests/asserts/_check_system_url.yml
34
35 - name: Gather Facts for the Sensors Battery 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 - sensor_battery | length > 0
43 when: battery_result.status == 200
44
45 - name: Fetching Sensor Battery info
46 ansible.builtin.uri:
47 url: "https://{{ hostname }}{{ api_system }}/Oem/Dell/DellSensors/iDRAC.Embedded.1_0x23_SystemBoardCMOSBattery"
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 ignore_errors: true
58 register: battery_result
59
60 - name: Response filter
61 ansible.builtin.set_fact:
62 api_response:
63 "{{ battery_result.json | ansible.utils.remove_keys(target=['@odata.context',
64 '@odata.id', '@odata.type', '@odata.etag']) }}"
65 vars:
66 jquery: "Oem.Dell.DellSystem"
67 when: battery_result is defined and battery_result.status == 200
68
69 - name: Set the keys diff
70 ansible.builtin.set_fact:
71 diff_keys: "{{ sensor_battery.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: sensor_battery[item]}) }}"
77 loop: "{{ sensor_battery.keys() }}"
78 when:
79 - diff_keys is defined
80 - diff_keys | length == 0
81 - sensor_battery[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