install_logging.yaml 17 KB

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