main.yaml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. ---
  2. - name: Ensure that ElasticSearch has nodes to run on
  3. import_role:
  4. name: openshift_control_plane
  5. tasks_from: ensure_nodes_matching_selector.yml
  6. vars:
  7. openshift_master_ensure_nodes_selector: "{{ openshift_logging_es_nodeselector | map_to_pairs }}"
  8. openshift_master_ensure_nodes_service: Elasticsearch
  9. - name: Validate Elasticsearch cluster size
  10. fail: msg="The openshift_logging_es_cluster_size may only be scaled down manually. Please see official documentation on how to do this."
  11. when: openshift_logging_facts.elasticsearch.deploymentconfigs | length > openshift_logging_es_cluster_size|int
  12. - name: Validate Elasticsearch Ops cluster size
  13. fail: msg="The openshift_logging_es_ops_cluster_size may only be scaled down manually. Please see official documentation on how to do this."
  14. when: openshift_logging_facts.elasticsearch_ops.deploymentconfigs | length > openshift_logging_es_ops_cluster_size|int
  15. - fail:
  16. msg: Invalid deployment type, one of ['data-master', 'data-client', 'master', 'client'] allowed
  17. when: not openshift_logging_elasticsearch_deployment_type in __allowed_es_types
  18. - set_fact:
  19. elasticsearch_name: "{{ 'logging-elasticsearch' ~ ( (openshift_logging_elasticsearch_ops_deployment | default(false) | bool) | ternary('-ops', '')) }}"
  20. es_component: "{{ 'es' ~ ( (openshift_logging_elasticsearch_ops_deployment | default(false) | bool) | ternary('-ops', '') ) }}"
  21. - include_tasks: get_es_version.yml
  22. - set_fact:
  23. full_restart_cluster: True
  24. when:
  25. - _es_installed_version is defined
  26. - _es_installed_version.split('.')[0] | int < __es_version.split('.')[0] | int
  27. - set_fact:
  28. full_restart_cluster: True
  29. when:
  30. - _es_ops_installed_version is defined
  31. - _es_ops_installed_version.split('.')[0] | int < __es_version.split('.')[0] | int
  32. # allow passing in a tempdir
  33. - name: Create temp directory for doing work in
  34. command: mktemp -d /tmp/openshift-logging-ansible-XXXXXX
  35. register: mktemp
  36. changed_when: False
  37. - set_fact:
  38. tempdir: "{{ mktemp.stdout }}"
  39. # This may not be necessary in this role
  40. - name: Create templates subdirectory
  41. file:
  42. state: directory
  43. path: "{{ tempdir }}/templates"
  44. mode: 0755
  45. changed_when: False
  46. # we want to make sure we have all the necessary components here
  47. # service account
  48. - name: Create ES service account
  49. oc_serviceaccount:
  50. state: present
  51. name: "aggregated-logging-elasticsearch"
  52. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  53. image_pull_secrets: "{{ openshift_logging_image_pull_secret }}"
  54. when: openshift_logging_image_pull_secret != ''
  55. - name: Create ES service account
  56. oc_serviceaccount:
  57. state: present
  58. name: "aggregated-logging-elasticsearch"
  59. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  60. when:
  61. - openshift_logging_image_pull_secret == ''
  62. # rolebinding reader
  63. - name: Create rolebinding-reader role
  64. oc_clusterrole:
  65. state: present
  66. name: rolebinding-reader
  67. rules:
  68. - apiGroups: [""]
  69. resources: ["clusterrolebindings"]
  70. verbs: ["get"]
  71. # SA roles
  72. - name: Set rolebinding-reader permissions for ES
  73. oc_adm_policy_user:
  74. state: present
  75. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  76. resource_kind: cluster-role
  77. resource_name: rolebinding-reader
  78. user: "system:serviceaccount:{{ openshift_logging_elasticsearch_namespace }}:aggregated-logging-elasticsearch"
  79. - oc_adm_policy_user:
  80. state: present
  81. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  82. resource_kind: cluster-role
  83. resource_name: system:auth-delegator
  84. user: "system:serviceaccount:{{ openshift_logging_elasticsearch_namespace}}:aggregated-logging-elasticsearch"
  85. # logging-metrics-reader role
  86. - template:
  87. src: "{{ __base_file_dir }}/logging-metrics-role.j2"
  88. dest: "{{mktemp.stdout}}/templates/logging-metrics-role.yml"
  89. vars:
  90. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  91. - template:
  92. src: "{{ __base_file_dir }}/logging-metrics-rolebinding.j2"
  93. dest: "{{mktemp.stdout}}/templates/logging-metrics-rolebinding.yml"
  94. vars:
  95. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  96. role_namespace: "{{ openshift_logging_elasticsearch_prometheus_sa | serviceaccount_namespace(openshift_logging_elasticsearch_namespace) }}"
  97. role_user: "{{ openshift_logging_elasticsearch_prometheus_sa | serviceaccount_name }}"
  98. - name: Create logging-metrics-reader-role
  99. oc_obj:
  100. state: present
  101. name: "prometheus-metrics-viewer"
  102. kind: role
  103. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  104. files:
  105. - "{{mktemp.stdout}}/templates/logging-metrics-role.yml"
  106. delete_after: true
  107. - name: Create logging-metrics-reader-rolebinding
  108. oc_obj:
  109. state: present
  110. name: "prometheus-metrics-viewer"
  111. kind: rolebinding
  112. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  113. files:
  114. - "{{mktemp.stdout}}/templates/logging-metrics-rolebinding.yml"
  115. delete_after: true
  116. - name: Checking for passwd.yml
  117. stat: path="{{ generated_certs_dir }}/passwd.yml"
  118. register: passwd_file
  119. check_mode: no
  120. - when: passwd_file.stat.exists
  121. slurp:
  122. src: "{{ generated_certs_dir }}/passwd.yml"
  123. register: _logging_metrics_proxy_passwd
  124. - when: not passwd_file.stat.exists or openshift_logging_elasticsearch_prometheus_sa not in ( _logging_metrics_proxy_passwd['content'] | b64decode | from_yaml )
  125. template:
  126. src: passwd.j2
  127. dest: "{{ generated_certs_dir }}/passwd.yml"
  128. vars:
  129. logging_user_name: "{{ openshift_logging_elasticsearch_prometheus_sa }}"
  130. logging_user_passwd: "{{ 16 | lib_utils_oo_random_word | b64encode }}"
  131. - slurp:
  132. src: "{{ generated_certs_dir }}/passwd.yml"
  133. register: _logging_metrics_proxy_passwd
  134. # View role and binding
  135. - name: Generate logging-elasticsearch-view-role
  136. template:
  137. src: "{{ __base_file_dir }}/rolebinding.j2"
  138. dest: "{{mktemp.stdout}}/logging-elasticsearch-view-role.yaml"
  139. vars:
  140. obj_name: logging-elasticsearch-view-role
  141. roleRef:
  142. name: view
  143. subjects:
  144. - kind: ServiceAccount
  145. name: aggregated-logging-elasticsearch
  146. changed_when: no
  147. - name: Set logging-elasticsearch-view-role role
  148. oc_obj:
  149. state: present
  150. name: "logging-elasticsearch-view-role"
  151. kind: rolebinding
  152. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  153. files:
  154. - "{{ tempdir }}/logging-elasticsearch-view-role.yaml"
  155. delete_after: true
  156. # configmap
  157. - assert:
  158. that:
  159. - openshift_logging_elasticsearch_kibana_index_mode in __kibana_index_modes
  160. msg: "The openshift_logging_elasticsearch_kibana_index_mode '{{ openshift_logging_elasticsearch_kibana_index_mode }}' only supports one of: {{ __kibana_index_modes | join(', ') }}"
  161. - assert:
  162. that:
  163. - "{{ openshift_logging_es_log_appenders | length > 0 }}"
  164. msg: "The openshift_logging_es_log_appenders '{{ openshift_logging_es_log_appenders }}' has an unrecognized option and only supports the following as a list: {{ __es_log_appenders | join(', ') }}"
  165. - template:
  166. src: "{{ __base_file_dir }}/elasticsearch.yml.j2"
  167. dest: "{{ tempdir }}/elasticsearch.yml"
  168. vars:
  169. allow_cluster_reader: "{{ openshift_logging_elasticsearch_ops_allow_cluster_reader | lower | default('false') }}"
  170. es_number_of_shards: "{{ openshift_logging_es_number_of_shards | default(1) }}"
  171. es_number_of_replicas: "{{ openshift_logging_es_number_of_replicas| default(0) }}"
  172. es_kibana_index_mode: "{{ openshift_logging_elasticsearch_kibana_index_mode | default('unique') }}"
  173. changed_when: no
  174. # create diff between current configmap files and our current files
  175. - when: not openshift_logging_es5_techpreview
  176. block:
  177. - template:
  178. src: "{{ __base_file_dir }}/elasticsearch-logging.yml.j2"
  179. dest: "{{ tempdir }}/elasticsearch-logging.yml"
  180. vars:
  181. root_logger: "{{openshift_logging_es_log_appenders | join(', ')}}"
  182. changed_when: no
  183. - include_role:
  184. name: openshift_logging
  185. tasks_from: patch_configmap_files.yaml
  186. vars:
  187. configmap_name: "{{ elasticsearch_name }}"
  188. configmap_namespace: "{{ openshift_logging_namespace }}"
  189. configmap_file_names:
  190. - current_file: "elasticsearch.yml"
  191. new_file: "{{ tempdir }}/elasticsearch.yml"
  192. protected_lines: ["number_of_shards", "number_of_replicas"]
  193. - current_file: "logging.yml"
  194. new_file: "{{ tempdir }}/elasticsearch-logging.yml"
  195. - slurp:
  196. src: "{{ tempdir }}/elasticsearch.yml"
  197. register: _patched_elasticsearch_config
  198. - copy:
  199. content: "{{ config_source | combine(override_config, recursive=True) | to_nice_yaml(indent=2) }}"
  200. dest: "{{ tempdir }}/elasticsearch.yml"
  201. vars:
  202. config_source: "{{ _patched_elasticsearch_config['content'] | b64decode | from_yaml }}"
  203. override_config: "{{ openshift_logging_es_config | default({}) | from_yaml }}"
  204. - name: Set ES configmap
  205. oc_configmap:
  206. state: present
  207. name: "{{ elasticsearch_name }}"
  208. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  209. from_file:
  210. elasticsearch.yml: "{{ tempdir }}/elasticsearch.yml"
  211. logging.yml: "{{ tempdir }}/elasticsearch-logging.yml"
  212. register: es_config_creation
  213. notify: "restart elasticsearch"
  214. - when: openshift_logging_es5_techpreview | bool
  215. block:
  216. - template:
  217. src: "{{ __base_file_dir }}/log4j2.properties.j2"
  218. dest: "{{ tempdir }}/log4j2.properties"
  219. vars:
  220. root_logger: "{{ openshift_logging_es_log_appenders | list }}"
  221. changed_when: no
  222. - include_role:
  223. name: openshift_logging
  224. tasks_from: patch_configmap_files.yaml
  225. vars:
  226. configmap_name: "{{ elasticsearch_name }}"
  227. configmap_namespace: "{{ openshift_logging_namespace }}"
  228. configmap_file_names:
  229. - current_file: "elasticsearch.yml"
  230. new_file: "{{ tempdir }}/elasticsearch.yml"
  231. - current_file: "log4j2.properties"
  232. new_file: "{{ tempdir }}/log4j2.properties"
  233. - slurp:
  234. src: "{{ tempdir }}/elasticsearch.yml"
  235. register: _patched_elasticsearch_config
  236. - copy:
  237. content: "{{ config_source | combine(override_config, recursive=True) | to_nice_yaml(indent=2) }}"
  238. dest: "{{ tempdir }}/elasticsearch.yml"
  239. vars:
  240. config_source: "{{ _patched_elasticsearch_config['content'] | b64decode | from_yaml }}"
  241. override_config: "{{ openshift_logging_es_config | default({}) | from_yaml }}"
  242. - name: Set ES configmap
  243. oc_configmap:
  244. state: present
  245. name: "{{ elasticsearch_name }}"
  246. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  247. from_file:
  248. elasticsearch.yml: "{{ tempdir }}/elasticsearch.yml"
  249. log4j2.properties: "{{ tempdir }}/log4j2.properties"
  250. register: es_config_creation
  251. notify: "restart elasticsearch"
  252. - when: es_config_creation.changed | bool
  253. block:
  254. - set_fact:
  255. _restart_logging_components: "{{ _restart_logging_components | default([]) + [es_component] | unique }}"
  256. - shell: >
  257. {{ openshift_client_binary }} --config={{ openshift.common.config_base }}/master/admin.kubeconfig get dc -l component="{{ es_component }}" -n "{{ openshift_logging_elasticsearch_namespace }}" -o name | cut -d'/' -f2
  258. register: _es_dcs
  259. - set_fact:
  260. _restart_logging_nodes: "{{ _restart_logging_nodes | default([]) + [_es_dcs.stdout] | unique }}"
  261. when: _es_dcs.stdout != ""
  262. # secret
  263. - name: Set ES secret
  264. oc_secret:
  265. state: present
  266. name: "logging-elasticsearch"
  267. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  268. files:
  269. - name: key
  270. path: "{{ generated_certs_dir }}/logging-es.jks"
  271. - name: truststore
  272. path: "{{ generated_certs_dir }}/truststore.jks"
  273. - name: searchguard.key
  274. path: "{{ generated_certs_dir }}/elasticsearch.jks"
  275. - name: searchguard.truststore
  276. path: "{{ generated_certs_dir }}/truststore.jks"
  277. - name: admin-key
  278. path: "{{ generated_certs_dir }}/system.admin.key"
  279. - name: admin-cert
  280. path: "{{ generated_certs_dir }}/system.admin.crt"
  281. - name: admin-ca
  282. path: "{{ generated_certs_dir }}/ca.crt"
  283. - name: admin.jks
  284. path: "{{ generated_certs_dir }}/system.admin.jks"
  285. - name: passwd.yml
  286. path: "{{ generated_certs_dir }}/passwd.yml"
  287. # services
  288. - name: Set logging-{{ es_component }}-cluster service
  289. oc_service:
  290. state: present
  291. name: "logging-{{ es_component }}-cluster"
  292. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  293. selector:
  294. component: "{{ es_component }}"
  295. provider: openshift
  296. labels:
  297. logging-infra: 'support'
  298. ports:
  299. - port: 9300
  300. - name: Set logging-{{ es_component }} service
  301. oc_service:
  302. state: present
  303. name: "logging-{{ es_component }}"
  304. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  305. selector:
  306. component: "{{ es_component }}"
  307. provider: openshift
  308. labels:
  309. logging-infra: 'support'
  310. ports:
  311. - port: 9200
  312. targetPort: "restapi"
  313. - name: Set logging-{{ es_component}}-prometheus service
  314. oc_service:
  315. state: present
  316. name: "logging-{{es_component}}-prometheus"
  317. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  318. labels:
  319. logging-infra: 'support'
  320. ports:
  321. - name: proxy
  322. port: 443
  323. targetPort: 4443
  324. selector:
  325. component: "{{ es_component }}"
  326. provider: openshift
  327. - oc_edit:
  328. kind: service
  329. name: "logging-{{es_component}}-prometheus"
  330. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  331. separator: '#'
  332. content:
  333. metadata#annotations#service.alpha.openshift.io/serving-cert-secret-name: "prometheus-tls"
  334. metadata#annotations#prometheus.io/scrape: "true"
  335. metadata#annotations#prometheus.io/scheme: "https"
  336. metadata#annotations#prometheus.io/path: "/_prometheus/metrics"
  337. metadata#annotations#prometheus.io/port: "4443"
  338. - name: Check to see if PVC already exists
  339. oc_obj:
  340. state: list
  341. kind: pvc
  342. name: "{{ openshift_logging_elasticsearch_pvc_name }}"
  343. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  344. register: logging_elasticsearch_pvc
  345. # logging_elasticsearch_pvc.results.results | length > 0 returns a false positive
  346. # so we check for the presence of 'stderr' to determine if the obj exists or not
  347. # the RC for existing and not existing is both 0
  348. - when:
  349. - logging_elasticsearch_pvc.results.stderr is defined
  350. - openshift_logging_elasticsearch_storage_type == "pvc"
  351. block:
  352. # storageclasses are used by default but if static then disable
  353. # storageclasses with the storageClassName set to "" in pvc.j2
  354. - name: Creating ES storage template - static
  355. template:
  356. src: "{{ __base_file_dir }}/pvc.j2"
  357. dest: "{{ tempdir }}/templates/logging-es-pvc.yml"
  358. vars:
  359. obj_name: "{{ openshift_logging_elasticsearch_pvc_name }}"
  360. size: "{{ (openshift_logging_elasticsearch_pvc_size | trim | length == 0) | ternary('10Gi', openshift_logging_elasticsearch_pvc_size) }}"
  361. access_modes: "{{ openshift_logging_elasticsearch_pvc_access_modes | list }}"
  362. pv_selector: "{{ openshift_logging_elasticsearch_pvc_pv_selector }}"
  363. storage_class_name: "{{ openshift_logging_elasticsearch_pvc_storage_class_name | default('', true) }}"
  364. when:
  365. - not openshift_logging_elasticsearch_pvc_dynamic | bool
  366. # Storageclasses are used by default if configured
  367. - name: Creating ES storage template - dynamic
  368. template:
  369. src: "{{ __base_file_dir }}/pvc.j2"
  370. dest: "{{ tempdir }}/templates/logging-es-pvc.yml"
  371. vars:
  372. obj_name: "{{ openshift_logging_elasticsearch_pvc_name }}"
  373. size: "{{ (openshift_logging_elasticsearch_pvc_size | trim | length == 0) | ternary('10Gi', openshift_logging_elasticsearch_pvc_size) }}"
  374. access_modes: "{{ openshift_logging_elasticsearch_pvc_access_modes | list }}"
  375. pv_selector: "{{ openshift_logging_elasticsearch_pvc_pv_selector }}"
  376. when:
  377. - openshift_logging_elasticsearch_pvc_dynamic | bool
  378. - name: Set ES storage
  379. oc_obj:
  380. state: present
  381. kind: pvc
  382. name: "{{ openshift_logging_elasticsearch_pvc_name }}"
  383. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  384. files:
  385. - "{{ tempdir }}/templates/logging-es-pvc.yml"
  386. delete_after: true
  387. - set_fact:
  388. es_deploy_name: "logging-{{ es_component }}-{{ openshift_logging_elasticsearch_deployment_type }}-{{ 8 | lib_utils_oo_random_word('abcdefghijklmnopqrstuvwxyz0123456789') }}"
  389. when: openshift_logging_elasticsearch_deployment_name == ""
  390. - set_fact:
  391. es_deploy_name: "{{ openshift_logging_elasticsearch_deployment_name }}"
  392. when: openshift_logging_elasticsearch_deployment_name != ""
  393. # DC
  394. - name: Set ES dc templates
  395. template:
  396. src: "{{ __base_file_dir }}/es.j2"
  397. dest: "{{ tempdir }}/templates/logging-es-dc.yml"
  398. vars:
  399. es_cluster_name: "{{ es_component }}"
  400. component: "{{ es_component }}"
  401. logging_component: elasticsearch
  402. deploy_name: "{{ es_deploy_name }}"
  403. es_cpu_limit: "{{ openshift_logging_elasticsearch_cpu_limit | default('') }}"
  404. es_cpu_request: "{{ openshift_logging_elasticsearch_cpu_request | min_cpu(openshift_logging_elasticsearch_cpu_limit | default(none)) }}"
  405. es_memory_limit: "{{ openshift_logging_elasticsearch_memory_limit }}"
  406. es_node_selector: "{{ openshift_logging_elasticsearch_nodeselector | default({}) }}"
  407. es_storage_groups: "{{ openshift_logging_elasticsearch_storage_group | default([]) }}"
  408. es_container_security_context: "{{ _es_containers.elasticsearch.securityContext if _es_containers is defined and 'elasticsearch' in _es_containers and 'securityContext' in _es_containers.elasticsearch else None }}"
  409. deploy_type: "{{ openshift_logging_elasticsearch_deployment_type }}"
  410. es_replicas: 1
  411. basic_auth_passwd: "{{ ( _logging_metrics_proxy_passwd['content'] | b64decode | from_yaml )[openshift_logging_elasticsearch_prometheus_sa]['passwd'] | b64decode }}"
  412. es_number_of_shards: "{{ openshift_logging_es_number_of_shards | default(1) }}"
  413. es_number_of_replicas: "{{ openshift_logging_es_number_of_replicas| default(0) }}"
  414. - name: Set ES dc
  415. oc_obj:
  416. state: present
  417. name: "{{ es_deploy_name }}"
  418. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  419. kind: dc
  420. files:
  421. - "{{ tempdir }}/templates/logging-es-dc.yml"
  422. delete_after: true
  423. register: es_dc_creation
  424. notify: "restart elasticsearch"
  425. - set_fact:
  426. _restart_logging_components: "{{ _restart_logging_components | default([]) + [es_component] | unique }}"
  427. _restart_logging_nodes: "{{ _restart_logging_nodes | default([]) + [es_deploy_name] | unique }}"
  428. when: es_dc_creation.changed | bool
  429. - name: Retrieving the cert to use when generating secrets for the {{ es_component }} component
  430. slurp:
  431. src: "{{ generated_certs_dir }}/{{ item.file }}"
  432. register: key_pairs
  433. with_items:
  434. - { name: "ca_file", file: "ca.crt" }
  435. - { name: "es_key", file: "system.logging.es.key" }
  436. - { name: "es_cert", file: "system.logging.es.crt" }
  437. when: openshift_logging_es_allow_external | bool
  438. - set_fact:
  439. es_key: "{{ lookup('file', openshift_logging_es_key) | b64encode }}"
  440. when:
  441. - openshift_logging_es_key | trim | length > 0
  442. - openshift_logging_es_allow_external | bool
  443. changed_when: false
  444. - set_fact:
  445. es_cert: "{{ lookup('file', openshift_logging_es_cert) | b64encode }}"
  446. when:
  447. - openshift_logging_es_cert | trim | length > 0
  448. - openshift_logging_es_allow_external | bool
  449. changed_when: false
  450. - set_fact:
  451. es_ca: "{{ lookup('file', openshift_logging_es_ca_ext) | b64encode }}"
  452. when:
  453. - openshift_logging_es_ca_ext | trim | length > 0
  454. - openshift_logging_es_allow_external | bool
  455. changed_when: false
  456. - set_fact:
  457. es_ca: "{{ key_pairs | entry_from_named_pair('ca_file') }}"
  458. when:
  459. - es_ca is not defined
  460. - openshift_logging_es_allow_external | bool
  461. changed_when: false
  462. - name: Generating Elasticsearch {{ es_component }} route template
  463. template:
  464. src: "{{ __base_file_dir }}/route_reencrypt.j2"
  465. dest: "{{mktemp.stdout}}/templates/logging-{{ es_component }}-route.yaml"
  466. vars:
  467. obj_name: "logging-{{ es_component }}"
  468. route_host: "{{ openshift_logging_es_hostname }}"
  469. service_name: "logging-{{ es_component }}"
  470. tls_key: "{{ es_key | default('') | b64decode }}"
  471. tls_cert: "{{ es_cert | default('') | b64decode }}"
  472. tls_ca_cert: "{{ es_ca | b64decode }}"
  473. tls_dest_ca_cert: "{{ key_pairs | entry_from_named_pair('ca_file') | b64decode }}"
  474. edge_term_policy: "{{ openshift_logging_es_edge_term_policy | default('') }}"
  475. labels:
  476. component: support
  477. logging-infra: support
  478. provider: openshift
  479. changed_when: no
  480. when: openshift_logging_es_allow_external | bool
  481. # This currently has an issue if the host name changes
  482. - name: Setting Elasticsearch {{ es_component }} route
  483. oc_obj:
  484. state: present
  485. name: "logging-{{ es_component }}"
  486. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  487. kind: route
  488. files:
  489. - "{{ tempdir }}/templates/logging-{{ es_component }}-route.yaml"
  490. when: openshift_logging_es_allow_external | bool
  491. ## Placeholder for migration when necessary ##
  492. - name: Delete temp directory
  493. file:
  494. name: "{{ tempdir }}"
  495. state: absent
  496. changed_when: False