install_logging.yaml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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. ## Elasticsearch
  58. - set_fact: es_indices={{ es_indices | default([]) + [item | int - 1] }}
  59. with_sequence: count={{ openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count }}
  60. when: openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count > 0
  61. - set_fact: es_indices=[]
  62. when: openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count == 0
  63. - set_fact: openshift_logging_es_pvc_prefix="logging-es"
  64. when: openshift_logging_es_pvc_prefix == ""
  65. # Using this module for setting this fact because otherwise we were getting a value of "" trying to
  66. # use default() in the set_fact after this which caused us to not correctly evaluate
  67. # openshift_logging_elasticsearch_storage_type
  68. - conditional_set_fact:
  69. facts: "{{ hostvars[inventory_hostname] }}"
  70. vars:
  71. elasticsearch_storage_type: openshift_logging_elasticsearch_storage_type
  72. - set_fact:
  73. 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' }}"
  74. - include_role:
  75. name: openshift_logging_elasticsearch
  76. vars:
  77. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  78. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  79. openshift_logging_elasticsearch_deployment_name: "{{ outer_item.0.name }}"
  80. 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 }}"
  81. openshift_logging_elasticsearch_pvc_size: "{{ openshift_logging_es_pvc_size }}"
  82. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_cluster_size | int }}"
  83. 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) }}"
  84. openshift_logging_elasticsearch_hostmount_path: "{{ outer_item.0.volumes['elasticsearch-storage'].hostPath.path if outer_item.0.volumes['elasticsearch-storage'].hostPath is defined else '' }}"
  85. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_pv_selector }}"
  86. openshift_logging_elasticsearch_pvc_storage_class_name: "{{ openshift_logging_es_pvc_storage_class_name | default() }}"
  87. openshift_logging_elasticsearch_nodeselector: "{{ openshift_logging_es_nodeselector if outer_item.0.nodeSelector | default(None) is none else outer_item.0.nodeSelector }}"
  88. openshift_logging_elasticsearch_storage_group: "{{ [openshift_logging_es_storage_group] if outer_item.0.storageGroups | default([]) | length == 0 else outer_item.0.storageGroups }}"
  89. _es_containers: "{{ outer_item.0.containers}}"
  90. _es_configmap: "{{ openshift_logging_facts | walk('elasticsearch#configmaps#logging-elasticsearch#elasticsearch.yml', '{}', delimiter='#') | from_yaml }}"
  91. with_together:
  92. - "{{ openshift_logging_facts.elasticsearch.deploymentconfigs.values() | list }}"
  93. - "{{ openshift_logging_facts.elasticsearch.pvcs }}"
  94. - "{{ es_indices }}"
  95. loop_control:
  96. loop_var: outer_item
  97. when:
  98. - openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count > 0
  99. # Create any new DC that may be required
  100. - include_role:
  101. name: openshift_logging_elasticsearch
  102. vars:
  103. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  104. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  105. openshift_logging_elasticsearch_pvc_name: "{{ openshift_logging_es_pvc_prefix }}-{{ outer_item | int + openshift_logging_facts.elasticsearch.deploymentconfigs | count - 1 }}"
  106. openshift_logging_elasticsearch_pvc_size: "{{ openshift_logging_es_pvc_size }}"
  107. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_cluster_size | int }}"
  108. openshift_logging_elasticsearch_storage_type: "{{ elasticsearch_storage_type | default(default_elasticsearch_storage_type) }}"
  109. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_pv_selector }}"
  110. openshift_logging_elasticsearch_pvc_storage_class_name: "{{ openshift_logging_es_pvc_storage_class_name | default() }}"
  111. with_sequence: count={{ openshift_logging_es_cluster_size | int - openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count }}
  112. loop_control:
  113. loop_var: outer_item
  114. - set_fact:
  115. __logging_scale_up: True
  116. when:
  117. - openshift_logging_es_cluster_size | int - openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count > 0
  118. - set_fact: es_ops_indices={{ es_ops_indices | default([]) + [item | int - 1] }}
  119. with_sequence: count={{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count }}
  120. when:
  121. - openshift_logging_use_ops | bool
  122. - openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count > 0
  123. - set_fact: es_ops_indices=[]
  124. when: openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count == 0
  125. - set_fact: openshift_logging_es_ops_pvc_prefix="logging-es-ops"
  126. when: openshift_logging_es_ops_pvc_prefix == ""
  127. - set_fact:
  128. 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' }}"
  129. when:
  130. - openshift_logging_use_ops | bool
  131. - include_role:
  132. name: openshift_logging_elasticsearch
  133. vars:
  134. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  135. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  136. openshift_logging_elasticsearch_deployment_name: "{{ outer_item.0.name }}"
  137. 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 }}"
  138. openshift_logging_elasticsearch_ops_deployment: true
  139. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_ops_cluster_size | int }}"
  140. 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) }}"
  141. openshift_logging_elasticsearch_hostmount_path: "{{ outer_item.0.volumes['elasticsearch-storage'].hostPath.path if outer_item.0.volumes['elasticsearch-storage'].hostPath is defined else '' }}"
  142. openshift_logging_elasticsearch_pvc_size: "{{ openshift_logging_es_ops_pvc_size }}"
  143. openshift_logging_elasticsearch_pvc_dynamic: "{{ openshift_logging_es_ops_pvc_dynamic }}"
  144. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_ops_pv_selector }}"
  145. openshift_logging_elasticsearch_pvc_storage_class_name: "{{ openshift_logging_es_ops_pvc_storage_class_name | default() }}"
  146. openshift_logging_elasticsearch_memory_limit: "{{ openshift_logging_es_ops_memory_limit }}"
  147. openshift_logging_elasticsearch_cpu_limit: "{{ openshift_logging_es_ops_cpu_limit }}"
  148. openshift_logging_elasticsearch_cpu_request: "{{ openshift_logging_es_ops_cpu_request }}"
  149. openshift_logging_elasticsearch_nodeselector: "{{ openshift_logging_es_ops_nodeselector if outer_item.0.nodeSelector | default(None) is none else outer_item.0.nodeSelector }}"
  150. openshift_logging_elasticsearch_storage_group: "{{ [openshift_logging_es_ops_storage_group] if outer_item.0.storageGroups | default([]) | length == 0 else outer_item.0.storageGroups }}"
  151. openshift_logging_es_key: "{{ openshift_logging_es_ops_key }}"
  152. openshift_logging_es_cert: "{{ openshift_logging_es_ops_cert }}"
  153. openshift_logging_es_ca_ext: "{{ openshift_logging_es_ops_ca_ext }}"
  154. openshift_logging_es_hostname: "{{ openshift_logging_es_ops_hostname }}"
  155. openshift_logging_es_edge_term_policy: "{{ openshift_logging_es_ops_edge_term_policy | default('') }}"
  156. openshift_logging_es_allow_external: "{{ openshift_logging_es_ops_allow_external }}"
  157. openshift_logging_es_number_of_shards: "{{ openshift_logging_es_ops_number_of_shards | default(None) }}"
  158. openshift_logging_es_number_of_replicas: "{{ openshift_logging_es_ops_number_of_replicas | default(None) }}"
  159. _es_containers: "{{ outer_item.0.containers}}"
  160. _es_configmap: "{{ openshift_logging_facts | walk('elasticsearch_ops#configmaps#logging-elasticsearch-ops#elasticsearch.yml', '{}', delimiter='#') | from_yaml }}"
  161. with_together:
  162. - "{{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.values() | list }}"
  163. - "{{ openshift_logging_facts.elasticsearch_ops.pvcs }}"
  164. - "{{ es_ops_indices }}"
  165. loop_control:
  166. loop_var: outer_item
  167. when:
  168. - openshift_logging_use_ops | bool
  169. - openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count > 0
  170. # Create any new DC that may be required
  171. - include_role:
  172. name: openshift_logging_elasticsearch
  173. vars:
  174. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  175. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  176. openshift_logging_elasticsearch_pvc_name: "{{ openshift_logging_es_ops_pvc_prefix }}-{{ outer_item | int + openshift_logging_facts.elasticsearch_ops.deploymentconfigs | count - 1 }}"
  177. openshift_logging_elasticsearch_ops_deployment: true
  178. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_ops_cluster_size | int }}"
  179. openshift_logging_elasticsearch_storage_type: "{{ elasticsearch_storage_type | default(default_elasticsearch_storage_type) }}"
  180. openshift_logging_elasticsearch_pvc_size: "{{ openshift_logging_es_ops_pvc_size }}"
  181. openshift_logging_elasticsearch_pvc_dynamic: "{{ openshift_logging_es_ops_pvc_dynamic }}"
  182. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_ops_pv_selector }}"
  183. openshift_logging_elasticsearch_pvc_storage_class_name: "{{ openshift_logging_es_ops_pvc_storage_class_name | default() }}"
  184. openshift_logging_elasticsearch_memory_limit: "{{ openshift_logging_es_ops_memory_limit }}"
  185. openshift_logging_elasticsearch_cpu_limit: "{{ openshift_logging_es_ops_cpu_limit }}"
  186. openshift_logging_elasticsearch_cpu_request: "{{ openshift_logging_es_ops_cpu_request }}"
  187. openshift_logging_elasticsearch_nodeselector: "{{ openshift_logging_es_ops_nodeselector }}"
  188. openshift_logging_es_key: "{{ openshift_logging_es_ops_key }}"
  189. openshift_logging_es_cert: "{{ openshift_logging_es_ops_cert }}"
  190. openshift_logging_es_ca_ext: "{{ openshift_logging_es_ops_ca_ext }}"
  191. openshift_logging_es_hostname: "{{ openshift_logging_es_ops_hostname }}"
  192. openshift_logging_es_edge_term_policy: "{{ openshift_logging_es_ops_edge_term_policy | default('') }}"
  193. openshift_logging_es_allow_external: "{{ openshift_logging_es_ops_allow_external }}"
  194. with_sequence: count={{ openshift_logging_es_ops_cluster_size | int - openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count }}
  195. loop_control:
  196. loop_var: outer_item
  197. when:
  198. - openshift_logging_use_ops | bool
  199. - set_fact:
  200. __logging_ops_scale_up: True
  201. when:
  202. - openshift_logging_use_ops | bool
  203. - openshift_logging_es_ops_cluster_size | int - openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count > 0
  204. ## Kibana
  205. - import_role:
  206. name: openshift_logging_kibana
  207. vars:
  208. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  209. openshift_logging_kibana_namespace: "{{ openshift_logging_namespace }}"
  210. openshift_logging_kibana_master_url: "{{ openshift_logging_master_url }}"
  211. openshift_logging_kibana_master_public_url: "{{ openshift_logging_master_public_url }}"
  212. openshift_logging_kibana_replicas: "{{ openshift_logging_kibana_replica_count }}"
  213. openshift_logging_kibana_es_host: "{{ openshift_logging_es_host }}"
  214. openshift_logging_kibana_es_port: "{{ openshift_logging_es_port }}"
  215. openshift_logging_kibana_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  216. - import_role:
  217. name: openshift_logging_kibana
  218. vars:
  219. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  220. openshift_logging_kibana_ops_deployment: true
  221. openshift_logging_kibana_namespace: "{{ openshift_logging_namespace }}"
  222. openshift_logging_kibana_master_url: "{{ openshift_logging_master_url }}"
  223. openshift_logging_kibana_master_public_url: "{{ openshift_logging_master_public_url }}"
  224. openshift_logging_kibana_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  225. openshift_logging_kibana_es_host: "{{ openshift_logging_es_ops_host }}"
  226. openshift_logging_kibana_es_port: "{{ openshift_logging_es_ops_port }}"
  227. openshift_logging_kibana_nodeselector: "{{ openshift_logging_kibana_ops_nodeselector }}"
  228. openshift_logging_kibana_cpu_limit: "{{ openshift_logging_kibana_ops_cpu_limit }}"
  229. openshift_logging_kibana_cpu_request: "{{ openshift_logging_kibana_ops_cpu_request }}"
  230. openshift_logging_kibana_memory_limit: "{{ openshift_logging_kibana_ops_memory_limit }}"
  231. openshift_logging_kibana_hostname: "{{ openshift_logging_kibana_ops_hostname }}"
  232. openshift_logging_kibana_replicas: "{{ openshift_logging_kibana_ops_replica_count }}"
  233. openshift_logging_kibana_proxy_debug: "{{ openshift_logging_kibana_ops_proxy_debug }}"
  234. openshift_logging_kibana_proxy_cpu_limit: "{{ openshift_logging_kibana_ops_proxy_cpu_limit }}"
  235. openshift_logging_kibana_proxy_cpu_request: "{{ openshift_logging_kibana_ops_proxy_cpu_request }}"
  236. openshift_logging_kibana_proxy_memory_limit: "{{ openshift_logging_kibana_ops_proxy_memory_limit }}"
  237. openshift_logging_kibana_cert: "{{ openshift_logging_kibana_ops_cert }}"
  238. openshift_logging_kibana_key: "{{ openshift_logging_kibana_ops_key }}"
  239. openshift_logging_kibana_ca: "{{ openshift_logging_kibana_ops_ca}}"
  240. when:
  241. - openshift_logging_use_ops | bool
  242. - include_tasks: annotate_ops_projects.yaml
  243. ## Curator
  244. - import_role:
  245. name: openshift_logging_curator
  246. vars:
  247. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  248. openshift_logging_curator_namespace: "{{ openshift_logging_namespace }}"
  249. openshift_logging_curator_es_host: "{{ openshift_logging_es_host }}"
  250. openshift_logging_curator_es_port: "{{ openshift_logging_es_port }}"
  251. openshift_logging_curator_master_url: "{{ openshift_logging_master_url }}"
  252. openshift_logging_curator_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  253. - import_role:
  254. name: openshift_logging_curator
  255. vars:
  256. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  257. openshift_logging_curator_ops_deployment: true
  258. openshift_logging_curator_es_host: "{{ openshift_logging_es_ops_host }}"
  259. openshift_logging_curator_es_port: "{{ openshift_logging_es_ops_port }}"
  260. openshift_logging_curator_namespace: "{{ openshift_logging_namespace }}"
  261. openshift_logging_curator_master_url: "{{ openshift_logging_master_url }}"
  262. openshift_logging_curator_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  263. openshift_logging_curator_cpu_limit: "{{ openshift_logging_curator_ops_cpu_limit }}"
  264. openshift_logging_curator_cpu_request: "{{ openshift_logging_curator_ops_cpu_request }}"
  265. openshift_logging_curator_memory_limit: "{{ openshift_logging_curator_ops_memory_limit }}"
  266. openshift_logging_curator_nodeselector: "{{ openshift_logging_curator_ops_nodeselector }}"
  267. when:
  268. - openshift_logging_use_ops | bool
  269. ## Mux
  270. - import_role:
  271. name: openshift_logging_mux
  272. vars:
  273. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  274. openshift_logging_mux_ops_host: "{{ ( openshift_logging_use_ops | bool ) | ternary('logging-es-ops', 'logging-es') }}"
  275. openshift_logging_mux_namespace: "{{ openshift_logging_namespace }}"
  276. openshift_logging_mux_master_url: "{{ openshift_logging_master_url }}"
  277. openshift_logging_mux_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  278. when:
  279. - openshift_logging_use_mux | bool
  280. ## Fluentd
  281. - import_role:
  282. name: openshift_logging_fluentd
  283. vars:
  284. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  285. openshift_logging_fluentd_ops_host: "{{ ( openshift_logging_use_ops | bool ) | ternary('logging-es-ops', 'logging-es') }}"
  286. openshift_logging_fluentd_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  287. openshift_logging_fluentd_master_url: "{{ openshift_logging_master_url }}"
  288. openshift_logging_fluentd_namespace: "{{ openshift_logging_namespace }}"
  289. ## EventRouter
  290. - import_role:
  291. name: openshift_logging_eventrouter
  292. when:
  293. openshift_logging_install_eventrouter | default(false) | bool
  294. # Update asset config in openshift-web-console namespace
  295. - name: Add Kibana route information to web console asset config
  296. include_role:
  297. name: openshift_web_console
  298. tasks_from: update_console_config.yml
  299. vars:
  300. console_config_edits:
  301. - key: clusterInfo#loggingPublicURL
  302. value: "https://{{ openshift_logging_kibana_hostname }}"
  303. when:
  304. - openshift_web_console_install | default(true) | bool