-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapps.yml
103 lines (88 loc) · 2.57 KB
/
apps.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
---
- name: Create Apps namespace
k8s:
name: demoapps
api_version: v1
kind: Namespace
state: present
wait: yes
wait_condition:
reason: completed
status: "True"
- name: Check to see if config map already exists
k8s_facts:
kind: ConfigMap
namespace: demoapps
name: k8s-app-ssl
register: appsConfigMap
ignore_errors: yes
- name: Set status of configmap
set_fact:
sslConfigMap: "configured"
when: appsConfigMap.resources[0] is defined
- name: Set status of configmap
set_fact:
sslConfigMap: "unconfigured"
when: appsConfigMap.resources[0] is undefined
- name: create configmap
block:
- name: Get POD information for DAP instances
k8s_facts:
kind: pod
namespace: dap
label_selectors:
- role = source
register: dappod
until: dappod.resources[0].status.containerStatuses[0].ready == true
retries: 60
delay: 2
- name: Configure Variable with pod name
set_fact:
sourcePodName: "{{ dappod.resources[0].metadata.name }}"
- name: Get SSL cert
shell: |
kubectl exec -n dap {{ sourcePodName }} -i -- cat /opt/conjur/etc/ssl/{{dapSourceService}}.pem
register: ssl
- name: save SSL cert
local_action: copy content={{ ssl.stdout}} dest={{ playbook_dir }}/files/ssl.pem
- name: create SSL cert config map
shell: |
kubectl -n {{ item }} create configmap k8s-app-ssl --from-file=ssl-certificate={{ playbook_dir }}/files/ssl.pem
with_items:
- demoapps
- name: Delete ssl.pem file
file:
state: absent
path: "{{ playbook_dir }}/files/ssl.pem"
- name: Set status of configmap
set_fact:
sslConfigMap: "configured"
when: sslConfigMap == "unconfigured"
- name: load apps when ssl is configured
block:
- name: find all demo app manifests
find:
paths: "{{ playbook_dir }}/files/manifests/demoapps/"
file_type: file
register: demoApps
- name: turn demoapps into a list
set_fact:
demoAppsManifests: "{{ demoApps.files | map(attribute='path') | list }}"
- name: Load demoapp manifests
k8s:
state: present
src: "{{ appManifest }}"
wait: yes
wait_condition:
reason: completed
status: "True"
loop: "{{ demoAppsManifests }}"
loop_control:
loop_var: appManifest
when: sslConfigMap == "configured"
- name: Configure sidecarInjector
include_tasks: "{{ task }}.yml"
with_items:
- sidecarInjector
loop_control:
loop_var: task