Skip to content

Commit 78aa643

Browse files
author
Alan Christie
committed
feat: Initial AWX support
1 parent 5a53799 commit 78aa643

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

roles/operator/tasks/main.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,29 @@
99
- jo_image_tag|length > 0
1010
- jo_image_tag != 'SetMe'
1111

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+
1322
module_defaults:
1423
group/k8s:
1524
kubeconfig: "{{ jo_kubeconfig }}"
25+
when: jo_kubeconfig != 'SetMe'
26+
27+
- name: Deploy (with k8s host and API key)
1628
block:
1729

18-
- name: Deploy
30+
- name: Deploy (k8s API key)
1931
ansible.builtin.include_tasks: deploy.yaml
2032
when: jo_state|string == 'present'
21-
- name: Undeploy
33+
- name: Undeploy (k8s API key)
2234
ansible.builtin.include_tasks: undeploy.yaml
2335
when: jo_state|string == 'absent'
36+
37+
when: jo_kubeconfig == 'SetMe'

roles/operator/tasks/prep.yaml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,31 @@
1818
ansible.builtin.debug:
1919
var: freeze.stdout_lines
2020

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)
2245
ansible.builtin.assert:
2346
that:
2447
- jo_kubeconfig|length > 0
25-
- jo_kubeconfig != 'SetMe'
48+
when: jo_kubeconfig != 'SetMe'

0 commit comments

Comments
 (0)