generate_certs.yaml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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_client_binary }} adm --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. when:
  22. - not ca_key_file.stat.exists
  23. - not ca_cert_file.stat.exists
  24. - not ca_serial_file.stat.exists
  25. - name: Checking for signing.conf
  26. stat: path="{{generated_certs_dir}}/signing.conf"
  27. register: signing_conf_file
  28. check_mode: no
  29. - template: src=signing.conf.j2 dest={{generated_certs_dir}}/signing.conf
  30. vars:
  31. - top_dir: '{{generated_certs_dir}}'
  32. when: not signing_conf_file.stat.exists
  33. - include_tasks: procure_server_certs.yaml
  34. loop_control:
  35. loop_var: cert_info
  36. with_items:
  37. - procure_component: kibana
  38. - procure_component: kibana-ops
  39. - procure_component: kibana-internal
  40. hostnames: "kibana, kibana-ops, {{openshift_logging_kibana_hostname}}, {{openshift_logging_kibana_ops_hostname}}"
  41. - include_tasks: procure_server_certs.yaml
  42. loop_control:
  43. loop_var: cert_info
  44. with_items:
  45. - procure_component: mux
  46. hostnames: "logging-mux, {{openshift_logging_mux_hostname}}"
  47. when: openshift_logging_use_mux | bool
  48. - include_tasks: procure_shared_key.yaml
  49. loop_control:
  50. loop_var: shared_key_info
  51. with_items:
  52. - procure_component: mux
  53. when: openshift_logging_use_mux | bool
  54. - include_tasks: procure_server_certs.yaml
  55. loop_control:
  56. loop_var: cert_info
  57. with_items:
  58. - procure_component: es
  59. hostnames: "es, {{openshift_logging_es_hostname}}"
  60. when: openshift_logging_es_allow_external | bool
  61. - include_tasks: procure_server_certs.yaml
  62. loop_control:
  63. loop_var: cert_info
  64. with_items:
  65. - procure_component: es-ops
  66. hostnames: "es-ops, {{openshift_logging_es_ops_hostname}}"
  67. when:
  68. - openshift_logging_es_allow_external | bool
  69. - openshift_logging_use_ops | bool
  70. - name: Copy proxy TLS configuration file
  71. copy: src=server-tls.json dest={{generated_certs_dir}}/server-tls.json
  72. when: server_tls_json is undefined
  73. check_mode: no
  74. - name: Copy proxy TLS configuration file
  75. copy: content="{{server_tls_json}}" dest={{generated_certs_dir}}/server-tls.json
  76. when: server_tls_json is defined
  77. check_mode: no
  78. - name: Checking for ca.db
  79. stat: path="{{generated_certs_dir}}/ca.db"
  80. register: ca_db_file
  81. check_mode: no
  82. - copy: content="" dest={{generated_certs_dir}}/ca.db
  83. check_mode: no
  84. when:
  85. - not ca_db_file.stat.exists
  86. - name: Checking for ca.crt.srl
  87. stat: path="{{generated_certs_dir}}/ca.crt.srl"
  88. register: ca_cert_srl_file
  89. check_mode: no
  90. - copy: content="" dest={{generated_certs_dir}}/ca.crt.srl
  91. check_mode: no
  92. when:
  93. - not ca_cert_srl_file.stat.exists
  94. - name: Generate PEM certs
  95. include_tasks: generate_pems.yaml component={{node_name}}
  96. with_items:
  97. - system.logging.fluentd
  98. - system.logging.kibana
  99. - system.logging.curator
  100. - system.admin
  101. loop_control:
  102. loop_var: node_name
  103. - name: Generate PEM cert for mux
  104. include_tasks: generate_pems.yaml component={{node_name}}
  105. with_items:
  106. - system.logging.mux
  107. loop_control:
  108. loop_var: node_name
  109. when: openshift_logging_use_mux | bool
  110. - name: Generate PEM cert for Elasticsearch external route
  111. include_tasks: generate_pems.yaml component={{node_name}}
  112. with_items:
  113. - system.logging.es
  114. loop_control:
  115. loop_var: node_name
  116. when: openshift_logging_es_allow_external | bool
  117. - name: Creating necessary JKS certs
  118. include_tasks: generate_jks.yaml
  119. # TODO: make idempotent
  120. - name: Generate proxy session
  121. set_fact: session_secret={{ 200 | lib_utils_oo_random_word}}
  122. check_mode: no
  123. # TODO: make idempotent
  124. - name: Generate oauth client secret
  125. set_fact: oauth_secret={{ 64 | lib_utils_oo_random_word}}
  126. check_mode: no