setup_certificate.yaml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. ---
  2. - name: generate {{ component }} keys
  3. command: >
  4. {{ openshift_client_binary }} adm ca create-server-cert
  5. --config={{ mktemp.stdout }}/admin.kubeconfig
  6. --key='{{ mktemp.stdout }}/{{ component }}.key'
  7. --cert='{{ mktemp.stdout }}/{{ component }}.crt'
  8. --hostnames='{{ hostnames }}'
  9. --signer-cert='{{ mktemp.stdout }}/ca.crt'
  10. --signer-key='{{ mktemp.stdout }}/ca.key'
  11. --signer-serial='{{ mktemp.stdout }}/ca.serial.txt'
  12. - slurp: src={{item}}
  13. register: component_certs
  14. with_items:
  15. - '{{ mktemp.stdout | quote }}/{{ component|quote }}.key'
  16. - '{{ mktemp.stdout | quote }}/{{ component|quote }}.crt'
  17. - name: generate {{ component }} certificate
  18. copy:
  19. dest: '{{ mktemp.stdout }}/{{ component }}.pem'
  20. content: "{{ component_certs.results | map(attribute='content') | map('b64decode') | join('') }}"
  21. - name: generate random password for the {{ component }} keystore
  22. copy:
  23. content: "{{ 15 | lib_utils_oo_random_word }}"
  24. dest: '{{ mktemp.stdout }}/{{ component }}-keystore.pwd'
  25. - slurp: src={{ mktemp.stdout | quote }}/{{ component|quote }}-keystore.pwd
  26. register: keystore_password
  27. - name: create the {{ component }} pkcs12 from the pem file
  28. command: >
  29. openssl pkcs12 -export
  30. -in '{{ mktemp.stdout }}/{{ component }}.pem'
  31. -out '{{ mktemp.stdout }}/{{ component }}.pkcs12'
  32. -name '{{ component }}' -noiter -nomaciter
  33. -password 'pass:{{keystore_password.content | b64decode }}'
  34. - name: generate random password for the {{ component }} truststore
  35. copy:
  36. content: "{{ 15 | lib_utils_oo_random_word }}"
  37. dest: '{{ mktemp.stdout | quote }}/{{ component|quote }}-truststore.pwd'