blob: 6bfeccf614c492811a9ea37b907f3af2983adc8c (
plain)
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
|
---
# we will ensure our secrets and configmaps are set up here first
- name: Checking for ca.key
stat: path="{{generated_certs_dir}}/ca.key"
register: ca_key_file
check_mode: no
- name: Checking for ca.crt
stat: path="{{generated_certs_dir}}/ca.crt"
register: ca_cert_file
check_mode: no
- name: Checking for ca.serial.txt
stat: path="{{generated_certs_dir}}/ca.serial.txt"
register: ca_serial_file
check_mode: no
- name: Generate certificates
command: >
{{ openshift.common.admin_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig ca create-signer-cert
--key={{generated_certs_dir}}/ca.key --cert={{generated_certs_dir}}/ca.crt
--serial={{generated_certs_dir}}/ca.serial.txt --name=logging-signer-test
check_mode: no
when:
- not ca_key_file.stat.exists
- not ca_cert_file.stat.exists
- not ca_serial_file.stat.exists
- name: Checking for signing.conf
stat: path="{{generated_certs_dir}}/signing.conf"
register: signing_conf_file
check_mode: no
- block:
- copy: src=signing.conf dest={{generated_certs_dir}}/signing.conf
check_mode: no
- lineinfile: "dest={{generated_certs_dir}}/signing.conf regexp='# Top dir$' line='dir = {{generated_certs_dir}} # Top dir'"
check_mode: no
when:
- not signing_conf_file.stat.exists
- include: procure_server_certs.yaml
loop_control:
loop_var: cert_info
with_items:
- procure_component: kibana
- procure_component: kibana-ops
- procure_component: kibana-internal
hostnames: "kibana, kibana-ops, {{openshift_logging_kibana_hostname}}, {{openshift_logging_kibana_ops_hostname}}"
# - include: procure_server_certs.yaml
# vars:
# - procure_component: kibana
# - include: procure_server_certs.yaml
# vars:
# - procure_component: kibana-ops
# - include: procure_server_certs.yaml
# vars:
# - procure_component: kibana-internal
# - hostnames: "kibana, kibana-ops, {{openshift_logging_kibana_hostname}}, {{openshift_logging_kibana_ops_hostname}}"
- name: Copy proxy TLS configuration file
copy: src=server-tls.json dest={{generated_certs_dir}}/server-tls.json
when: server_tls_json is undefined
check_mode: no
- name: Copy proxy TLS configuration file
copy: content="{{server_tls_json}}" dest={{generated_certs_dir}}/server-tls.json
when: server_tls_json is defined
check_mode: no
- name: Checking for ca.db
stat: path="{{generated_certs_dir}}/ca.db"
register: ca_db_file
check_mode: no
- copy: content="" dest={{generated_certs_dir}}/ca.db
check_mode: no
when:
- not ca_db_file.stat.exists
- name: Checking for ca.crt.srl
stat: path="{{generated_certs_dir}}/ca.crt.srl"
register: ca_cert_srl_file
check_mode: no
- copy: content="" dest={{generated_certs_dir}}/ca.crt.srl
check_mode: no
when:
- not ca_cert_srl_file.stat.exists
- name: Generate PEM certs
include: generate_pems.yaml component={{node_name}}
with_items:
- system.logging.fluentd
- system.logging.kibana
- system.logging.curator
- system.admin
loop_control:
loop_var: node_name
- name: Check for jks-generator service account
command: >
{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get serviceaccount/jks-generator --no-headers -n {{openshift_logging_namespace}}
register: serviceaccount_result
ignore_errors: yes
when: not ansible_check_mode
- name: Create jks-generator service account
command: >
{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig create serviceaccount jks-generator -n {{openshift_logging_namespace}}
when: not ansible_check_mode and "not found" in serviceaccount_result.stderr
- name: Check for hostmount-anyuid scc entry
shell: >
{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get scc hostmount-anyuid -o go-template='{{ '{{' }}.users{{ '}}' }}' |
grep system:serviceaccount:{{openshift_logging_namespace}}:jks-generator
register: scc_result
ignore_errors: yes
when: not ansible_check_mode
- name: Add to hostmount-anyuid scc
command: >
{{ openshift.common.admin_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig policy add-scc-to-user hostmount-anyuid -z jks-generator -n {{openshift_logging_namespace}}
when: not ansible_check_mode and scc_result.rc == 1
- name: Copy jks script
copy:
src: generate-jks.sh
dest: "{{generated_certs_dir}}/generate-jks.sh"
- name: Generate JKS chains
template:
src: jks_pod.j2
dest: "{{mktemp.stdout}}/jks_pod.yaml"
- name: create pod
shell: >
{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig create -f {{mktemp.stdout}}/jks_pod.yaml -n {{openshift_logging_namespace}}
register: podoutput
- shell: >
echo {{podoutput.stdout}} | awk -v podname='\\\".*\\\"' '{print $2}'
register: podname
- shell: >
{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get pod {{podname.stdout}} -o go-template='{{ '{{' }}index .status "phase"{{ '}}' }}' -n {{openshift_logging_namespace}}
register: result
until: result.stdout.find("Succeeded") != -1
retries: 5
delay: 10
- name: Generate proxy session
shell: tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 200
register: session_secret
check_mode: no
- name: Generate oauth client secret
shell: tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 64
register: oauth_secret
check_mode: no
|