Debian Codegraph @

ansible_collections/dellemc/openmanage/roles/idrac_gather_facts/molecule/system-10621/converge.yml

raw symbols SCIP
1 ---
2 - name: Converge idrac_gather_facts
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 - System
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: ["ServerOS.1.ServerPoweredOnTime"]
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: Find the manager API
36 ansible.builtin.include_tasks:
37 ../../tests/asserts/_check_manager_url.yml
38
39 - name: Set 17G url
40 ansible.builtin.set_fact:
41 url2_1: "https://{{ hostname }}{{ api_manager }}"
42 url2_2: "/Oem/Dell/DellAttributes/{{ computer_system_id }}"
43 when:
44 - not is_omsdk_required | bool
45
46 - name: Set < 17G url
47 ansible.builtin.set_fact:
48 url2_1: "https://{{ hostname }}/redfish/v1/"
49 url2_2: "Managers/{{ computer_system_id }}/Attributes"
50 when:
51 - is_omsdk_required | bool
52
53 - name: Set < 17G url.
54 ansible.builtin.set_fact:
55 url2: "{{ url2_1 }}{{ url2_2 }}"
56
57 - name: Gather Facts for the System component
58 ansible.builtin.include_role:
59 name: "idrac_gather_facts"
60
61 - name: Assert system dict for length
62 ansible.builtin.assert:
63 that:
64 - "{{ system | length > 0 }}"
65 when: system_result.status == 200 and os_result.status == 200
66
67 - name: Fetching System info
68 ansible.builtin.uri:
69 url: "https://{{ hostname }}{{ api_system }}"
70 validate_certs: false
71 method: "{{ idrac_gather_facts_uri_method }}"
72 user: "{{ username }}"
73 password: "{{ password }}"
74 headers: "{{ idrac_gather_facts_uri_headers }}"
75 body_format: "{{ idrac_gather_facts_uri_body_format }}"
76 status_code: "{{ idrac_gather_facts_uri_status_code }}"
77 return_content: "{{ idrac_gather_facts_uri_return_content }}"
78 register: system_result
79 no_log: false
80
81 - name: Fetching operating system info
82 ansible.builtin.uri:
83 url: "{{ url2 }}" # verification firmware version 5.00.00
84 validate_certs: "{{ validate_certs }}"
85 ca_path: "{{ ca_path | default(omit) }}"
86 method: "{{ idrac_gather_facts_uri_method }}"
87 user: "{{ username }}"
88 password: "{{ password }}"
89 headers: "{{ idrac_gather_facts_uri_headers }}"
90 body_format: "{{ idrac_gather_facts_uri_body_format }}"
91 status_code: "{{ idrac_gather_facts_uri_status_code }}"
92 return_content: "{{ idrac_gather_facts_uri_return_content }}"
93 register: os_result
94 no_log: false
95
96 - name: Extracting Server OS
97 ansible.builtin.set_fact:
98 os_attrs:
99 "{{ os_attrs | default({}) | combine({item.key: item.value}) }}"
100 when: "'ServerOS' in item.key"
101 loop: "{{ os_result.json.Attributes | dict2items }}"
102
103 - name: Set system facts
104 ansible.builtin.set_fact:
105 api_response:
106 "{{ system_result.json.Oem.Dell.DellSystem | combine(os_attrs) |
107 ansible.utils.remove_keys(target=['@odata.context',
108 '@odata.id', '@odata.etag', '@odata.type']) }}"
109 when: system_result.status == 200 and os_result.status == 200
110
111 - name: Set the keys diff
112 ansible.builtin.set_fact:
113 diff_keys: "{{ system.keys() | list | symmetric_difference((api_response.keys() | list)) }}"
114 when: system is defined and api_response is defined
115
116 - name: Set a Diff of dict
117 ansible.builtin.set_fact:
118 diff_data: "{{ diff_data | combine({item: system[item]}) }}"
119 loop: "{{ system.keys() }}"
120 when:
121 - diff_keys is defined
122 - diff_keys | length == 0
123 - system[item] != api_response[item]
124 - item not in exclude_keys
125 - item != "EstimatedSystemAirflowCFM"
126 - item != "EstimatedExhaustTemperatureCelsius"
127
128 - name: Assert the difference in Keys
129 ansible.builtin.assert:
130 that:
131 - (diff_keys | length) == 0
132 - (diff_data | length) == 0
133 fail_msg: "The response from the role does not match | Diff Keys : {{ diff_keys }} Diff Data : {{ diff_data }}"
134 success_msg: "The response from the role matches | Diff Keys : {{ diff_keys }} Diff Data : {{ diff_data }}"
135 when: diff_keys is defined and diff_data is defined