generate_pems.yaml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ---
  2. - name: Checking for {{component}}.key
  3. stat:
  4. path: "{{generated_certs_dir}}/{{component}}.key"
  5. get_checksum: false
  6. get_attributes: false
  7. get_mime: false
  8. register: key_file
  9. check_mode: no
  10. - name: Checking for {{component}}.crt
  11. stat:
  12. path: "{{generated_certs_dir}}/{{component}}.crt"
  13. get_checksum: false
  14. get_attributes: false
  15. get_mime: false
  16. register: cert_file
  17. check_mode: no
  18. - name: Creating cert req for {{component}}
  19. command: >
  20. openssl req -out {{generated_certs_dir}}/{{component}}.csr -new -newkey rsa:2048 -keyout {{generated_certs_dir}}/{{component}}.key
  21. -subj "/CN={{component}}/OU=OpenShift/O=Logging/subjectAltName=DNS.1=localhost{{cert_ext.stdout}}" -days 712 -nodes
  22. when:
  23. - not key_file.stat.exists
  24. - cert_ext is defined
  25. - cert_ext.stdout is defined
  26. check_mode: no
  27. - name: Creating cert req for {{component}}
  28. command: >
  29. openssl req -out {{generated_certs_dir}}/{{component}}.csr -new -newkey rsa:2048 -keyout {{generated_certs_dir}}/{{component}}.key
  30. -subj "/CN={{component}}/OU=OpenShift/O=Logging" -days 712 -nodes
  31. when:
  32. - not key_file.stat.exists
  33. - cert_ext is undefined or cert_ext is defined and cert_ext.stdout is undefined
  34. check_mode: no
  35. - name: Sign cert request with CA for {{component}}
  36. command: >
  37. openssl ca -in {{generated_certs_dir}}/{{component}}.csr -notext -out {{generated_certs_dir}}/{{component}}.crt
  38. -config {{generated_certs_dir}}/signing.conf -extensions v3_req -batch -extensions server_ext
  39. when:
  40. - not cert_file.stat.exists
  41. check_mode: no