Debian Codegraph @

ansible_collections/dellemc/openmanage/roles/idrac_gather_facts/molecule/physicaldisk-10624/converge.yml

raw symbols SCIP
1 ---
2 - name: Converge idrac_gather_facts for Physical Disk
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 - PhysicalDisk
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: Get Storage information.
36 ansible.builtin.uri: &uri_params
37 url: "https://{{ hostname }}{{ api_system }}/Storage"
38 validate_certs: "{{ validate_certs }}"
39 ca_path: "{{ ca_path | default(omit) }}"
40 method: "{{ idrac_gather_facts_uri_method }}"
41 user: "{{ username }}"
42 password: "{{ password }}"
43 headers: "{{ idrac_gather_facts_uri_headers }}"
44 body_format: "{{ idrac_gather_facts_uri_body_format }}"
45 status_code: "{{ idrac_gather_facts_uri_status_code }}"
46 return_content: "{{ idrac_gather_facts_uri_return_content }}"
47 register: idrac_gather_facts_controllers_result
48
49 - name: Get all storage controller ids.
50 ansible.builtin.set_fact:
51 storage_ids_list:
52 "{{ idrac_gather_facts_controllers_result.json.Members |
53 map('dict2items') | flatten | map(attribute='value') }}"
54 when: idrac_gather_facts_controllers_result.json.Members is defined
55
56 - name: Get physical disk information using API.
57 ansible.builtin.uri:
58 url: "https://{{ hostname }}{{ item }}?$expand=*($levels=1)"
59 <<: *uri_params
60 loop: "{{ storage_ids_list }}"
61 no_log: true
62 register: idrac_gather_facts_disk_result
63 when: storage_ids_list is defined
64
65 - name: Assert the response from the API
66 ansible.builtin.debug:
67 var: idrac_gather_facts_disk_result
68
69 - name: Count the number of drives in drives_result.results
70 ansible.builtin.set_fact:
71 drives_count: "{{ idrac_gather_facts_disk_result.results |
72 map(attribute='json.Drives') | list | length }}"
73 when: idrac_gather_facts_disk_result.results is defined
74
75 - name: Set Physical Disk facts
76 ansible.builtin.set_fact:
77 api_response:
78 "{{ idrac_gather_facts_disk_result.results |
79 selectattr('json', 'defined') | map(attribute='json') |
80 selectattr('Drives', 'defined') | map(attribute='Drives') |
81 flatten | ansible.utils.remove_keys(target=['@odata.context',
82 '@odata.id', '@odata.type', 'Actions', 'Assembly', 'Links',
83 'DellDriveSMARTAttributes', 'DellNVMeSMARTAttributes',
84 '[email protected]']) }}"
85 when: idrac_gather_facts_disk_result.results is defined
86
87 - name: Gather Facts for the Physical Disk component
88 ansible.builtin.include_role:
89 name: "idrac_gather_facts"
90
91 - name: Assert Physical Disk data
92 ansible.builtin.assert:
93 that:
94 - "((drives_count | string | length == 0) and
95 (physical_disk | string | length == 0))"
96 fail_msg: "The response from the role does not match"
97 success_msg: "The response from the role matches"
98 when: drives_count | string | length == 0
99
100 - name: Check whether output differs
101 ansible.builtin.set_fact:
102 result_diff: "{{ physical_disk | symmetric_difference(api_response) }}"
103 when: drives_count | string | length > 0
104
105 - name: Assert the differences in List
106 ansible.builtin.assert:
107 fail_msg: "The response from the role does not match"
108 success_msg: "The response from the role matches"
109 that:
110 - result_diff | length == 0
111 when: drives_count | string | length > 0