install_logging.yaml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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: Create logging cert directory
  36. file:
  37. path: "{{ openshift.common.config_base }}/logging"
  38. state: directory
  39. mode: 0755
  40. changed_when: False
  41. check_mode: no
  42. - include: generate_certs.yaml
  43. vars:
  44. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  45. ## Elasticsearch
  46. - set_fact: es_indices={{ es_indices | default([]) + [item | int - 1] }}
  47. with_sequence: count={{ openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count }}
  48. when: openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count > 0
  49. - set_fact: es_indices=[]
  50. when: openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count == 0
  51. - set_fact: openshift_logging_es_pvc_prefix="logging-es"
  52. when: openshift_logging_es_pvc_prefix == ""
  53. - set_fact:
  54. 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') }}"
  55. # We don't allow scaling down of ES nodes currently
  56. - include_role:
  57. name: openshift_logging_elasticsearch
  58. vars:
  59. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  60. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  61. openshift_logging_elasticsearch_deployment_name: "{{ item.0.name }}"
  62. openshift_logging_elasticsearch_pvc_name: "{{ openshift_logging_es_pvc_prefix ~ '-' ~ item.2 if item.1 is none else item.1 }}"
  63. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_cluster_size | int }}"
  64. openshift_logging_elasticsearch_storage_type: "{{ elasticsearch_storage_type }}"
  65. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_pv_selector }}"
  66. openshift_logging_elasticsearch_nodeselector: "{{ openshift_logging_es_nodeselector if item.0.nodeSelector | default(None) is none else item.0.nodeSelector }}"
  67. openshift_logging_elasticsearch_storage_group: "{{ [openshift_logging_es_storage_group] if item.0.storageGroups | default([]) | length == 0 else item.0.storageGroups }}"
  68. _es_containers: "{{item.0.containers}}"
  69. with_together:
  70. - "{{ openshift_logging_facts.elasticsearch.deploymentconfigs.values() }}"
  71. - "{{ openshift_logging_facts.elasticsearch.pvcs }}"
  72. - "{{ es_indices }}"
  73. when:
  74. - openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count > 0
  75. # Create any new DC that may be required
  76. - include_role:
  77. name: openshift_logging_elasticsearch
  78. vars:
  79. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  80. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  81. openshift_logging_elasticsearch_pvc_name: "{{ openshift_logging_es_pvc_prefix }}-{{ item | int + openshift_logging_facts.elasticsearch.deploymentconfigs | count - 1 }}"
  82. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_cluster_size | int }}"
  83. openshift_logging_elasticsearch_storage_type: "{{ elasticsearch_storage_type }}"
  84. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_pv_selector }}"
  85. with_sequence: count={{ openshift_logging_es_cluster_size | int - openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count }}
  86. - set_fact: es_ops_indices={{ es_ops_indices | default([]) + [item | int - 1] }}
  87. with_sequence: count={{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count }}
  88. when:
  89. - openshift_logging_use_ops | bool
  90. - openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count > 0
  91. - set_fact: es_ops_indices=[]
  92. when: openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count == 0
  93. - set_fact: openshift_logging_es_ops_pvc_prefix="logging-es-ops"
  94. when: openshift_logging_es_ops_pvc_prefix == ""
  95. - set_fact:
  96. 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') }}"
  97. when:
  98. - openshift_logging_use_ops | bool
  99. - include_role:
  100. name: openshift_logging_elasticsearch
  101. vars:
  102. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  103. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  104. openshift_logging_elasticsearch_deployment_name: "{{ item.0.name }}"
  105. openshift_logging_elasticsearch_pvc_name: "{{ openshift_logging_es_ops_pvc_prefix ~ '-' ~ item.2 if item.1 is none else item.1 }}"
  106. openshift_logging_elasticsearch_ops_deployment: true
  107. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_ops_cluster_size | int }}"
  108. openshift_logging_elasticsearch_storage_type: "{{ elasticsearch_storage_type }}"
  109. openshift_logging_elasticsearch_pvc_size: "{{ openshift_logging_es_ops_pvc_size }}"
  110. openshift_logging_elasticsearch_pvc_dynamic: "{{ openshift_logging_es_ops_pvc_dynamic }}"
  111. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_ops_pv_selector }}"
  112. openshift_logging_elasticsearch_memory_limit: "{{ openshift_logging_es_ops_memory_limit }}"
  113. openshift_logging_elasticsearch_cpu_limit: "{{ openshift_logging_es_ops_cpu_limit }}"
  114. openshift_logging_elasticsearch_cpu_request: "{{ openshift_logging_es_ops_cpu_request }}"
  115. openshift_logging_elasticsearch_nodeselector: "{{ openshift_logging_es_ops_nodeselector if item.0.nodeSelector | default(None) is none else item.0.nodeSelector }}"
  116. openshift_logging_elasticsearch_storage_group: "{{ [openshift_logging_es_ops_storage_group] if item.0.storageGroups | default([]) | length == 0 else item.0.storageGroups }}"
  117. openshift_logging_es_key: "{{ openshift_logging_es_ops_key }}"
  118. openshift_logging_es_cert: "{{ openshift_logging_es_ops_cert }}"
  119. openshift_logging_es_ca_ext: "{{ openshift_logging_es_ops_ca_ext }}"
  120. openshift_logging_es_hostname: "{{ openshift_logging_es_ops_hostname }}"
  121. openshift_logging_es_edge_term_policy: "{{ openshift_logging_es_ops_edge_term_policy | default('') }}"
  122. openshift_logging_es_allow_external: "{{ openshift_logging_es_ops_allow_external }}"
  123. _es_containers: "{{item.0.containers}}"
  124. with_together:
  125. - "{{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.values() }}"
  126. - "{{ openshift_logging_facts.elasticsearch_ops.pvcs }}"
  127. - "{{ es_ops_indices }}"
  128. when:
  129. - openshift_logging_use_ops | bool
  130. - openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count > 0
  131. # Create any new DC that may be required
  132. - include_role:
  133. name: openshift_logging_elasticsearch
  134. vars:
  135. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  136. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  137. openshift_logging_elasticsearch_pvc_name: "{{ openshift_logging_es_ops_pvc_prefix }}-{{ item | int + openshift_logging_facts.elasticsearch_ops.deploymentconfigs | count - 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 }}"
  141. openshift_logging_elasticsearch_pvc_size: "{{ openshift_logging_es_ops_pvc_size }}"
  142. openshift_logging_elasticsearch_pvc_dynamic: "{{ openshift_logging_es_ops_pvc_dynamic }}"
  143. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_ops_pv_selector }}"
  144. openshift_logging_elasticsearch_memory_limit: "{{ openshift_logging_es_ops_memory_limit }}"
  145. openshift_logging_elasticsearch_cpu_limit: "{{ openshift_logging_es_ops_cpu_limit }}"
  146. openshift_logging_elasticsearch_cpu_request: "{{ openshift_logging_es_ops_cpu_request }}"
  147. openshift_logging_elasticsearch_nodeselector: "{{ openshift_logging_es_ops_nodeselector }}"
  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. with_sequence: count={{ openshift_logging_es_ops_cluster_size | int - openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count }}
  155. when:
  156. - openshift_logging_use_ops | bool
  157. ## Kibana
  158. - include_role:
  159. name: openshift_logging_kibana
  160. vars:
  161. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  162. openshift_logging_kibana_namespace: "{{ openshift_logging_namespace }}"
  163. openshift_logging_kibana_master_url: "{{ openshift_logging_master_url }}"
  164. openshift_logging_kibana_master_public_url: "{{ openshift_logging_master_public_url }}"
  165. openshift_logging_kibana_replicas: "{{ openshift_logging_kibana_replica_count }}"
  166. openshift_logging_kibana_es_host: "{{ openshift_logging_es_host }}"
  167. openshift_logging_kibana_es_port: "{{ openshift_logging_es_port }}"
  168. openshift_logging_kibana_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  169. - include_role:
  170. name: openshift_logging_kibana
  171. vars:
  172. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  173. openshift_logging_kibana_ops_deployment: true
  174. openshift_logging_kibana_namespace: "{{ openshift_logging_namespace }}"
  175. openshift_logging_kibana_master_url: "{{ openshift_logging_master_url }}"
  176. openshift_logging_kibana_master_public_url: "{{ openshift_logging_master_public_url }}"
  177. openshift_logging_kibana_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  178. openshift_logging_kibana_es_host: "{{ openshift_logging_es_ops_host }}"
  179. openshift_logging_kibana_es_port: "{{ openshift_logging_es_ops_port }}"
  180. openshift_logging_kibana_nodeselector: "{{ openshift_logging_kibana_ops_nodeselector }}"
  181. openshift_logging_kibana_cpu_limit: "{{ openshift_logging_kibana_ops_cpu_limit }}"
  182. openshift_logging_kibana_cpu_request: "{{ openshift_logging_kibana_ops_cpu_request }}"
  183. openshift_logging_kibana_memory_limit: "{{ openshift_logging_kibana_ops_memory_limit }}"
  184. openshift_logging_kibana_hostname: "{{ openshift_logging_kibana_ops_hostname }}"
  185. openshift_logging_kibana_replicas: "{{ openshift_logging_kibana_ops_replica_count }}"
  186. openshift_logging_kibana_proxy_debug: "{{ openshift_logging_kibana_ops_proxy_debug }}"
  187. openshift_logging_kibana_proxy_cpu_limit: "{{ openshift_logging_kibana_ops_proxy_cpu_limit }}"
  188. openshift_logging_kibana_proxy_cpu_request: "{{ openshift_logging_kibana_ops_proxy_cpu_request }}"
  189. openshift_logging_kibana_proxy_memory_limit: "{{ openshift_logging_kibana_ops_proxy_memory_limit }}"
  190. openshift_logging_kibana_cert: "{{ openshift_logging_kibana_ops_cert }}"
  191. openshift_logging_kibana_key: "{{ openshift_logging_kibana_ops_key }}"
  192. openshift_logging_kibana_ca: "{{ openshift_logging_kibana_ops_ca}}"
  193. when:
  194. - openshift_logging_use_ops | bool
  195. - include: annotate_ops_projects.yaml
  196. ## Curator
  197. - include_role:
  198. name: openshift_logging_curator
  199. vars:
  200. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  201. openshift_logging_curator_namespace: "{{ openshift_logging_namespace }}"
  202. openshift_logging_curator_es_host: "{{ openshift_logging_es_host }}"
  203. openshift_logging_curator_es_port: "{{ openshift_logging_es_port }}"
  204. openshift_logging_curator_master_url: "{{ openshift_logging_master_url }}"
  205. openshift_logging_curator_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  206. - include_role:
  207. name: openshift_logging_curator
  208. vars:
  209. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  210. openshift_logging_curator_ops_deployment: true
  211. openshift_logging_curator_es_host: "{{ openshift_logging_es_ops_host }}"
  212. openshift_logging_curator_es_port: "{{ openshift_logging_es_ops_port }}"
  213. openshift_logging_curator_namespace: "{{ openshift_logging_namespace }}"
  214. openshift_logging_curator_master_url: "{{ openshift_logging_master_url }}"
  215. openshift_logging_curator_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  216. openshift_logging_curator_cpu_limit: "{{ openshift_logging_curator_ops_cpu_limit }}"
  217. openshift_logging_curator_cpu_request: "{{ openshift_logging_curator_ops_cpu_request }}"
  218. openshift_logging_curator_memory_limit: "{{ openshift_logging_curator_ops_memory_limit }}"
  219. openshift_logging_curator_nodeselector: "{{ openshift_logging_curator_ops_nodeselector }}"
  220. when:
  221. - openshift_logging_use_ops | bool
  222. ## Mux
  223. - include_role:
  224. name: openshift_logging_mux
  225. vars:
  226. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  227. openshift_logging_mux_ops_host: "{{ ( openshift_logging_use_ops | bool ) | ternary('logging-es-ops', 'logging-es') }}"
  228. openshift_logging_mux_namespace: "{{ openshift_logging_namespace }}"
  229. openshift_logging_mux_master_url: "{{ openshift_logging_master_url }}"
  230. openshift_logging_mux_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  231. when:
  232. - openshift_logging_use_mux | bool
  233. ## Fluentd
  234. - include_role:
  235. name: openshift_logging_fluentd
  236. vars:
  237. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  238. openshift_logging_fluentd_ops_host: "{{ ( openshift_logging_use_ops | bool ) | ternary('logging-es-ops', 'logging-es') }}"
  239. openshift_logging_fluentd_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  240. openshift_logging_fluentd_master_url: "{{ openshift_logging_master_url }}"
  241. openshift_logging_fluentd_namespace: "{{ openshift_logging_namespace }}"
  242. ## EventRouter
  243. - include_role:
  244. name: openshift_logging_eventrouter
  245. when:
  246. openshift_logging_install_eventrouter | default(false) | bool
  247. - include: update_master_config.yaml