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