Debian Codegraph @

ansible_collections/dellemc/openmanage/roles/idrac_certificate/molecule/CSC-10557/converge.yml

raw symbols SCIP
1 ---
2 - name: Converge
3 hosts: all
4 gather_facts: false
5 vars:
6 ca_cert_path: "{{ lookup('env', 'ca_cert_path') }}"
7 csc_cert_name: "{{ lookup('env', 'csc_certificate') }}"
8 csc_cert_pass_name: "{{ lookup('env', 'csc_passphrase_certificate') }}"
9 import_cert_path: "{{ lookup('env', 'path_for_import_cert') }}"
10 export_cert_path: "{{ lookup('env', 'path_for_export_cert') }}"
11
12 tasks:
13 - name: Fetching CSC certificates from share
14 ansible.builtin.include_tasks:
15 file: ../__get_helper.yml
16 vars:
17 idrac_cert_name:
18 - "{{ csc_cert_name }}"
19
20 - name: Import CSC certificate without passphrase
21 ansible.builtin.import_role:
22 name: dellemc.openmanage.idrac_certificate
23 vars:
24 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
25 username: "{{ lookup('env', 'IDRAC_USER') }}"
26 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
27 validate_certs: false
28 command: "import"
29 certificate_type: "CSC"
30 passphrase: ""
31 certificate_path: "{{ import_cert_path }}{{ csc_cert_name }}"
32
33 - name: Waiting for idrac readiness
34 ansible.builtin.wait_for:
35 timeout: 30
36 when:
37 - not ansible_check_mode
38 - idrac_certificate_out is defined
39 - idrac_certificate_out.changed
40
41 - name: Asserting operation with check mode.
42 ansible.builtin.assert:
43 that: idrac_certificate_out.msg == "Changes found to be applied."
44 when: ansible_check_mode
45
46 - name: Asserting operation with Normal/Idempotence
47 mode (Import certificate).
48 ansible.builtin.assert:
49 that: idrac_certificate_out.msg == "Successfully performed the
50 'import' certificate operation.iDRAC
51 has been reset successfully."
52 when: not ansible_check_mode and idrac_certificate_out.changed
53
54 - name: Export CSC certificate without passphrase
55 ansible.builtin.import_role:
56 name: dellemc.openmanage.idrac_certificate
57 vars:
58 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
59 username: "{{ lookup('env', 'IDRAC_USER') }}"
60 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
61 validate_certs: false
62 command: "export"
63 certificate_type: "CSC"
64 certificate_path: "{{ export_cert_path }}"
65
66 when: not ansible_check_mode
67
68 - name: Setting up CSC certificate path for exported file
69 when: idrac_certificate_out is defined
70 and idrac_certificate_out.certificate_path is defined
71 ansible.builtin.stat:
72 path: "{{ idrac_certificate_out.certificate_path }}"
73 register: csc_cert_file
74 no_log: true
75
76 - name: Asserting operation with Normal/Idempotence
77 mode (Export certificate).
78 ansible.builtin.assert:
79 that:
80 - csc_cert_file.stat.exists
81 - not idrac_certificate_out.changed
82 - not idrac_certificate_out.failed
83 - idrac_certificate_out.msg == "Successfully performed the
84 'export' certificate operation."
85 when: not ansible_check_mode and not idrac_certificate_out.changed
86
87 - name: Fetching CSC certificates from share.
88 ansible.builtin.include_tasks:
89 file: ../__get_helper.yml
90 vars:
91 idrac_cert_name:
92 - "{{ csc_cert_pass_name }}"
93
94 - name: Import CSC certificate with passphrase
95 ansible.builtin.import_role:
96 name: dellemc.openmanage.idrac_certificate
97 vars:
98 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
99 username: "{{ lookup('env', 'IDRAC_USER') }}"
100 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
101 validate_certs: false
102 command: "import"
103 certificate_type: "CSC"
104 passphrase: "{{ lookup('env', 'passphrase') }}"
105 certificate_path: "{{ import_cert_path }}{{ csc_cert_pass_name }}"
106
107 - name: Waiting for idrac readiness.
108 ansible.builtin.wait_for:
109 timeout: 30
110 when:
111 - not ansible_check_mode
112 - idrac_certificate_out is defined
113 - idrac_certificate_out.changed
114
115 - name: Asserting operation with check mode
116 ansible.builtin.assert:
117 that: idrac_certificate_out.msg == "Changes found to be applied."
118 when: ansible_check_mode
119
120 - name: Asserting operation with Normal/Idempotence mode.
121 ansible.builtin.assert:
122 that: idrac_certificate_out.msg == "Successfully performed the
123 'import' certificate operation.iDRAC
124 has been reset successfully."
125 when: not ansible_check_mode and idrac_certificate_out.changed
126
127 - name: Export CSC certificate with passphrase
128 ansible.builtin.import_role:
129 name: dellemc.openmanage.idrac_certificate
130 vars:
131 hostname: "{{ lookup('env', 'IDRAC_IP') }}"
132 username: "{{ lookup('env', 'IDRAC_USER') }}"
133 password: "{{ lookup('env', 'IDRAC_PASSWORD') }}"
134 validate_certs: false
135 command: "export"
136 certificate_type: "CSC"
137 certificate_path: "{{ export_cert_path }}"
138
139 when: not ansible_check_mode
140
141 - name: Setting up CSC certificate path for exported file.
142 when: idrac_certificate_out is defined
143 and idrac_certificate_out.certificate_path is defined
144 ansible.builtin.stat:
145 path: "{{ idrac_certificate_out.certificate_path }}"
146 register: csc_cert_file
147 no_log: true
148
149 - name: Asserting operation with Normal/Idempotence mode
150 ansible.builtin.assert:
151 that:
152 - csc_cert_file.stat.exists
153 - not idrac_certificate_out.changed
154 - not idrac_certificate_out.failed
155 - idrac_certificate_out.msg == "Successfully performed the
156 'export' certificate operation."
157 when: not ansible_check_mode and not idrac_certificate_out.changed
158
159 - name: Deleting the directory
160 ansible.builtin.include_tasks:
161 file: ../__delete_directory.yml