install_logging.yaml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. _es_configmap: "{{ openshift_logging_facts | walk('elasticsearch#configmaps#logging-elasticsearch#elasticsearch.yml', '{}', delimiter='#') | from_yaml }}"
  70. with_together:
  71. - "{{ openshift_logging_facts.elasticsearch.deploymentconfigs.values() }}"
  72. - "{{ openshift_logging_facts.elasticsearch.pvcs }}"
  73. - "{{ es_indices }}"
  74. when:
  75. - openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count > 0
  76. # Create any new DC that may be required
  77. - include_role:
  78. name: openshift_logging_elasticsearch
  79. vars:
  80. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  81. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  82. openshift_logging_elasticsearch_pvc_name: "{{ openshift_logging_es_pvc_prefix }}-{{ item | int + openshift_logging_facts.elasticsearch.deploymentconfigs | count - 1 }}"
  83. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_cluster_size | int }}"
  84. openshift_logging_elasticsearch_storage_type: "{{ elasticsearch_storage_type }}"
  85. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_pv_selector }}"
  86. with_sequence: count={{ openshift_logging_es_cluster_size | int - openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count }}
  87. - set_fact: es_ops_indices={{ es_ops_indices | default([]) + [item | int - 1] }}
  88. with_sequence: count={{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count }}
  89. when:
  90. - openshift_logging_use_ops | bool
  91. - openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count > 0
  92. - set_fact: es_ops_indices=[]
  93. when: openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count == 0
  94. - set_fact: openshift_logging_es_ops_pvc_prefix="logging-es-ops"
  95. when: openshift_logging_es_ops_pvc_prefix == ""
  96. - set_fact:
  97. 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') }}"
  98. when:
  99. - openshift_logging_use_ops | bool
  100. - include_role:
  101. name: openshift_logging_elasticsearch
  102. vars:
  103. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  104. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  105. openshift_logging_elasticsearch_deployment_name: "{{ item.0.name }}"
  106. openshift_logging_elasticsearch_pvc_name: "{{ openshift_logging_es_ops_pvc_prefix ~ '-' ~ item.2 if item.1 is none else item.1 }}"
  107. openshift_logging_elasticsearch_ops_deployment: true
  108. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_ops_cluster_size | int }}"
  109. openshift_logging_elasticsearch_storage_type: "{{ elasticsearch_storage_type }}"
  110. openshift_logging_elasticsearch_pvc_size: "{{ openshift_logging_es_ops_pvc_size }}"
  111. openshift_logging_elasticsearch_pvc_dynamic: "{{ openshift_logging_es_ops_pvc_dynamic }}"
  112. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_ops_pv_selector }}"
  113. openshift_logging_elasticsearch_memory_limit: "{{ openshift_logging_es_ops_memory_limit }}"
  114. openshift_logging_elasticsearch_cpu_limit: "{{ openshift_logging_es_ops_cpu_limit }}"
  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. openshift_logging_es_number_of_shards: "{{ openshift_logging_es_ops_number_of_shards | default(None) }}"
  124. openshift_logging_es_number_of_replicas: "{{ openshift_logging_es_ops_number_of_replicas | default(None) }}"
  125. _es_containers: "{{item.0.containers}}"
  126. _es_configmap: "{{ openshift_logging_facts | walk('elasticsearch_ops#configmaps#logging-elasticsearch-ops#elasticsearch.yml', '{}', delimiter='#') | from_yaml }}"
  127. with_together:
  128. - "{{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.values() }}"
  129. - "{{ openshift_logging_facts.elasticsearch_ops.pvcs }}"
  130. - "{{ es_ops_indices }}"
  131. when:
  132. - openshift_logging_use_ops | bool
  133. - openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count > 0
  134. # Create any new DC that may be required
  135. - include_role:
  136. name: openshift_logging_elasticsearch
  137. vars:
  138. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  139. openshift_logging_elasticsearch_namespace: "{{ openshift_logging_namespace }}"
  140. openshift_logging_elasticsearch_pvc_name: "{{ openshift_logging_es_ops_pvc_prefix }}-{{ item | int + openshift_logging_facts.elasticsearch_ops.deploymentconfigs | count - 1 }}"
  141. openshift_logging_elasticsearch_ops_deployment: true
  142. openshift_logging_elasticsearch_replica_count: "{{ openshift_logging_es_ops_cluster_size | int }}"
  143. openshift_logging_elasticsearch_storage_type: "{{ elasticsearch_storage_type }}"
  144. openshift_logging_elasticsearch_pvc_size: "{{ openshift_logging_es_ops_pvc_size }}"
  145. openshift_logging_elasticsearch_pvc_dynamic: "{{ openshift_logging_es_ops_pvc_dynamic }}"
  146. openshift_logging_elasticsearch_pvc_pv_selector: "{{ openshift_logging_es_ops_pv_selector }}"
  147. openshift_logging_elasticsearch_memory_limit: "{{ openshift_logging_es_ops_memory_limit }}"
  148. openshift_logging_elasticsearch_cpu_limit: "{{ openshift_logging_es_ops_cpu_limit }}"
  149. openshift_logging_elasticsearch_nodeselector: "{{ openshift_logging_es_ops_nodeselector }}"
  150. openshift_logging_es_key: "{{ openshift_logging_es_ops_key }}"
  151. openshift_logging_es_cert: "{{ openshift_logging_es_ops_cert }}"
  152. openshift_logging_es_ca_ext: "{{ openshift_logging_es_ops_ca_ext }}"
  153. openshift_logging_es_hostname: "{{ openshift_logging_es_ops_hostname }}"
  154. openshift_logging_es_edge_term_policy: "{{ openshift_logging_es_ops_edge_term_policy | default('') }}"
  155. openshift_logging_es_allow_external: "{{ openshift_logging_es_ops_allow_external }}"
  156. with_sequence: count={{ openshift_logging_es_ops_cluster_size | int - openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count }}
  157. when:
  158. - openshift_logging_use_ops | bool
  159. ## Kibana
  160. - include_role:
  161. name: openshift_logging_kibana
  162. vars:
  163. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  164. openshift_logging_kibana_namespace: "{{ openshift_logging_namespace }}"
  165. openshift_logging_kibana_master_url: "{{ openshift_logging_master_url }}"
  166. openshift_logging_kibana_master_public_url: "{{ openshift_logging_master_public_url }}"
  167. openshift_logging_kibana_replicas: "{{ openshift_logging_kibana_replica_count }}"
  168. openshift_logging_kibana_es_host: "{{ openshift_logging_es_host }}"
  169. openshift_logging_kibana_es_port: "{{ openshift_logging_es_port }}"
  170. openshift_logging_kibana_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  171. - include_role:
  172. name: openshift_logging_kibana
  173. vars:
  174. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  175. openshift_logging_kibana_ops_deployment: true
  176. openshift_logging_kibana_namespace: "{{ openshift_logging_namespace }}"
  177. openshift_logging_kibana_master_url: "{{ openshift_logging_master_url }}"
  178. openshift_logging_kibana_master_public_url: "{{ openshift_logging_master_public_url }}"
  179. openshift_logging_kibana_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  180. openshift_logging_kibana_es_host: "{{ openshift_logging_es_ops_host }}"
  181. openshift_logging_kibana_es_port: "{{ openshift_logging_es_ops_port }}"
  182. openshift_logging_kibana_nodeselector: "{{ openshift_logging_kibana_ops_nodeselector }}"
  183. openshift_logging_kibana_cpu_limit: "{{ openshift_logging_kibana_ops_cpu_limit }}"
  184. openshift_logging_kibana_memory_limit: "{{ openshift_logging_kibana_ops_memory_limit }}"
  185. openshift_logging_kibana_hostname: "{{ openshift_logging_kibana_ops_hostname }}"
  186. openshift_logging_kibana_replicas: "{{ openshift_logging_kibana_ops_replica_count }}"
  187. openshift_logging_kibana_proxy_debug: "{{ openshift_logging_kibana_ops_proxy_debug }}"
  188. openshift_logging_kibana_proxy_cpu_limit: "{{ openshift_logging_kibana_ops_proxy_cpu_limit }}"
  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_memory_limit: "{{ openshift_logging_curator_ops_memory_limit }}"
  218. openshift_logging_curator_nodeselector: "{{ openshift_logging_curator_ops_nodeselector }}"
  219. when:
  220. - openshift_logging_use_ops | bool
  221. ## Mux
  222. - include_role:
  223. name: openshift_logging_mux
  224. vars:
  225. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  226. openshift_logging_mux_ops_host: "{{ ( openshift_logging_use_ops | bool ) | ternary('logging-es-ops', 'logging-es') }}"
  227. openshift_logging_mux_namespace: "{{ openshift_logging_namespace }}"
  228. openshift_logging_mux_master_url: "{{ openshift_logging_master_url }}"
  229. openshift_logging_mux_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  230. when:
  231. - openshift_logging_use_mux | bool
  232. ## Fluentd
  233. - include_role:
  234. name: openshift_logging_fluentd
  235. vars:
  236. generated_certs_dir: "{{openshift.common.config_base}}/logging"
  237. openshift_logging_fluentd_ops_host: "{{ ( openshift_logging_use_ops | bool ) | ternary('logging-es-ops', 'logging-es') }}"
  238. openshift_logging_fluentd_image_pull_secret: "{{ openshift_logging_image_pull_secret }}"
  239. openshift_logging_fluentd_master_url: "{{ openshift_logging_master_url }}"
  240. openshift_logging_fluentd_namespace: "{{ openshift_logging_namespace }}"
  241. ## EventRouter
  242. - include_role:
  243. name: openshift_logging_eventrouter
  244. when:
  245. openshift_logging_install_eventrouter | default(false) | bool
  246. - include: update_master_config.yaml