Debian Codegraph @

ansible_collections/dellemc/openmanage/roles/redfish_firmware/molecule/negative_scenarios-10598/converge.yml

raw symbols SCIP
1 ---
2 - name: Converge
3 hosts: all
4 gather_facts: false
5 vars:
6 redfish_firmware_image_url_without_reboot: "{{ lookup('env', 'redfish_firmware_image_url_without_reboot') }}"
7 redfish_firmware_image_url_need_reboot: "{{ lookup('env', 'redfish_firmware_image_url_need_reboot') }}"
8 redfish_firmware_image_local_path: "{{ lookup('env', 'redfish_firmware_image_local_path') }}"
9 tasks:
10 - name: Checking if HTTP url is empty
11 ansible.builtin.fail:
12 msg: Please provide HTTP url for redfish_firmware in molecule.yml
13 when: redfish_firmware_image_url_without_reboot == "" and redfish_firmware_image_url_need_reboot == ""
14
15 - name: Downloading firmware image for local manual reboot
16 ansible.builtin.get_url:
17 url: "{{ redfish_firmware_image_url_need_reboot }}"
18 dest: "{{ redfish_firmware_image_local_path }}"
19 mode: "0755"
20 delegate_to: localhost
21
22 - name: TC - 003 - Provide wrong hostname
23 ansible.builtin.import_role:
24 name: redfish_firmware
25 vars:
26 hostname: "randomHostname"
27 username: "{{ lookup('env', 'IDRAC_USER') }}"
28 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
29 validate_certs: false
30 image_uri: "{{ redfish_firmware_image_url_need_reboot }}"
31 job_wait_timeout: 60
32 ignore_errors: true
33 ignore_unreachable: true
34 register: redfish_firmware_error_msg
35
36 - name: TC - 003 - Asserting wrong hostname
37 ansible.builtin.assert:
38 that:
39 - redfish_firmware_out.msg == "<urlopen error [Errno -2] Name or service not known>" or
40 redfish_firmware_out.msg == "<urlopen error Unable to resolve hostname or IP randomHostname:443.>"
41
42 - name: TC - 004 - Provide wrong username
43 ansible.builtin.import_role:
44 name: redfish_firmware
45 vars:
46 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
47 username: "WrongUsername123"
48 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
49 validate_certs: false
50 image_uri: "{{ redfish_firmware_image_url_need_reboot }}"
51 job_wait_timeout: 60
52 ignore_errors: true
53 ignore_unreachable: true
54 register: redfish_firmware_error_msg
55
56 - name: TC - 004 - Asserting wrong username
57 ansible.builtin.assert:
58 that:
59 - '"HTTP Error 401" in redfish_firmware_out.msg'
60
61 - name: TC - 005 - Provide wrong password
62 ansible.builtin.import_role:
63 name: redfish_firmware
64 vars:
65 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
66 username: "{{ lookup('env', 'IDRAC_USER') }}"
67 password: "WrongPassword@123"
68 validate_certs: false
69 image_uri: "{{ redfish_firmware_image_url_need_reboot }}"
70 job_wait_timeout: 60
71 ignore_errors: true
72 ignore_unreachable: true
73 register: redfish_firmware_error_msg
74
75 - name: TC - 005 - Asserting wrong password
76 ansible.builtin.assert:
77 that: |-
78 ('"HTTP Error 401" in redfish_firmware_out.msg')
79 or
80 ('"urlopen error timed out" in redfish_firmware_out.msg')
81
82 - name: TC - 006 - Providing invalid validate_certs
83 ansible.builtin.import_role:
84 name: redfish_firmware
85 vars:
86 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
87 username: "{{ lookup('env', 'IDRAC_USER') }}"
88 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
89 validate_certs: 'someStringValue'
90 image_uri: "{{ redfish_firmware_image_url_need_reboot }}"
91 job_wait_timeout: 60
92 ignore_errors: true
93 ignore_unreachable: true
94 register: redfish_firmware_error_msg
95
96 - name: TC - 006 - Asserting invalid validate_certs
97 ansible.builtin.assert:
98 that:
99 - '"Valid booleans include" in redfish_firmware_out.msg'
100
101 - name: TC - 007 - Providing invalid local path in image_uri
102 ansible.builtin.import_role:
103 name: redfish_firmware
104 vars:
105 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
106 username: "{{ lookup('env', 'IDRAC_USER') }}"
107 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
108 validate_certs: false
109 image_uri: "/tmp/file_not_exists.iso"
110 job_wait_timeout: 60
111 ignore_errors: true
112 register: redfish_firmware_error_msg
113
114 - name: TC - 007 - Asserting invalid local path in image_uri
115 ansible.builtin.assert:
116 that:
117 - '"No such file or directory" in redfish_firmware_out.msg'
118
119 - name: TC - 008 - Providing invalid HTTP in image_uri
120 ansible.builtin.import_role:
121 name: redfish_firmware
122 vars:
123 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
124 username: "{{ lookup('env', 'IDRAC_USER') }}"
125 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
126 validate_certs: false
127 image_uri: "http://www.example.com"
128 job_wait_timeout: 60
129 ignore_errors: true
130 register: redfish_firmware_error_msg
131
132 - name: TC - 008 - Asserting invalid HTTP in image_uri
133 ansible.builtin.assert:
134 that:
135 - redfish_firmware_out.msg == "Firmware update failed."
136 - not redfish_firmware_out.changed
137
138 - name: TC - 009 - Providing job_wait_timeout as -100 with auto reboot firmware component
139 ansible.builtin.import_role:
140 name: redfish_firmware
141 vars:
142 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
143 username: "{{ lookup('env', 'IDRAC_USER') }}"
144 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
145 validate_certs: false
146 image_uri: "{{ redfish_firmware_image_url_without_reboot }}"
147 job_wait_timeout: -100
148
149 - name: TC - 009 - Asserting job_wait_timeout as -100 with auto reboot firmware component
150 ansible.builtin.assert:
151 that:
152 - redfish_firmware_out.msg == "Successfully submitted the firmware update task."
153 - redfish_firmware_out.changed
154
155 - name: TC - 009 - Waiting for job completion
156 ansible.builtin.uri:
157 url: "https://{{ lookup('env', 'IDRAC_IP') }}/redfish/v1/JobService/Jobs/{{ redfish_firmware_out.task.id }}"
158 validate_certs: "{{ lookup('env', 'VALIDATE_CERTS') }}"
159 method: "GET"
160 user: "{{ lookup('env', 'IDRAC_USER') }}"
161 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
162 headers:
163 Accept: "application/json"
164 Content-Type: "application/json"
165 OData-Version: "4.0"
166 body_format: "json"
167 status_code:
168 - 200
169 return_content: true
170 register: job_result
171 until: job_result.json.JobState == 'Completed' or job_result.json.JobState == 'Failed'
172 retries: 30
173 delay: 10
174 when: redfish_firmware_out.changed # noqa: no-handler
175 ignore_errors: true
176
177 - name: Wait for iDRAC to come up
178 ansible.builtin.include_tasks:
179 file: ../_wait_for_idrac_interface.yml
180 vars:
181 idrac_ip: "{{ lookup('env', 'IDRAC_IP') }}"
182 idrac_user: "{{ lookup('env', 'IDRAC_USER') }}"
183 idrac_password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
184 idrac_port: "{{ lookup('env', 'IDRAC_PORT') }}"
185 validate_certs: false
186
187 - name: TC - 009 - Waiting for job completion after iDRAC came up
188 ansible.builtin.uri:
189 url: "https://{{ lookup('env', 'IDRAC_IP') }}/redfish/v1/JobService\
190 /Jobs/{{ redfish_firmware_out.task.id }}"
191 validate_certs: "{{ lookup('env', 'VALIDATE_CERTS') }}"
192 force_basic_auth: true
193 method: "GET"
194 user: "{{ lookup('env', 'IDRAC_USER') }}"
195 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
196 headers:
197 Accept: "application/json"
198 Content-Type: "application/json"
199 OData-Version: "4.0"
200 body_format: "json"
201 status_code:
202 - 200
203 return_content: true
204 register: job_result
205 until: job_result.json.JobState == 'Completed' or
206 job_result.json.JobState == 'Failed'
207 retries: 30
208 delay: 10
209 when: redfish_firmware_out.changed # noqa: no-handler