blob: 9333d341cd62517b9104bec09e30605b069642cf (
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
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
|
---
- name: generate hawkular-metrics certificates
include: setup_certificate.yaml
vars:
component: hawkular-metrics
hostnames: "hawkular-metrics,{{ openshift_metrics_hawkular_hostname }}"
changed_when: no
- name: generate hawkular-cassandra certificates
include: setup_certificate.yaml
vars:
component: hawkular-cassandra
hostnames: hawkular-cassandra
changed_when: no
- slurp: src={{ openshift_metrics_certs_dir }}/hawkular-cassandra-truststore.pwd
register: cassandra_truststore_password
- slurp: src={{ openshift_metrics_certs_dir }}/hawkular-metrics-truststore.pwd
register: hawkular_truststore_password
- stat: path="{{openshift_metrics_certs_dir}}/{{item}}"
register: pwd_file_stat
with_items:
- hawkular-metrics.pwd
- hawkular-metrics.htpasswd
- hawkular-jgroups-keystore.pwd
changed_when: no
- set_fact:
pwd_files: "{{pwd_files | default({}) | combine ({item.item: item.stat}) }}"
with_items: "{{pwd_file_stat.results}}"
changed_when: no
- name: Create temp directory local on control node
local_action: command mktemp -d
register: local_tmp
changed_when: False
- name: generate password for hawkular metrics and jgroups
local_action: copy dest="{{ local_tmp.stdout}}/{{ item }}.pwd" content="{{ 15 | oo_random_word }}"
with_items:
- hawkular-metrics
- hawkular-jgroups-keystore
when: "not pwd_files['{{ item }}.pwd'].exists"
- name: generate htpasswd file for hawkular metrics
local_action: >
shell htpasswd -ci
'{{ local_tmp.stdout }}/hawkular-metrics.htpasswd' hawkular
< '{{ local_tmp.stdout }}/hawkular-metrics.pwd'
when: "not pwd_files['hawkular-metrics.htpasswd'].exists"
- name: copy local generated passwords to target
copy:
src: "{{local_tmp.stdout}}/{{item}}"
dest: "{{openshift_metrics_certs_dir}}/{{item}}"
with_items:
- hawkular-metrics.pwd
- hawkular-metrics.htpasswd
- hawkular-jgroups-keystore.pwd
when: "not pwd_files['{{ item }}'].exists"
- include: import_jks_certs.yaml
- local_action: file path="{{local_tmp.stdout}}" state=absent
changed_when: False
- name: read files for the hawkular-metrics secret
shell: >
printf '%s: ' '{{ item }}'
&& base64 --wrap 0 '{{ openshift_metrics_certs_dir }}/{{ item }}'
register: hawkular_secrets
with_items:
- ca.crt
- hawkular-metrics.crt
- hawkular-metrics.keystore
- hawkular-metrics-keystore.pwd
- hawkular-metrics.truststore
- hawkular-metrics-truststore.pwd
- hawkular-metrics.pwd
- hawkular-metrics.htpasswd
- hawkular-jgroups.keystore
- hawkular-jgroups-keystore.pwd
- hawkular-cassandra.crt
- hawkular-cassandra.pem
- hawkular-cassandra.keystore
- hawkular-cassandra-keystore.pwd
- hawkular-cassandra.truststore
- hawkular-cassandra-truststore.pwd
changed_when: false
- set_fact:
hawkular_secrets: |
{{ hawkular_secrets.results|map(attribute='stdout')|join('
')|from_yaml }}
- name: generate hawkular-metrics-secrets secret template
template:
src: secret.j2
dest: "{{ mktemp.stdout }}/templates/hawkular_metrics_secrets.yaml"
vars:
name: hawkular-metrics-secrets
labels:
metrics-infra: hawkular-metrics
data:
hawkular-metrics.keystore: >
{{ hawkular_secrets['hawkular-metrics.keystore'] }}
hawkular-metrics.keystore.password: >
{{ hawkular_secrets['hawkular-metrics-keystore.pwd'] }}
hawkular-metrics.truststore: >
{{ hawkular_secrets['hawkular-metrics.truststore'] }}
hawkular-metrics.truststore.password: >
{{ hawkular_secrets['hawkular-metrics-truststore.pwd'] }}
hawkular-metrics.keystore.alias: "{{ 'hawkular-metrics'|b64encode }}"
hawkular-metrics.htpasswd.file: >
{{ hawkular_secrets['hawkular-metrics.htpasswd'] }}
hawkular-metrics.jgroups.keystore: >
{{ hawkular_secrets['hawkular-jgroups.keystore'] }}
hawkular-metrics.jgroups.keystore.password: >
{{ hawkular_secrets['hawkular-jgroups-keystore.pwd'] }}
hawkular-metrics.jgroups.alias: "{{ 'hawkular'|b64encode }}"
when: name not in metrics_secrets.stdout_lines
changed_when: no
- name: generate hawkular-metrics-certificate secret template
template:
src: secret.j2
dest: "{{ mktemp.stdout }}/templates/hawkular_metrics_certificate.yaml"
vars:
name: hawkular-metrics-certificate
labels:
metrics-infra: hawkular-metrics
data:
hawkular-metrics.certificate: >
{{ hawkular_secrets['hawkular-metrics.crt'] }}
hawkular-metrics-ca.certificate: >
{{ hawkular_secrets['ca.crt'] }}
when: name not in metrics_secrets.stdout_lines
changed_when: no
- name: generate hawkular-metrics-account secret template
template:
src: secret.j2
dest: "{{ mktemp.stdout }}/templates/hawkular_metrics_account.yaml"
vars:
name: hawkular-metrics-account
labels:
metrics-infra: hawkular-metrics
data:
hawkular-metrics.username: "{{ 'hawkular'|b64encode }}"
hawkular-metrics.password: >
{{ hawkular_secrets['hawkular-metrics.pwd'] }}
when: name not in metrics_secrets.stdout_lines
changed_when: no
- name: generate cassandra secret template
template:
src: secret.j2
dest: "{{ mktemp.stdout }}/templates/cassandra_secrets.yaml"
vars:
name: hawkular-cassandra-secrets
labels:
metrics-infra: hawkular-cassandra
data:
cassandra.keystore: >
{{ hawkular_secrets['hawkular-cassandra.keystore'] }}
cassandra.keystore.password: >
{{ hawkular_secrets['hawkular-cassandra-keystore.pwd'] }}
cassandra.keystore.alias: "{{ 'hawkular-cassandra'|b64encode }}"
cassandra.truststore: >
{{ hawkular_secrets['hawkular-cassandra.truststore'] }}
cassandra.truststore.password: >
{{ hawkular_secrets['hawkular-cassandra-truststore.pwd'] }}
cassandra.pem: >
{{ hawkular_secrets['hawkular-cassandra.pem'] }}
when: name not in metrics_secrets
changed_when: no
- name: generate cassandra-certificate secret template
template:
src: secret.j2
dest: "{{ mktemp.stdout }}/templates/cassandra_certificate.yaml"
vars:
name: hawkular-cassandra-certificate
labels:
metrics-infra: hawkular-cassandra
data:
cassandra.certificate: >
{{ hawkular_secrets['hawkular-cassandra.crt'] }}
cassandra-ca.certificate: >
{{ hawkular_secrets['hawkular-cassandra.pem'] }}
when: name not in metrics_secrets.stdout_lines
changed_when: no
|