install_logging.yaml 16 KB

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