generate_secrets.yaml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. ---
  2. - name: Retrieving the cert to use when generating secrets for the logging components
  3. slurp: src="{{generated_certs_dir}}/{{item.file}}"
  4. register: key_pairs
  5. with_items:
  6. - { name: "ca_file", file: "ca.crt" }
  7. - { name: "kibana_key", file: "system.logging.kibana.key"}
  8. - { name: "kibana_cert", file: "system.logging.kibana.crt"}
  9. - { name: "curator_key", file: "system.logging.curator.key"}
  10. - { name: "curator_cert", file: "system.logging.curator.crt"}
  11. - { name: "fluentd_key", file: "system.logging.fluentd.key"}
  12. - { name: "fluentd_cert", file: "system.logging.fluentd.crt"}
  13. - { name: "kibana_internal_key", file: "kibana-internal.key"}
  14. - { name: "kibana_internal_cert", file: "kibana-internal.crt"}
  15. - { name: "server_tls", file: "server-tls.json"}
  16. - name: Generating secrets for logging components
  17. template: src=secret.j2 dest={{mktemp.stdout}}/templates/{{secret_name}}-secret.yaml
  18. vars:
  19. secret_name: "logging-{{component}}"
  20. secret_key_file: "{{component}}_key"
  21. secret_cert_file: "{{component}}_cert"
  22. secrets:
  23. - {key: ca, value: "{{key_pairs | entry_from_named_pair('ca_file')| b64decode }}"}
  24. - {key: key, value: "{{key_pairs | entry_from_named_pair(secret_key_file)| b64decode }}"}
  25. - {key: cert, value: "{{key_pairs | entry_from_named_pair(secret_cert_file)| b64decode }}"}
  26. secret_keys: ["ca", "cert", "key"]
  27. with_items:
  28. - kibana
  29. - curator
  30. - fluentd
  31. loop_control:
  32. loop_var: component
  33. check_mode: no
  34. changed_when: no
  35. - name: Retrieving the cert to use when generating secrets for mux
  36. slurp: src="{{generated_certs_dir}}/{{item.file}}"
  37. register: mux_key_pairs
  38. with_items:
  39. - { name: "ca_file", file: "ca.crt" }
  40. - { name: "mux_key", file: "system.logging.mux.key"}
  41. - { name: "mux_cert", file: "system.logging.mux.crt"}
  42. - { name: "mux_shared_key", file: "mux_shared_key"}
  43. when: openshift_logging_use_mux
  44. - name: Generating secrets for mux
  45. template: src=secret.j2 dest={{mktemp.stdout}}/templates/{{secret_name}}-secret.yaml
  46. vars:
  47. secret_name: "logging-{{component}}"
  48. secret_key_file: "{{component}}_key"
  49. secret_cert_file: "{{component}}_cert"
  50. secrets:
  51. - {key: ca, value: "{{mux_key_pairs | entry_from_named_pair('ca_file')| b64decode }}"}
  52. - {key: key, value: "{{mux_key_pairs | entry_from_named_pair(secret_key_file)| b64decode }}"}
  53. - {key: cert, value: "{{mux_key_pairs | entry_from_named_pair(secret_cert_file)| b64decode }}"}
  54. - {key: shared_key, value: "{{mux_key_pairs | entry_from_named_pair('mux_shared_key')| b64decode }}"}
  55. secret_keys: ["ca", "cert", "key", "shared_key"]
  56. with_items:
  57. - mux
  58. loop_control:
  59. loop_var: component
  60. check_mode: no
  61. changed_when: no
  62. when: openshift_logging_use_mux
  63. - name: Generating secrets for kibana proxy
  64. template: src=secret.j2 dest={{mktemp.stdout}}/templates/{{secret_name}}-secret.yaml
  65. vars:
  66. secret_name: logging-kibana-proxy
  67. secrets:
  68. - {key: oauth-secret, value: "{{oauth_secret}}"}
  69. - {key: session-secret, value: "{{session_secret}}"}
  70. - {key: server-key, value: "{{kibana_key_file}}"}
  71. - {key: server-cert, value: "{{kibana_cert_file}}"}
  72. - {key: server-tls.json, value: "{{server_tls_file}}"}
  73. secret_keys: ["server-tls.json", "server-key", "session-secret", "oauth-secret", "server-cert"]
  74. kibana_key_file: "{{key_pairs | entry_from_named_pair('kibana_internal_key')| b64decode }}"
  75. kibana_cert_file: "{{key_pairs | entry_from_named_pair('kibana_internal_cert')| b64decode }}"
  76. server_tls_file: "{{key_pairs | entry_from_named_pair('server_tls')| b64decode }}"
  77. check_mode: no
  78. changed_when: no
  79. - name: Generating secrets for elasticsearch
  80. command: >
  81. {{openshift.common.client_binary}} --config={{ mktemp.stdout }}/admin.kubeconfig secrets new {{secret_name}}
  82. key={{generated_certs_dir}}/logging-es.jks truststore={{generated_certs_dir}}/truststore.jks
  83. searchguard.key={{generated_certs_dir}}/elasticsearch.jks searchguard.truststore={{generated_certs_dir}}/truststore.jks
  84. admin-key={{generated_certs_dir}}/system.admin.key admin-cert={{generated_certs_dir}}/system.admin.crt
  85. admin-ca={{generated_certs_dir}}/ca.crt admin.jks={{generated_certs_dir}}/system.admin.jks -o yaml
  86. vars:
  87. secret_name: logging-elasticsearch
  88. secret_keys: ["admin-cert", "searchguard.key", "admin-ca", "key", "truststore", "admin-key", "searchguard.truststore"]
  89. register: logging_es_secret
  90. check_mode: no
  91. changed_when: no
  92. - copy: content="{{logging_es_secret.stdout}}" dest={{mktemp.stdout}}/templates/logging-elasticsearch-secret.yaml
  93. when: logging_es_secret.stdout is defined
  94. check_mode: no
  95. changed_when: no
  96. - name: Retrieving the cert to use when generating secrets for Elasticsearch external route
  97. slurp: src="{{generated_certs_dir}}/{{item.file}}"
  98. register: es_key_pairs
  99. with_items:
  100. - { name: "ca_file", file: "ca.crt" }
  101. - { name: "es_key", file: "system.logging.es.key"}
  102. - { name: "es_cert", file: "system.logging.es.crt"}
  103. when: openshift_logging_es_allow_external | bool
  104. - name: Generating secrets for Elasticsearch external route
  105. template: src=secret.j2 dest={{mktemp.stdout}}/templates/{{secret_name}}-secret.yaml
  106. vars:
  107. secret_name: "logging-{{component}}"
  108. secret_key_file: "{{component}}_key"
  109. secret_cert_file: "{{component}}_cert"
  110. secrets:
  111. - {key: ca, value: "{{es_key_pairs | entry_from_named_pair('ca_file')| b64decode }}"}
  112. - {key: key, value: "{{es_key_pairs | entry_from_named_pair(secret_key_file)| b64decode }}"}
  113. - {key: cert, value: "{{es_key_pairs | entry_from_named_pair(secret_cert_file)| b64decode }}"}
  114. secret_keys: ["ca", "cert", "key"]
  115. with_items:
  116. - es
  117. loop_control:
  118. loop_var: component
  119. check_mode: no
  120. changed_when: no
  121. when: openshift_logging_es_allow_external | bool