install_logging.yaml 17 KB

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