File tree Expand file tree Collapse file tree 2 files changed +42
-5
lines changed Expand file tree Collapse file tree 2 files changed +42
-5
lines changed Original file line number Diff line number Diff line change 9
9
- jo_image_tag|length > 0
10
10
- jo_image_tag != 'SetMe'
11
11
12
- - name : Deploy using Kubernetes config
12
+ - name : Deploy (with k8s kubeconfig)
13
+ block :
14
+
15
+ - name : Deploy (k8s kubeconfig)
16
+ ansible.builtin.include_tasks : deploy.yaml
17
+ when : jo_state|string == 'present'
18
+ - name : Undeploy (k8s kubeconfig)
19
+ ansible.builtin.include_tasks : undeploy.yaml
20
+ when : jo_state|string == 'absent'
21
+
13
22
module_defaults :
14
23
group/k8s :
15
24
kubeconfig : " {{ jo_kubeconfig }}"
25
+ when : jo_kubeconfig != 'SetMe'
26
+
27
+ - name : Deploy (with k8s host and API key)
16
28
block :
17
29
18
- - name : Deploy
30
+ - name : Deploy (k8s API key)
19
31
ansible.builtin.include_tasks : deploy.yaml
20
32
when : jo_state|string == 'present'
21
- - name : Undeploy
33
+ - name : Undeploy (k8s API key)
22
34
ansible.builtin.include_tasks : undeploy.yaml
23
35
when : jo_state|string == 'absent'
36
+
37
+ when : jo_kubeconfig == 'SetMe'
Original file line number Diff line number Diff line change 18
18
ansible.builtin.debug :
19
19
var : freeze.stdout_lines
20
20
21
- - name : Assert kubeconfig defined
21
+ # Kubernetes credentials ------------------------------------------------------
22
+
23
+ # We don't use the Kubernetes credentials directly,
24
+ # but we load them into variables here from their
25
+ # expected environment variables so that we can assert they've been set.
26
+
27
+ - name : Set initial authentication facts
28
+ set_fact :
29
+ k8s_auth_host : " {{ lookup('env', 'K8S_AUTH_HOST') }}"
30
+ k8s_auth_api_key : " {{ lookup('env', 'K8S_AUTH_API_KEY') }}"
31
+
32
+ # A kubernetes host and an API key must be set.
33
+ # Either environment variables will have been set by the user
34
+ # or AWX 'kubernetes' credentials will have injected them.
35
+ # Either way the variables 'k8s_auth_host' and
36
+ # 'k8s_auth_api_key' must have been set.
37
+ - name : Assert kubernetes authentication (no kubeconfig)
38
+ assert :
39
+ that :
40
+ - k8s_auth_host|string|length > 0
41
+ - k8s_auth_api_key|string|length > 0
42
+ when : jo_kubeconfig == 'SetMe'
43
+
44
+ - name : Assert kubeconfig defined (kubeconfig)
22
45
ansible.builtin.assert :
23
46
that :
24
47
- jo_kubeconfig|length > 0
25
- - jo_kubeconfig != 'SetMe'
48
+ when : jo_kubeconfig != 'SetMe'
You can’t perform that action at this time.
0 commit comments