generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathmain.yml
232 lines (201 loc) · 7.92 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
---
- name: Define helm versions to test
set_fact:
helm_versions:
- 3.8.0
- 3.1.0
- 3.0.0
- 2.3.0
- block:
- name: Create temp directory for helm tests
tempfile:
state: directory
register: tmpdir
- name: Set temp directory fact
set_fact:
temp_dir: "{{ tmpdir.path }}"
- set_fact:
destination: "{{ temp_dir }}"
- name: Create Helm directories
file:
state: directory
path: "{{ temp_dir }}/{{ item }}"
with_items: "{{ helm_versions }}"
- name: Unarchive Helm binary
unarchive:
src: "https://get.helm.sh/helm-v{{ item }}-linux-amd64.tar.gz"
dest: "{{ temp_dir }}/{{ item }}"
remote_src: yes
with_items: "{{ helm_versions }}"
# Testing helm pull with helm version == 2.3.0
- block:
- name: Assert that helm pull failed with helm <= 3.0.0
helm_pull:
binary_path: "{{ helm_path }}"
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
destination: "{{ destination }}"
ignore_errors: true
register: _result
- name: assert that module failed with proper message
assert:
that:
- _result is failed
- _result.msg == "This module requires helm >= 3.0.0, current version is 2.3.0"
vars:
helm_path: "{{ temp_dir }}/2.3.0/linux-amd64/helm"
# Testing helm pull with helm version == 3.0.0
- block:
- name: Download chart using chart_ssl_cert_file
helm_pull:
binary_path: "{{ helm_path }}"
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
destination: "{{ destination }}"
chart_ssl_cert_file: ssl_cert_file
ignore_errors: true
check_mode: true
register: _result
- name: assert that module failed with proper message
assert:
that:
- _result is failed
- _result.msg == "Parameter chart_ssl_cert_file requires helm >= 3.1.0, current version is 3.0.0"
- name: Download chart using chart_ssl_key_file
helm_pull:
binary_path: "{{ helm_path }}"
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
destination: "{{ destination }}"
chart_ssl_key_file: ssl_key_file
ignore_errors: true
check_mode: true
register: _result
- name: assert that module failed with proper message
assert:
that:
- _result is failed
- _result.msg == "Parameter chart_ssl_key_file requires helm >= 3.1.0, current version is 3.0.0"
- name: Download chart using chart_ca_cert
helm_pull:
binary_path: "{{ helm_path }}"
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
destination: "{{ destination }}"
chart_ca_cert: ca_cert_file
ignore_errors: true
check_mode: true
register: _result
- name: assert that module failed with proper message
assert:
that:
- _result is failed
- _result.msg == "Parameter chart_ca_cert requires helm >= 3.1.0, current version is 3.0.0"
vars:
helm_path: "{{ temp_dir }}/3.0.0/linux-amd64/helm"
# Testing helm pull with helm version == 3.1.0
- block:
- name: Download chart using chart_ssl_cert_file, chart_ca_cert, chart_ssl_key_file
helm_pull:
binary_path: "{{ helm_path }}"
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
destination: "{{ destination }}"
chart_ssl_cert_file: ssl_cert_file
chart_ssl_key_file: ssl_key_file
chart_ca_cert: ca_cert_file
check_mode: true
register: _result
- name: assert that module failed with proper message
assert:
that:
- _result is changed
- '"--ca-file ca_cert_file" in _result.command'
- '"--cert-file ssl_cert_file" in _result.command'
- '"--key-file ssl_key_file" in _result.command'
- name: Download chart using skip_tls_certs_check
helm_pull:
binary_path: "{{ helm_path }}"
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
destination: "{{ destination }}"
skip_tls_certs_check: true
ignore_errors: true
check_mode: true
register: _result
- name: assert that module failed with proper message
assert:
that:
- _result is failed
- _result.msg == "Parameter skip_tls_certs_check requires helm >= 3.3.0, current version is 3.1.0"
vars:
helm_path: "{{ temp_dir }}/3.1.0/linux-amd64/helm"
# Testing helm pull with helm version == 3.8.0
- block:
# Test options chart_version, verify, pass-credentials, provenance, untar_chart
# skip_tls_certs_check, repo_url, repo_username, repo_password
- name: Testing chart version
helm_pull:
binary_path: "{{ helm_path }}"
chart_ref: redis
destination: "{{ destination }}"
chart_version: "0.2.1"
verify_chart: true
pass_credentials: true
provenance: true
untar_chart: true
skip_tls_certs_check: true
repo_url: "https://charts.bitnami.com/bitnami"
repo_username: ansible
repo_password: testing123
verify_chart_keyring: pubring.gpg
check_mode: true
register: _result
- assert:
that:
- _result is changed
- '"--version 0.2.1" in _result.command'
- '"--verify" in _result.command'
- '"--pass-credentials" in _result.command'
- '"--prov" in _result.command'
- '"--untar" in _result.command'
- '"--insecure-skip-tls-verify" in _result.command'
- '"--repo https://charts.bitnami.com/bitnami" in _result.command'
- '"--username ansible" in _result.command'
- '"--password ***" in _result.command'
- '"--keyring pubring.gpg" in _result.command'
- name: Download chart using chart_ref
helm_pull:
binary_path: "{{ helm_path }}"
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
destination: "{{ destination }}"
register: _result
- name: Check chart on local filesystem
stat:
path: "{{ destination }}/grafana-5.6.0.tgz"
register: _chart
- name: Validate that chart was downloaded
assert:
that:
- _result is changed
- _chart.stat.exists
- _chart.stat.isreg
- name: Download chart using untar_chart
helm_pull:
binary_path: "{{ helm_path }}"
chart_ref: redis
destination: "{{ destination }}"
repo_url: "https://charts.bitnami.com/bitnami"
untar_chart: true
register: _result
- name: Check chart on local filesystem
stat:
path: "{{ destination }}/redis"
register: _chart
- name: Validate that chart was downloaded
assert:
that:
- _result is changed
- _chart.stat.exists
- _chart.stat.isdir
vars:
helm_path: "{{ temp_dir }}/3.8.0/linux-amd64/helm"
always:
- name: Delete temp directory
file:
state: absent
path: "{{ temp_dir }}"