Debian Codegraph @

ansible_collections/dellemc/openmanage/roles/idrac_certificate/molecule/CustomCertificate-10564/converge.yml

raw symbols SCIP
1 ---
2 - name: Converge
3 hosts: all
4 gather_facts: false
5 vars:
6 custom_certificate_failure: {}
7 custom_cert_name: "{{ lookup('env', 'custom_cert_name') }}"
8 cust_crt_name_pass: "{{ lookup('env', 'custom_cert_name_pass') }}"
9 import_cert_path: "{{ lookup('env', 'path_for_import_cert') }}"
10
11 tasks:
12 - name: Fetching firmware version for IDRAC
13 ansible.builtin.include_tasks:
14 file: ../__extract_firmware_version.yml
15 vars:
16 idrac_ip: "{{ lookup('env', 'IDRAC_IP') }}"
17 idrac_user: "{{ lookup('env', 'IDRAC_USER') }}"
18 idrac_password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
19
20 - name: Import CUSTOMCERTIFICATE without passphrase
21 block:
22 - name: Fetching Custom certificate from share
23 ansible.builtin.include_tasks:
24 file: ../__get_helper.yml
25 vars:
26 idrac_cert_name:
27 - "{{ custom_cert_name }}"
28
29 - name: Import a custom certificate
30 ansible.builtin.import_role:
31 name: dellemc.openmanage.idrac_certificate
32 vars:
33 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
34 username: "{{ lookup('env', 'IDRAC_USER') }}"
35 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
36 validate_certs: false
37 command: "import"
38 certificate_type: "CUSTOMCERTIFICATE"
39 certificate_path: "{{ import_cert_path }}{{ custom_cert_name }}"
40 passphrase: ""
41
42 - name: Waiting for idrac readiness
43 ansible.builtin.wait_for:
44 timeout: 60
45 when:
46 - not ansible_check_mode
47 - idrac_certificate_out is defined
48 - idrac_certificate_out.changed
49
50 - name: Asserting operation with check mode.
51 ansible.builtin.assert:
52 that: idrac_certificate_out.msg == "Changes found to be applied."
53 when: ansible_check_mode
54
55 - name: Asserting operation with Normal/Idempotence
56 mode (import certificate)
57 ansible.builtin.assert:
58 that: idrac_certificate_out.msg == "Successfully performed the
59 'import' certificate operation.iDRAC
60 has been reset successfully."
61 when: not ansible_check_mode and idrac_certificate_out.changed
62
63 rescue:
64 - name: Set the failure messages for CUSTOMECERT
65 ansible.builtin.set_fact:
66 custom_certificate_failure: "{{ custom_certificate_failure |
67 combine({'CUSTOMCERTIFICATE_WITHOUT_PASS_IMPORT':
68 {'msg': ansible_failed_result.msg,
69 'failed_task_name': ansible_failed_task.name}}) }}"
70 always:
71 - name: Deleting the directory
72 ansible.builtin.include_tasks:
73 file: ../__delete_directory.yml
74
75 - name: Export CUSTOMCERTIFICATE
76 when:
77 - idrac_certificate_firmware_version is defined
78
79 block:
80 - name: Fetching Custom certificate from share
81 ansible.builtin.include_tasks:
82 file: ../__get_helper.yml
83 vars:
84 idrac_cert_name:
85 - "{{ custom_cert_name }}"
86
87 - name: Export a custom certificate
88 ansible.builtin.import_role:
89 name: dellemc.openmanage.idrac_certificate
90 vars:
91 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
92 username: "{{ lookup('env', 'IDRAC_USER') }}"
93 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
94 validate_certs: false
95 command: "export"
96 certificate_type: "CUSTOMCERTIFICATE"
97 certificate_path: "{{ import_cert_path }}"
98 when: not ansible_check_mode
99
100 - name: Setting up CustomCertificate certificate path for exported file
101 when: idrac_certificate_out is defined
102 and idrac_certificate_out.certificate_path is defined
103 ansible.builtin.stat:
104 path: "{{ idrac_certificate_out.certificate_path }}"
105 register: csc_cert_file
106 no_log: true
107
108 - name: Asserting operation with Normal/Idempotence mode.
109 ansible.builtin.assert:
110 that:
111 - csc_cert_file.stat.exists
112 - not idrac_certificate_out.changed
113 - not idrac_certificate_out.failed
114 - idrac_certificate_out.msg == "Successfully performed the
115 'export' certificate operation."
116 when: not ansible_check_mode and not idrac_certificate_out.changed
117
118 rescue:
119 - name: Set the failure messages for CUSTOMECERT
120 ansible.builtin.set_fact:
121 custom_certificate_failure: "{{ custom_certificate_failure |
122 combine({'CUSTOMCERTIFICATE_EXPORT':
123 {'msg': ansible_failed_result.msg,
124 'failed_task_name': ansible_failed_task.name}}) }}"
125
126 always:
127 - name: Deleting the directory
128 ansible.builtin.include_tasks:
129 file: ../__delete_directory.yml
130
131 - name: Import CUSTOMCERTIFICATE with passphrase
132 when: idrac_certificate_firmware_version is defined
133 and cust_crt_name_pass is defined
134 block:
135 - name: Fetching Custom certificate from share
136 ansible.builtin.include_tasks: ../__get_helper.yml
137 vars:
138 idrac_cert_name:
139 - "{{ cust_crt_name_pass }}"
140
141 - name: Import a custom certificate with passphrase
142 ansible.builtin.import_role:
143 name: dellemc.openmanage.idrac_certificate
144 vars:
145 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
146 username: "{{ lookup('env', 'IDRAC_USER') }}"
147 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
148 validate_certs: false
149 command: "import"
150 certificate_type: "CUSTOMCERTIFICATE"
151 certificate_path: "{{ import_cert_path }}{{ cust_crt_name_pass }}"
152 passphrase: "{{ lookup('env', 'passphrase') }}"
153
154 - name: Asserting operation with check mode.
155 ansible.builtin.assert:
156 that: idrac_certificate_out.msg == "Changes found to be applied."
157 when: ansible_check_mode
158
159 - name: Waiting for idrac readiness
160 ansible.builtin.wait_for:
161 timeout: 60
162 when:
163 - not ansible_check_mode
164 - idrac_certificate_out is defined
165 - idrac_certificate_out.changed
166
167 - name: Asserting operation with Normal/Idempotence mode
168 ansible.builtin.assert:
169 that: idrac_certificate_out.msg == "Successfully performed the
170 'import' certificate operation.iDRAC
171 has been reset successfully."
172 when: not ansible_check_mode and idrac_certificate_out.changed
173
174 rescue:
175 - name: Set the failure messages for CUSTOMECERT
176 ansible.builtin.set_fact:
177 custom_certificate_failure: "{{ custom_certificate_failure |
178 combine({'CUSTOMCERTIFICATE_WITH_PASS_IMPORT':
179 {'msg': ansible_failed_result.msg,
180 'failed_task_name': ansible_failed_task.name}}) }}"
181
182 - name: Collecting failure
183 ansible.builtin.debug:
184 var: custom_certificate_failure
185 when: custom_certificate_failure is defined
186 failed_when: true
187
188 always:
189 - name: Deleting the directory
190 ansible.builtin.include_tasks:
191 file: ../__delete_directory.yml