install_logging.yaml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. ---
  2. - name: Gather OpenShift Logging Facts
  3. openshift_logging_facts:
  4. oc_bin: "{{openshift_client_binary}}"
  5. openshift_logging_namespace: "{{openshift_logging_namespace}}"
  6. ## This is include vs import because we need access to group/inventory variables
  7. - include_tasks: set_defaults_from_current.yml
  8. - name: Set logging project
  9. oc_project:
  10. state: present
  11. name: "{{ openshift_logging_namespace }}"
  12. node_selector: "{{ openshift_logging_nodeselector | default(null) }}"
  13. - name: Labeling logging project
  14. oc_label:
  15. state: present
  16. kind: namespace
  17. name: "{{ openshift_logging_namespace }}"
  18. labels:
  19. - key: "{{ item.key }}"
  20. value: "{{ item.value }}"
  21. with_dict: "{{ openshift_logging_labels | default({}) }}"
  22. when:
  23. - openshift_logging_labels is defined
  24. - openshift_logging_labels is dict
  25. - name: Labeling logging project
  26. oc_label:
  27. state: present
  28. kind: namespace
  29. name: "{{ openshift_logging_namespace }}"
  30. labels:
  31. - key: "{{ openshift_logging_label_key }}"
  32. value: "{{ openshift_logging_label_value }}"
  33. when:
  34. - openshift_logging_label_key is defined
  35. - openshift_logging_label_key != ""
  36. - openshift_logging_label_value is defined
  37. - name: Annotate Logging Project to allow overcommit
  38. oc_edit:
  39. kind: ns
  40. name: "{{ openshift_logging_namespace }}"
  41. separator: '#'
  42. content:
  43. metadata#annotations#quota.openshift.io/cluster-resource-override-enabled: "false"
  44. - name: Create logging cert directory
  45. file:
  46. path: "{{ openshift.common.config_base }}/logging"
  47. state: directory
  48. mode: 0755
  49. changed_when: False
  50. check_mode: no
  51. - include_tasks: generate_certs.yaml
  52. vars:
  53. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  54. - set_fact:
  55. __base_file_dir: "{{ '5.x' if openshift_logging_es5_techpreview | bool else '2.x' }}"
  56. __es_version: "{{ '5.x' if openshift_logging_es5_techpreview | bool else '2.x' }}"
  57. - set_fact:
  58. openshift_logging_image_version: "techpreview"
  59. when: openshift_logging_es5_techpreview | bool
  60. ## Elasticsearch
  61. - set_fact: es_indices={{ es_indices | default([]) + [item | int - 1] }}
  62. with_sequence: count={{ openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count }}
  63. when: openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count > 0
  64. - set_fact: es_indices=[]
  65. when: openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count == 0
  66. - set_fact: openshift_logging_es_pvc_prefix="logging-es"
  67. when: openshift_logging_es_pvc_prefix == ""
  68. # Using this module for setting this fact because otherwise we were getting a value of "" trying to
  69. # use default() in the set_fact after this which caused us to not correctly evaluate
  70. # openshift_logging_elasticsearch_storage_type
  71. - conditional_set_fact:
  72. facts: "{{ hostvars[inventory_hostname] }}"
  73. vars:
  74. elasticsearch_storage_type: openshift_logging_elasticsearch_storage_type
  75. - set_fact:
  76. default_elasticsearch_storage_type: "{{ 'pvc' if ( openshift_logging_es_pvc_dynamic | bool or openshift_logging_storage_kind | default('') == 'nfs' or openshift_logging_es_pvc_size | length > 0) else 'emptydir' }}"
  77. - include_role:
  78. name: openshift_logging_elasticsearch
  79. vars:
  80. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  81. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  82. openshift_logging_elasticsearch_deployment_name: "{{ outer_item.0.name }}"
  83. openshift_logging_elasticsearch_pvc_name: "{{ outer_item.0.volumes['elasticsearch-storage'].persistentVolumeClaim.claimName if outer_item.0.volumes['elasticsearch-storage'].persistentVolumeClaim is defined else openshift_logging_es_pvc_prefix ~ '-' ~ outer_item.2 if outer_item.1 is none else outer_item.1 }}"
  84. openshift_logging_elasticsearch_pvc_size: "{{ openshift_logging_es_pvc_size }}"
  85. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_cluster_size | int }}"
  86. openshift_logging_elasticsearch_storage_type: "{{ elasticsearch_storage_type | default('pvc' if outer_item.0.volumes['elasticsearch-storage'].persistentVolumeClaim is defined else 'hostmount' if outer_item.0.volumes['elasticsearch-storage'].hostPath is defined else 'emptydir' if outer_item.0.volumes['elasticsearch-storage'].emptyDir is defined else default_elasticsearch_storage_type) }}"
  87. openshift_logging_elasticsearch_hostmount_path: "{{ outer_item.0.volumes['elasticsearch-storage'].hostPath.path if outer_item.0.volumes['elasticsearch-storage'].hostPath is defined else '' }}"
  88. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_pv_selector }}"
  89. openshift_logging_elasticsearch_pvc_storage_class_name: "{{ openshift_logging_es_pvc_storage_class_name | default() }}"
  90. openshift_logging_elasticsearch_nodeselector: "{{ openshift_logging_es_nodeselector if outer_item.0.nodeSelector | default(None) is none else outer_item.0.nodeSelector }}"
  91. openshift_logging_elasticsearch_storage_group: "{{ [openshift_logging_es_storage_group] if outer_item.0.storageGroups | default([]) | length == 0 else outer_item.0.storageGroups }}"
  92. _es_containers: "{{ outer_item.0.containers}}"
  93. _es_configmap: "{{ openshift_logging_facts | walk('elasticsearch#configmaps#logging-elasticsearch#elasticsearch.yml', '{}', delimiter='#') | from_yaml }}"
  94. with_together:
  95. - "{{ openshift_logging_facts.elasticsearch.deploymentconfigs.values() | list }}"
  96. - "{{ openshift_logging_facts.elasticsearch.pvcs }}"
  97. - "{{ es_indices }}"
  98. loop_control:
  99. loop_var: outer_item
  100. when:
  101. - openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count > 0
  102. # Create any new DC that may be required
  103. - include_role:
  104. name: openshift_logging_elasticsearch
  105. vars:
  106. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  107. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  108. openshift_logging_elasticsearch_pvc_name: "{{ openshift_logging_es_pvc_prefix }}-{{ outer_item | int + openshift_logging_facts.elasticsearch.deploymentconfigs | count - 1 }}"
  109. openshift_logging_elasticsearch_pvc_size: "{{ openshift_logging_es_pvc_size }}"
  110. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_cluster_size | int }}"
  111. openshift_logging_elasticsearch_storage_type: "{{ elasticsearch_storage_type | default(default_elasticsearch_storage_type) }}"
  112. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_pv_selector }}"
  113. openshift_logging_elasticsearch_pvc_storage_class_name: "{{ openshift_logging_es_pvc_storage_class_name | default() }}"
  114. with_sequence: count={{ openshift_logging_es_cluster_size | int - openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count }}
  115. loop_control:
  116. loop_var: outer_item
  117. - set_fact: es_ops_indices={{ es_ops_indices | default([]) + [item | int - 1] }}
  118. with_sequence: count={{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count }}
  119. when:
  120. - openshift_logging_use_ops | bool
  121. - openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count > 0
  122. - set_fact: es_ops_indices=[]
  123. when: openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count == 0
  124. - set_fact: openshift_logging_es_ops_pvc_prefix="logging-es-ops"
  125. when: openshift_logging_es_ops_pvc_prefix == ""
  126. - set_fact:
  127. default_elasticsearch_storage_type: "{{ 'pvc' if ( openshift_logging_es_ops_pvc_dynamic | bool or openshift_logging_storage_kind | default('') == 'nfs' or openshift_logging_es_ops_pvc_size | length > 0) else 'emptydir' }}"
  128. when:
  129. - openshift_logging_use_ops | bool
  130. - include_role:
  131. name: openshift_logging_elasticsearch
  132. vars:
  133. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  134. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  135. openshift_logging_elasticsearch_deployment_name: "{{ outer_item.0.name }}"
  136. openshift_logging_elasticsearch_pvc_name: "{{ outer_item.0.volumes['elasticsearch-storage'].persistentVolumeClaim.claimName if outer_item.0.volumes['elasticsearch-storage'].persistentVolumeClaim is defined else openshift_logging_es_ops_pvc_prefix ~ '-' ~ outer_item.2 if outer_item.1 is none else outer_item.1 }}"
  137. openshift_logging_elasticsearch_ops_deployment: true
  138. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_ops_cluster_size | int }}"
  139. openshift_logging_elasticsearch_storage_type: "{{ elasticsearch_storage_type | default('pvc' if outer_item.0.volumes['elasticsearch-storage'].persistentVolumeClaim is defined else 'hostmount' if outer_item.0.volumes['elasticsearch-storage'].hostPath is defined else 'emptydir' if outer_item.0.volumes['elasticsearch-storage'].emptyDir is defined else default_elasticsearch_storage_type) }}"
  140. openshift_logging_elasticsearch_hostmount_path: "{{ outer_item.0.volumes['elasticsearch-storage'].hostPath.path if outer_item.0.volumes['elasticsearch-storage'].hostPath is defined else '' }}"
  141. openshift_logging_elasticsearch_pvc_size: "{{ openshift_logging_es_ops_pvc_size }}"
  142. openshift_logging_elasticsearch_pvc_dynamic: "{{ openshift_logging_es_ops_pvc_dynamic }}"
  143. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_ops_pv_selector }}"
  144. openshift_logging_elasticsearch_pvc_storage_class_name: "{{ openshift_logging_es_ops_pvc_storage_class_name | default() }}"
  145. openshift_logging_elasticsearch_memory_limit: "{{ openshift_logging_es_ops_memory_limit }}"
  146. openshift_logging_elasticsearch_cpu_limit: "{{ openshift_logging_es_ops_cpu_limit }}"
  147. openshift_logging_elasticsearch_cpu_request: "{{ openshift_logging_es_ops_cpu_request }}"
  148. openshift_logging_elasticsearch_nodeselector: "{{ openshift_logging_es_ops_nodeselector if outer_item.0.nodeSelector | default(None) is none else outer_item.0.nodeSelector }}"
  149. openshift_logging_elasticsearch_storage_group: "{{ [openshift_logging_es_ops_storage_group] if outer_item.0.storageGroups | default([]) | length == 0 else outer_item.0.storageGroups }}"
  150. openshift_logging_es_key: "{{ openshift_logging_es_ops_key }}"
  151. openshift_logging_es_cert: "{{ openshift_logging_es_ops_cert }}"
  152. openshift_logging_es_ca_ext: "{{ openshift_logging_es_ops_ca_ext }}"
  153. openshift_logging_es_hostname: "{{ openshift_logging_es_ops_hostname }}"
  154. openshift_logging_es_edge_term_policy: "{{ openshift_logging_es_ops_edge_term_policy | default('') }}"
  155. openshift_logging_es_allow_external: "{{ openshift_logging_es_ops_allow_external }}"
  156. openshift_logging_es_number_of_shards: "{{ openshift_logging_es_ops_number_of_shards | default(None) }}"
  157. openshift_logging_es_number_of_replicas: "{{ openshift_logging_es_ops_number_of_replicas | default(None) }}"
  158. _es_containers: "{{ outer_item.0.containers}}"
  159. _es_configmap: "{{ openshift_logging_facts | walk('elasticsearch_ops#configmaps#logging-elasticsearch-ops#elasticsearch.yml', '{}', delimiter='#') | from_yaml }}"
  160. with_together:
  161. - "{{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.values() | list }}"
  162. - "{{ openshift_logging_facts.elasticsearch_ops.pvcs }}"
  163. - "{{ es_ops_indices }}"
  164. loop_control:
  165. loop_var: outer_item
  166. when:
  167. - openshift_logging_use_ops | bool
  168. - openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count > 0
  169. # Create any new DC that may be required
  170. - include_role:
  171. name: openshift_logging_elasticsearch
  172. vars:
  173. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  174. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  175. openshift_logging_elasticsearch_pvc_name: "{{ openshift_logging_es_ops_pvc_prefix }}-{{ outer_item | int + openshift_logging_facts.elasticsearch_ops.deploymentconfigs | count - 1 }}"
  176. openshift_logging_elasticsearch_ops_deployment: true
  177. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_ops_cluster_size | int }}"
  178. openshift_logging_elasticsearch_storage_type: "{{ elasticsearch_storage_type | default(default_elasticsearch_storage_type) }}"
  179. openshift_logging_elasticsearch_pvc_size: "{{ openshift_logging_es_ops_pvc_size }}"
  180. openshift_logging_elasticsearch_pvc_dynamic: "{{ openshift_logging_es_ops_pvc_dynamic }}"
  181. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_ops_pv_selector }}"
  182. openshift_logging_elasticsearch_pvc_storage_class_name: "{{ openshift_logging_es_ops_pvc_storage_class_name | default() }}"
  183. openshift_logging_elasticsearch_memory_limit: "{{ openshift_logging_es_ops_memory_limit }}"
  184. openshift_logging_elasticsearch_cpu_limit: "{{ openshift_logging_es_ops_cpu_limit }}"
  185. openshift_logging_elasticsearch_cpu_request: "{{ openshift_logging_es_ops_cpu_request }}"
  186. openshift_logging_elasticsearch_nodeselector: "{{ openshift_logging_es_ops_nodeselector }}"
  187. openshift_logging_es_key: "{{ openshift_logging_es_ops_key }}"
  188. openshift_logging_es_cert: "{{ openshift_logging_es_ops_cert }}"
  189. openshift_logging_es_ca_ext: "{{ openshift_logging_es_ops_ca_ext }}"
  190. openshift_logging_es_hostname: "{{ openshift_logging_es_ops_hostname }}"
  191. openshift_logging_es_edge_term_policy: "{{ openshift_logging_es_ops_edge_term_policy | default('') }}"
  192. openshift_logging_es_allow_external: "{{ openshift_logging_es_ops_allow_external }}"
  193. with_sequence: count={{ openshift_logging_es_ops_cluster_size | int - openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count }}
  194. loop_control:
  195. loop_var: outer_item
  196. when:
  197. - openshift_logging_use_ops | bool
  198. ## Kibana
  199. - import_role:
  200. name: openshift_logging_kibana
  201. vars:
  202. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  203. openshift_logging_kibana_namespace: "{{ openshift_logging_namespace }}"
  204. openshift_logging_kibana_master_url: "{{ openshift_logging_master_url }}"
  205. openshift_logging_kibana_master_public_url: "{{ openshift_logging_master_public_url }}"
  206. openshift_logging_kibana_replicas: "{{ openshift_logging_kibana_replica_count }}"
  207. openshift_logging_kibana_es_host: "{{ openshift_logging_es_host }}"
  208. openshift_logging_kibana_es_port: "{{ openshift_logging_es_port }}"
  209. openshift_logging_kibana_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  210. - import_role:
  211. name: openshift_logging_kibana
  212. vars:
  213. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  214. openshift_logging_kibana_ops_deployment: true
  215. openshift_logging_kibana_namespace: "{{ openshift_logging_namespace }}"
  216. openshift_logging_kibana_master_url: "{{ openshift_logging_master_url }}"
  217. openshift_logging_kibana_master_public_url: "{{ openshift_logging_master_public_url }}"
  218. openshift_logging_kibana_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  219. openshift_logging_kibana_es_host: "{{ openshift_logging_es_ops_host }}"
  220. openshift_logging_kibana_es_port: "{{ openshift_logging_es_ops_port }}"
  221. openshift_logging_kibana_nodeselector: "{{ openshift_logging_kibana_ops_nodeselector }}"
  222. openshift_logging_kibana_cpu_limit: "{{ openshift_logging_kibana_ops_cpu_limit }}"
  223. openshift_logging_kibana_cpu_request: "{{ openshift_logging_kibana_ops_cpu_request }}"
  224. openshift_logging_kibana_memory_limit: "{{ openshift_logging_kibana_ops_memory_limit }}"
  225. openshift_logging_kibana_hostname: "{{ openshift_logging_kibana_ops_hostname }}"
  226. openshift_logging_kibana_replicas: "{{ openshift_logging_kibana_ops_replica_count }}"
  227. openshift_logging_kibana_proxy_debug: "{{ openshift_logging_kibana_ops_proxy_debug }}"
  228. openshift_logging_kibana_proxy_cpu_limit: "{{ openshift_logging_kibana_ops_proxy_cpu_limit }}"
  229. openshift_logging_kibana_proxy_cpu_request: "{{ openshift_logging_kibana_ops_proxy_cpu_request }}"
  230. openshift_logging_kibana_proxy_memory_limit: "{{ openshift_logging_kibana_ops_proxy_memory_limit }}"
  231. openshift_logging_kibana_cert: "{{ openshift_logging_kibana_ops_cert }}"
  232. openshift_logging_kibana_key: "{{ openshift_logging_kibana_ops_key }}"
  233. openshift_logging_kibana_ca: "{{ openshift_logging_kibana_ops_ca}}"
  234. when:
  235. - openshift_logging_use_ops | bool
  236. - include_tasks: annotate_ops_projects.yaml
  237. ## Curator
  238. - import_role:
  239. name: openshift_logging_curator
  240. vars:
  241. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  242. openshift_logging_curator_namespace: "{{ openshift_logging_namespace }}"
  243. openshift_logging_curator_es_host: "{{ openshift_logging_es_host }}"
  244. openshift_logging_curator_es_port: "{{ openshift_logging_es_port }}"
  245. openshift_logging_curator_master_url: "{{ openshift_logging_master_url }}"
  246. openshift_logging_curator_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  247. - import_role:
  248. name: openshift_logging_curator
  249. vars:
  250. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  251. openshift_logging_curator_ops_deployment: true
  252. openshift_logging_curator_es_host: "{{ openshift_logging_es_ops_host }}"
  253. openshift_logging_curator_es_port: "{{ openshift_logging_es_ops_port }}"
  254. openshift_logging_curator_namespace: "{{ openshift_logging_namespace }}"
  255. openshift_logging_curator_master_url: "{{ openshift_logging_master_url }}"
  256. openshift_logging_curator_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  257. openshift_logging_curator_cpu_limit: "{{ openshift_logging_curator_ops_cpu_limit }}"
  258. openshift_logging_curator_cpu_request: "{{ openshift_logging_curator_ops_cpu_request }}"
  259. openshift_logging_curator_memory_limit: "{{ openshift_logging_curator_ops_memory_limit }}"
  260. openshift_logging_curator_nodeselector: "{{ openshift_logging_curator_ops_nodeselector }}"
  261. when:
  262. - openshift_logging_use_ops | bool
  263. ## Mux
  264. - import_role:
  265. name: openshift_logging_mux
  266. vars:
  267. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  268. openshift_logging_mux_ops_host: "{{ ( openshift_logging_use_ops | bool ) | ternary('logging-es-ops', 'logging-es') }}"
  269. openshift_logging_mux_namespace: "{{ openshift_logging_namespace }}"
  270. openshift_logging_mux_master_url: "{{ openshift_logging_master_url }}"
  271. openshift_logging_mux_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  272. when:
  273. - openshift_logging_use_mux | bool
  274. ## Fluentd
  275. - import_role:
  276. name: openshift_logging_fluentd
  277. vars:
  278. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  279. openshift_logging_fluentd_ops_host: "{{ ( openshift_logging_use_ops | bool ) | ternary('logging-es-ops', 'logging-es') }}"
  280. openshift_logging_fluentd_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  281. openshift_logging_fluentd_master_url: "{{ openshift_logging_master_url }}"
  282. openshift_logging_fluentd_namespace: "{{ openshift_logging_namespace }}"
  283. ## EventRouter
  284. - import_role:
  285. name: openshift_logging_eventrouter
  286. when:
  287. openshift_logging_install_eventrouter | default(false) | bool
  288. - include_tasks: update_master_config.yaml
  289. when: not openshift.common.version_gte_3_9
  290. # Update asset config in openshift-web-console namespace
  291. - name: Add Kibana route information to web console asset config
  292. include_role:
  293. name: openshift_web_console
  294. tasks_from: update_console_config.yml
  295. vars:
  296. console_config_edits:
  297. - key: clusterInfo#loggingPublicURL
  298. value: "https://{{ openshift_logging_kibana_hostname }}"
  299. when:
  300. - openshift_web_console_install | default(true) | bool
  301. - openshift.common.version_gte_3_9