summaryrefslogtreecommitdiffstats
path: root/roles/openshift_metrics/tasks/setup_certificate.yaml
blob: 223bd975e3847655647f06c53368fe326a665516 (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
---
- name: generate {{ component }} keys
  command: >
    {{ openshift_client_binary }} adm ca create-server-cert
    --config={{ mktemp.stdout }}/admin.kubeconfig
    --key='{{ mktemp.stdout }}/{{ component }}.key'
    --cert='{{ mktemp.stdout }}/{{ component }}.crt'
    --hostnames='{{ hostnames }}'
    --signer-cert='{{ mktemp.stdout }}/ca.crt'
    --signer-key='{{ mktemp.stdout }}/ca.key'
    --signer-serial='{{ mktemp.stdout }}/ca.serial.txt'

- slurp: src={{item}}
  register: component_certs
  with_items:
    - '{{ mktemp.stdout | quote }}/{{ component|quote }}.key'
    - '{{ mktemp.stdout | quote }}/{{ component|quote }}.crt'

- name: generate {{ component }} certificate
  copy:
    dest: '{{ mktemp.stdout }}/{{ component }}.pem'
    content: "{{ component_certs.results | map(attribute='content') | map('b64decode') | join('')  }}"

- name: generate random password for the {{ component }} keystore
  copy:
    content: "{{ 15 | lib_utils_oo_random_word }}"
    dest: '{{ mktemp.stdout }}/{{ component }}-keystore.pwd'

- slurp: src={{ mktemp.stdout | quote }}/{{ component|quote }}-keystore.pwd
  register: keystore_password

- name: create the {{ component }} pkcs12 from the pem file
  command: >
    openssl pkcs12 -export
    -in '{{ mktemp.stdout }}/{{ component }}.pem'
    -out '{{ mktemp.stdout }}/{{ component }}.pkcs12'
    -name '{{ component }}' -noiter -nomaciter
    -password 'pass:{{keystore_password.content | b64decode }}'

- name: generate random password for the {{ component }} truststore
  copy:
    content: "{{ 15 | lib_utils_oo_random_word }}"
    dest: '{{ mktemp.stdout | quote }}/{{ component|quote }}-truststore.pwd'