generate_jks.yaml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. ---
  2. # check if pod generated files exist -- if they all do don't run the pod
  3. - when:
  4. - openshift_logging_es_allow_external | default(False)
  5. - openshift_logging_es_hostname | default('') | regex_search('^[0-9]|[.][0-9]')
  6. block:
  7. - name: Report invalid external Elasticsearch hostnames for conclusion
  8. run_once: true
  9. set_stats:
  10. data:
  11. installer_phase_logging:
  12. message: "Elasticsearch external hostname {{ openshift_logging_es_hostname }} contains invalid characters for certificate subject Alt Name. Not adding to Elasticsearch certificate."
  13. - name: Report invalid external Elasticsearch hostnames
  14. debug:
  15. msg: "Elasticsearch external hostname {{ openshift_logging_es_hostname }} contains invalid characters for certificate subject Alt Name. Not adding to Elasticsearch certificate."
  16. - when:
  17. - openshift_logging_es_ops_allow_external | default(False)
  18. - openshift_logging_es_ops_hostname | default('') | regex_search('^[0-9]|[.][0-9]')
  19. block:
  20. - name: Report invalid external Elasticsearch ops hostnames for conclusion
  21. run_once: true
  22. set_stats:
  23. data:
  24. installer_phase_logging:
  25. message: "Elasticsearch external ops hostname {{ openshift_logging_es_ops_hostname }} contains invalid characters for certificate subject Alt Name. Not adding to Elasticsearch certificate."
  26. - name: Report invalid external Elasticsearch ops hostnames
  27. debug:
  28. msg: "Elasticsearch external hostname {{ openshift_logging_es_ops_hostname }} contains invalid characters for certificate subject Alt Name. Not adding to Elasticsearch certificate."
  29. - name: Checking for elasticsearch.jks
  30. stat:
  31. path: "{{generated_certs_dir}}/elasticsearch.jks"
  32. get_checksum: false
  33. get_attributes: false
  34. get_mime: false
  35. register: elasticsearch_jks
  36. check_mode: no
  37. - name: Checking for logging-es.jks
  38. stat:
  39. path: "{{generated_certs_dir}}/logging-es.jks"
  40. get_checksum: false
  41. get_attributes: false
  42. get_mime: false
  43. register: logging_es_jks
  44. check_mode: no
  45. - name: Checking for system.admin.jks
  46. stat:
  47. path: "{{generated_certs_dir}}/system.admin.jks"
  48. get_checksum: false
  49. get_attributes: false
  50. get_mime: false
  51. register: system_admin_jks
  52. check_mode: no
  53. - name: Checking for truststore.jks
  54. stat:
  55. path: "{{generated_certs_dir}}/truststore.jks"
  56. get_checksum: false
  57. get_attributes: false
  58. get_mime: false
  59. register: truststore_jks
  60. check_mode: no
  61. - name: Create placeholder for previously created JKS certs to prevent recreating...
  62. local_action: file path="{{local_tmp.stdout}}/elasticsearch.jks" state=touch mode="u=rw,g=r,o=r"
  63. when: elasticsearch_jks.stat.exists
  64. changed_when: False
  65. become: false
  66. - name: Create placeholder for previously created JKS certs to prevent recreating...
  67. local_action: file path="{{local_tmp.stdout}}/logging-es.jks" state=touch mode="u=rw,g=r,o=r"
  68. when: logging_es_jks.stat.exists
  69. changed_when: False
  70. become: false
  71. - name: Create placeholder for previously created JKS certs to prevent recreating...
  72. local_action: file path="{{local_tmp.stdout}}/system.admin.jks" state=touch mode="u=rw,g=r,o=r"
  73. when: system_admin_jks.stat.exists
  74. changed_when: False
  75. become: false
  76. - name: Create placeholder for previously created JKS certs to prevent recreating...
  77. local_action: file path="{{local_tmp.stdout}}/truststore.jks" state=touch mode="u=rw,g=r,o=r"
  78. when: truststore_jks.stat.exists
  79. changed_when: False
  80. become: false
  81. - name: pulling down signing items from host
  82. fetch:
  83. src: "{{generated_certs_dir}}/{{item}}"
  84. dest: "{{local_tmp.stdout}}/{{item}}"
  85. flat: yes
  86. with_items:
  87. - ca.crt
  88. - ca.key
  89. - ca.serial.txt
  90. - ca.crl.srl
  91. - ca.db
  92. when: not elasticsearch_jks.stat.exists or not logging_es_jks.stat.exists or not system_admin_jks.stat.exists or not truststore_jks.stat.exists
  93. - local_action: template src=signing.conf.j2 dest={{local_tmp.stdout}}/signing.conf
  94. vars:
  95. - top_dir: "{{local_tmp.stdout}}"
  96. become: false
  97. when: not elasticsearch_jks.stat.exists or not logging_es_jks.stat.exists or not system_admin_jks.stat.exists or not truststore_jks.stat.exists
  98. - name: Run JKS generation script
  99. local_action: script generate-jks.sh {{local_tmp.stdout}} {{openshift_logging_namespace}} {{openshift_logging_es_hostname | default()}} {{openshift_logging_es_ops_hostname | default()}}
  100. check_mode: no
  101. become: false
  102. when: not elasticsearch_jks.stat.exists or not logging_es_jks.stat.exists or not system_admin_jks.stat.exists or not truststore_jks.stat.exists
  103. - name: Pushing locally generated JKS certs to remote host...
  104. copy:
  105. src: "{{local_tmp.stdout}}/elasticsearch.jks"
  106. dest: "{{generated_certs_dir}}/elasticsearch.jks"
  107. when: not elasticsearch_jks.stat.exists
  108. - name: Pushing locally generated JKS certs to remote host...
  109. copy:
  110. src: "{{local_tmp.stdout}}/logging-es.jks"
  111. dest: "{{generated_certs_dir}}/logging-es.jks"
  112. when: not logging_es_jks.stat.exists
  113. - name: Pushing locally generated JKS certs to remote host...
  114. copy:
  115. src: "{{local_tmp.stdout}}/system.admin.jks"
  116. dest: "{{generated_certs_dir}}/system.admin.jks"
  117. when: not system_admin_jks.stat.exists
  118. - name: Pushing locally generated JKS certs to remote host...
  119. copy:
  120. src: "{{local_tmp.stdout}}/truststore.jks"
  121. dest: "{{generated_certs_dir}}/truststore.jks"
  122. when: not truststore_jks.stat.exists