generate_certs.yaml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. ---
  2. # we will ensure our secrets and configmaps are set up here first
  3. - name: Checking for ca.key
  4. stat: path="{{generated_certs_dir}}/ca.key"
  5. register: ca_key_file
  6. check_mode: no
  7. - name: Checking for ca.crt
  8. stat: path="{{generated_certs_dir}}/ca.crt"
  9. register: ca_cert_file
  10. check_mode: no
  11. - name: Checking for ca.serial.txt
  12. stat: path="{{generated_certs_dir}}/ca.serial.txt"
  13. register: ca_serial_file
  14. check_mode: no
  15. - name: Generate certificates
  16. command: >
  17. {{ openshift.common.admin_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig ca create-signer-cert
  18. --key={{generated_certs_dir}}/ca.key --cert={{generated_certs_dir}}/ca.crt
  19. --serial={{generated_certs_dir}}/ca.serial.txt --name=logging-signer-test
  20. check_mode: no
  21. become: false
  22. when:
  23. - not ca_key_file.stat.exists
  24. - not ca_cert_file.stat.exists
  25. - not ca_serial_file.stat.exists
  26. - name: Checking for signing.conf
  27. stat: path="{{generated_certs_dir}}/signing.conf"
  28. register: signing_conf_file
  29. check_mode: no
  30. - template: src=signing.conf.j2 dest={{generated_certs_dir}}/signing.conf
  31. vars:
  32. - top_dir: '{{generated_certs_dir}}'
  33. when: not signing_conf_file.stat.exists
  34. - include: procure_server_certs.yaml
  35. loop_control:
  36. loop_var: cert_info
  37. with_items:
  38. - procure_component: kibana
  39. - procure_component: kibana-ops
  40. - procure_component: kibana-internal
  41. hostnames: "kibana, kibana-ops, {{openshift_logging_kibana_hostname}}, {{openshift_logging_kibana_ops_hostname}}"
  42. - include: procure_server_certs.yaml
  43. loop_control:
  44. loop_var: cert_info
  45. with_items:
  46. - procure_component: mux
  47. hostnames: "logging-mux, {{openshift_logging_mux_hostname}}"
  48. when: openshift_logging_use_mux | bool
  49. - include: procure_shared_key.yaml
  50. loop_control:
  51. loop_var: shared_key_info
  52. with_items:
  53. - procure_component: mux
  54. when: openshift_logging_use_mux | bool
  55. - include: procure_server_certs.yaml
  56. loop_control:
  57. loop_var: cert_info
  58. with_items:
  59. - procure_component: es
  60. hostnames: "es, {{openshift_logging_es_hostname}}"
  61. when: openshift_logging_es_allow_external | bool
  62. - include: procure_server_certs.yaml
  63. loop_control:
  64. loop_var: cert_info
  65. with_items:
  66. - procure_component: es-ops
  67. hostnames: "es-ops, {{openshift_logging_es_ops_hostname}}"
  68. when:
  69. - openshift_logging_es_allow_external | bool
  70. - openshift_logging_use_ops | bool
  71. - name: Copy proxy TLS configuration file
  72. copy: src=server-tls.json dest={{generated_certs_dir}}/server-tls.json
  73. when: server_tls_json is undefined
  74. check_mode: no
  75. - name: Copy proxy TLS configuration file
  76. copy: content="{{server_tls_json}}" dest={{generated_certs_dir}}/server-tls.json
  77. when: server_tls_json is defined
  78. check_mode: no
  79. - name: Checking for ca.db
  80. stat: path="{{generated_certs_dir}}/ca.db"
  81. register: ca_db_file
  82. check_mode: no
  83. - copy: content="" dest={{generated_certs_dir}}/ca.db
  84. check_mode: no
  85. when:
  86. - not ca_db_file.stat.exists
  87. - name: Checking for ca.crt.srl
  88. stat: path="{{generated_certs_dir}}/ca.crt.srl"
  89. register: ca_cert_srl_file
  90. check_mode: no
  91. - copy: content="" dest={{generated_certs_dir}}/ca.crt.srl
  92. check_mode: no
  93. when:
  94. - not ca_cert_srl_file.stat.exists
  95. - name: Generate PEM certs
  96. include: generate_pems.yaml component={{node_name}}
  97. with_items:
  98. - system.logging.fluentd
  99. - system.logging.kibana
  100. - system.logging.curator
  101. - system.admin
  102. loop_control:
  103. loop_var: node_name
  104. - name: Generate PEM cert for mux
  105. include: generate_pems.yaml component={{node_name}}
  106. with_items:
  107. - system.logging.mux
  108. loop_control:
  109. loop_var: node_name
  110. when: openshift_logging_use_mux | bool
  111. - name: Generate PEM cert for Elasticsearch external route
  112. include: generate_pems.yaml component={{node_name}}
  113. with_items:
  114. - system.logging.es
  115. loop_control:
  116. loop_var: node_name
  117. when: openshift_logging_es_allow_external | bool
  118. - name: Creating necessary JKS certs
  119. include: generate_jks.yaml
  120. # TODO: make idempotent
  121. - name: Generate proxy session
  122. set_fact: session_secret={{'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'|random_word(200)}}
  123. check_mode: no
  124. # TODO: make idempotent
  125. - name: Generate oauth client secret
  126. set_fact: oauth_secret={{'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'|random_word(64)}}
  127. check_mode: no