set_defaults_from_current.yml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. ---
  2. ## We are pulling default values from configmaps if they exist already
  3. ## Using conditional_set_fact allows us to set the value of a variable based on
  4. ## the value of another one, if it is already defined. Else we don't set the
  5. ## left hand side (it stays undefined as well).
  6. ## conditional_set_fact allows us to specify a fact source, so first we try to
  7. ## set variables in the logging-elasticsearch & logging-elasticsearch-ops configmaps
  8. ## afterwards we set the value of the variable based on the value in the inventory
  9. ## but fall back to using the value from a configmap as a default. If neither is set
  10. ## then the variable remains undefined and the role default will be used.
  11. # Elasticsearch
  12. - when: openshift_logging_facts['elasticsearch']['configmaps']['logging-elasticsearch'] is defined
  13. conditional_set_fact:
  14. facts: "{{ openshift_logging_facts['elasticsearch']['configmaps']['logging-elasticsearch']['elasticsearch.yml'] | flatten_dict }}"
  15. vars:
  16. __openshift_logging_es_number_of_shards: index.number_of_shards
  17. __openshift_logging_es_number_of_replicas: index.number_of_replicas
  18. - when: openshift_logging_facts['elasticsearch']['deploymentconfigs'].keys() | count > 0
  19. block:
  20. - set_fact:
  21. __es_dc_name: "{{ openshift_logging_facts['elasticsearch']['deploymentconfigs'].keys()[0] }}"
  22. - set_fact:
  23. __openshift_logging_es_recover_after_time: "{{ openshift_logging_facts['elasticsearch']['deploymentconfigs'][__es_dc_name]['containers']['elasticsearch']['env'] | entry_from_name_value_pair('RECOVER_AFTER_TIME') }}"
  24. - conditional_set_fact:
  25. facts: "{{ openshift_logging_facts['elasticsearch']['deploymentconfigs'][__es_dc_name]['containers'] | flatten_dict }}"
  26. vars:
  27. __openshift_logging_elasticsearch_cpu_limit: elasticsearch.resources.limits.cpu
  28. __openshift_logging_elasticsearch_memory_limit: elasticsearch.resources.limits.memory
  29. __openshift_logging_elasticsearch_cpu_request: elasticsearch.resources.requests.cpu
  30. __openshift_logging_elasticsearch_proxy_cpu_request: proxy.resources.requests.cpu
  31. __openshift_logging_elasticsearch_proxy_memory_limit: proxy.resources.limits.memory
  32. # Elasticsearch Ops
  33. - when: openshift_logging_facts['elasticsearch_ops']['configmaps']['logging-elasticsearch-ops'] is defined
  34. conditional_set_fact:
  35. facts: "{{ openshift_logging_facts['elasticsearch_ops']['configmaps']['logging-elasticsearch-ops']['elasticsearch.yml'] | flatten_dict }}"
  36. vars:
  37. __openshift_logging_es_ops_number_of_shards: index.number_of_shards
  38. __openshift_logging_es_ops_number_of_replicas: index.number_of_replicas
  39. - when: openshift_logging_facts['elasticsearch_ops']['deploymentconfigs'].keys() | count > 0
  40. block:
  41. - set_fact:
  42. __es_dc_name: "{{ openshift_logging_facts['elasticsearch_ops']['deploymentconfigs'].keys()[0] }}"
  43. - set_fact:
  44. __openshift_logging_es_ops_recover_after_time: "{{ openshift_logging_facts['elasticsearch_ops']['deploymentconfigs'][__es_dc_name]['containers']['elasticsearch']['env'] | entry_from_name_value_pair('RECOVER_AFTER_TIME') }}"
  45. - conditional_set_fact:
  46. facts: "{{ openshift_logging_facts['elasticsearch_ops']['deploymentconfigs'][__es_dc_name]['containers'] | flatten_dict }}"
  47. vars:
  48. __openshift_logging_es_ops_cpu_limit: elasticsearch.resources.limits.cpu
  49. __openshift_logging_es_ops_memory_limit: elasticsearch.resources.limits.memory
  50. __openshift_logging_es_ops_cpu_request: elasticsearch.resources.requests.cpu
  51. __openshift_logging_es_ops_proxy_cpu_request: proxy.resources.requests.cpu
  52. __openshift_logging_es_ops_proxy_memory_limit: proxy.resources.limits.memory
  53. # Kibana
  54. - when: openshift_logging_facts['kibana']['deploymentconfigs']['logging-kibana'] is defined
  55. conditional_set_fact:
  56. facts: "{{ openshift_logging_facts['kibana']['deploymentconfigs']['logging-kibana']['containers'] | flatten_dict }}"
  57. vars:
  58. __openshift_logging_kibana_cpu_limit: kibana.resources.limits.cpu
  59. __openshift_logging_kibana_cpu_request: kibana.resources.requests.cpu
  60. __openshift_logging_kibana_memory_limit: kibana.resources.limits.memory
  61. __openshift_logging_kibana_proxy_cpu_limit: kibana.resources.limits.cpu
  62. __openshift_logging_kibana_proxy_cpu_request: kibana-proxy.resources.requests.cpu
  63. __openshift_logging_kibana_proxy_memory_limit: kibana-proxy.resources.limits.memory
  64. # Kibana Ops
  65. - when: openshift_logging_facts['kibana_ops']['deploymentconfigs']['logging-kibana-ops'] is defined
  66. conditional_set_fact:
  67. facts: "{{ openshift_logging_facts['kibana_ops']['deploymentconfigs']['logging-kibana-ops']['containers'] | flatten_dict }}"
  68. vars:
  69. __openshift_logging_kibana_ops_cpu_limit: kibana.resources.limits.cpu
  70. __openshift_logging_kibana_ops_cpu_request: kibana.resources.requests.cpu
  71. __openshift_logging_kibana_ops_memory_limit: kibana.resources.limits.memory
  72. __openshift_logging_kibana_ops_proxy_cpu_limit: kibana.resources.limits.cpu
  73. __openshift_logging_kibana_ops_proxy_cpu_request: kibana-proxy.resources.requests.cpu
  74. __openshift_logging_kibana_ops_proxy_memory_limit: kibana-proxy.resources.limits.memory
  75. # Curator
  76. - when: openshift_logging_facts['curator']['deploymentconfigs']['logging-curator'] is defined
  77. block:
  78. - set_fact:
  79. __openshift_logging_curator_default_days: "{{ openshift_logging_facts['curator']['deploymentconfigs']['logging-curator']['containers']['curator']['env'] | entry_from_name_value_pair('CURATOR_DEFAULT_DAYS') }}"
  80. __openshift_logging_curator_run_hour: "{{ openshift_logging_facts['curator']['deploymentconfigs']['logging-curator']['containers']['curator']['env'] | entry_from_name_value_pair('CURATOR_RUN_HOUR') }}"
  81. __openshift_logging_curator_run_minute: "{{ openshift_logging_facts['curator']['deploymentconfigs']['logging-curator']['containers']['curator']['env'] | entry_from_name_value_pair('CURATOR_RUN_MINUTE') }}"
  82. __openshift_logging_curator_run_timezone: "{{ openshift_logging_facts['curator']['deploymentconfigs']['logging-curator']['containers']['curator']['env'] | entry_from_name_value_pair('CURATOR_RUN_TIMEZONE') }}"
  83. - conditional_set_fact:
  84. facts: "{{ openshift_logging_facts['curator']['deploymentconfigs']['logging-curator']['containers'] | flatten_dict }}"
  85. vars:
  86. __openshift_logging_curator_cpu_limit: curator.resources.limits.cpu
  87. __openshift_logging_curator_memory_limit: curator.resources.limits.memory
  88. __openshift_logging_curator_cpu_request: curator.resources.requests.cpu
  89. # Curator Ops
  90. - when: openshift_logging_facts['curator_ops']['deploymentconfigs']['logging-curator-ops'] is defined
  91. block:
  92. - set_fact:
  93. __openshift_logging_curator_ops_default_days: "{{ openshift_logging_facts['curator_ops']['deploymentconfigs']['logging-curator-ops']['containers']['curator']['env'] | entry_from_name_value_pair('CURATOR_DEFAULT_DAYS') }}"
  94. __openshift_logging_curator_ops_run_hour: "{{ openshift_logging_facts['curator_ops']['deploymentconfigs']['logging-curator-ops']['containers']['curator']['env'] | entry_from_name_value_pair('CURATOR_RUN_HOUR') }}"
  95. __openshift_logging_curator_ops_run_minute: "{{ openshift_logging_facts['curator_ops']['deploymentconfigs']['logging-curator-ops']['containers']['curator']['env'] | entry_from_name_value_pair('CURATOR_RUN_MINUTE') }}"
  96. __openshift_logging_curator_ops_run_timezone: "{{ openshift_logging_facts['curator_ops']['deploymentconfigs']['logging-curator-ops']['containers']['curator']['env'] | entry_from_name_value_pair('CURATOR_RUN_TIMEZONE') }}"
  97. - conditional_set_fact:
  98. facts: "{{ openshift_logging_facts['curator_ops']['deploymentconfigs']['logging-curator-ops']['containers'] | flatten_dict }}"
  99. vars:
  100. __openshift_logging_curator_ops_cpu_limit: curator.resources.limits.cpu
  101. __openshift_logging_curator_ops_memory_limit: curator.resources.limits.memory
  102. __openshift_logging_curator_ops_cpu_request: curator.resources.requests.cpu
  103. # Fluentd
  104. - when: openshift_logging_facts['fluentd']['daemonsets']['logging-fluentd'] is defined
  105. block:
  106. - set_fact:
  107. __openshift_logging_fluentd_file_buffer_limit: "{{ openshift_logging_facts['fluentd']['daemonsets']['logging-fluentd']['containers']['fluentd-elasticsearch']['env'] | entry_from_name_value_pair('FILE_BUFFER_LIMIT') }}"
  108. __openshift_logging_fluentd_buffer_queue_limit: "{{ openshift_logging_facts['fluentd']['daemonsets']['logging-fluentd']['containers']['fluentd-elasticsearch']['env'] | entry_from_name_value_pair('BUFFER_QUEUE_LIMIT') }}"
  109. __openshift_logging_fluentd_buffer_size_limit: "{{ openshift_logging_facts['fluentd']['daemonsets']['logging-fluentd']['containers']['fluentd-elasticsearch']['env'] | entry_from_name_value_pair('BUFFER_SIZE_LIMIT') }}"
  110. - conditional_set_fact:
  111. facts: "{{ openshift_logging_facts['fluentd']['daemonsets']['logging-fluentd']['containers'] | flatten_dict }}"
  112. vars:
  113. __openshift_logging_fluentd_cpu_limit: fluentd-elasticsearch.resources.limits.cpu
  114. __openshift_logging_fluentd_memory_limit: fluentd-elasticsearch.resources.limits.memory
  115. __openshift_logging_fluentd_cpu_request: fluentd-elasticsearch.resources.requests.cpu
  116. # Mux
  117. - when: openshift_logging_facts['mux']['deploymentconfigs']['logging-mux'] is defined
  118. block:
  119. - set_fact:
  120. __openshift_logging_mux_file_buffer_limit: "{{ openshift_logging_facts['mux']['deploymentconfigs']['logging-mux']['containers']['mux']['env'] | entry_from_name_value_pair('FILE_BUFFER_LIMIT') }}"
  121. __openshift_logging_mux_buffer_queue_limit: "{{ openshift_logging_facts['mux']['deploymentconfigs']['logging-mux']['containers']['mux']['env'] | entry_from_name_value_pair('BUFFER_QUEUE_LIMIT') }}"
  122. __openshift_logging_mux_buffer_size_limit: "{{ openshift_logging_facts['mux']['deploymentconfigs']['logging-mux']['containers']['mux']['env'] | entry_from_name_value_pair('BUFFER_SIZE_LIMIT') }}"
  123. - conditional_set_fact:
  124. facts: "{{ openshift_logging_facts['mux']['deploymentconfigs']['logging-mux']['containers'] | flatten_dict }}"
  125. vars:
  126. __openshift_logging_mux_cpu_limit: mux.resources.limits.cpu
  127. __openshift_logging_mux_memory_limit: mux.resources.limits.memory
  128. __openshift_logging_mux_cpu_request: mux.resources.requests.cpu
  129. # EventRouter
  130. - when: openshift_logging_facts['eventrouter']['deploymentconfigs']['logging-eventrouter'] is defined
  131. conditional_set_fact:
  132. facts: "{{ openshift_logging_facts['eventrouter']['deploymentconfigs']['logging-eventrouter']['containers'] | flatten_dict }}"
  133. vars:
  134. __openshift_logging_eventrouter_cpu_limit: kube-eventrouter.resources.limits.cpu
  135. __openshift_logging_eventrouter_cpu_request: kube-eventrouter.resources.requests.cpu
  136. __openshift_logging_eventrouter_memory_limit: kube-eventrouter.resources.limits.memory
  137. # Set the defaults based on collected facts
  138. - conditional_set_fact:
  139. facts: "{{ hostvars[inventory_hostname] }}"
  140. vars:
  141. # Elasticsearch
  142. openshift_logging_es_number_of_shards: openshift_logging_es_number_of_shards | __openshift_logging_es_number_of_shards
  143. openshift_logging_es_number_of_replicas: openshift_logging_es_number_of_replicas | __openshift_logging_es_number_of_replicas
  144. openshift_logging_elasticsearch_recover_after_time: openshift_logging_es_recover_after_time | __openshift_logging_es_recover_after_time
  145. openshift_logging_elasticsearch_cpu_limit: openshift_logging_elasticsearch_cpu_limit | __openshift_logging_elasticsearch_cpu_limit
  146. openshift_logging_elasticsearch_cpu_request: openshift_logging_elasticsearch_cpu_request | __openshift_logging_elasticsearch_cpu_request
  147. openshift_logging_elasticsearch_memory_limit: openshift_logging_elasticsearch_memory_limit | __openshift_logging_elasticsearch_memory_limit
  148. openshift_logging_elasticsearch_proxy_cpu_request: openshift_logging_elasticsearch_proxy_cpu_request | __openshift_logging_elasticsearch_proxy_cpu_request
  149. openshift_logging_elasticsearch_proxy_memory_limit: openshift_logging_elasticsearch_proxy_memory_limit | __openshift_logging_elasticsearch_proxy_memory_limit
  150. # Elasticsearch Ops
  151. openshift_logging_es_ops_number_of_shards: openshift_logging_es_ops_number_of_shards | __openshift_logging_es_ops_number_of_shards
  152. openshift_logging_es_ops_number_of_replicas: openshift_logging_es_ops_number_of_replicas | __openshift_logging_es_ops_number_of_replicas
  153. openshift_logging_es_ops_recover_after_time: openshift_logging_es_ops_recover_after_time | __openshift_logging_es_ops_recover_after_time
  154. openshift_logging_es_ops_cpu_limit: openshift_logging_es_ops_cpu_limit | __openshift_logging_es_ops_cpu_limit
  155. openshift_logging_es_ops_cpu_request: openshift_logging_es_ops_cpu_request | __openshift_logging_es_ops_cpu_request
  156. openshift_logging_es_ops_memory_limit: openshift_logging_es_ops_memory_limit | __openshift_logging_es_ops_memory_limit
  157. openshift_logging_es_ops_proxy_cpu_request: openshift_logging_es_ops_proxy_cpu_request | __openshift_logging_es_ops_proxy_cpu_request
  158. openshift_logging_es_ops_proxy_memory_limit: openshift_logging_es_ops_proxy_memory_limit | __openshift_logging_es_ops_proxy_memory_limit
  159. # Kibana
  160. openshift_logging_kibana_cpu_limit: openshift_logging_kibana_cpu_limit | __openshift_logging_kibana_cpu_limit
  161. openshift_logging_kibana_cpu_request: openshift_logging_kibana_cpu_request | __openshift_logging_kibana_cpu_request
  162. openshift_logging_kibana_memory_limit: openshift_logging_kibana_memory_limit | __openshift_logging_kibana_memory_limit
  163. openshift_logging_kibana_proxy_cpu_limit: openshift_logging_kibana_proxy_cpu_limit | __openshift_logging_kibana_proxy_cpu_limit
  164. openshift_logging_kibana_proxy_cpu_request: openshift_logging_kibana_proxy_cpu_request | __openshift_logging_kibana_proxy_cpu_request
  165. openshift_logging_kibana_proxy_memory_limit: openshift_logging_kibana_proxy_memory_limit | __openshift_logging_kibana_proxy_memory_limit
  166. # Kibana Ops
  167. openshift_logging_kibana_ops_cpu_limit: openshift_logging_kibana_ops_cpu_limit | __openshift_logging_kibana_ops_cpu_limit
  168. openshift_logging_kibana_ops_cpu_request: openshift_logging_kibana_ops_cpu_request | __openshift_logging_kibana_ops_cpu_request
  169. openshift_logging_kibana_ops_memory_limit: openshift_logging_kibana_ops_memory_limit | __openshift_logging_kibana_ops_memory_limit
  170. openshift_logging_kibana_ops_proxy_cpu_limit: openshift_logging_kibana_ops_proxy_cpu_limit | __openshift_logging_kibana_ops_proxy_cpu_limit
  171. openshift_logging_kibana_ops_proxy_cpu_request: openshift_logging_kibana_ops_proxy_cpu_request | __openshift_logging_kibana_ops_proxy_cpu_request
  172. openshift_logging_kibana_ops_proxy_memory_limit: openshift_logging_kibana_ops_proxy_memory_limit | __openshift_logging_kibana_ops_proxy_memory_limit
  173. # Curator
  174. openshift_logging_curator_default_days: openshift_logging_curator_default_days | __openshift_logging_curator_default_days
  175. openshift_logging_curator_run_hour: openshift_logging_curator_run_hour | __openshift_logging_curator_run_hour
  176. openshift_logging_curator_run_minute: openshift_logging_curator_run_minute | __openshift_logging_curator_run_minute
  177. openshift_logging_curator_run_timezone: openshift_logging_curator_run_timezone | __openshift_logging_curator_run_timezone
  178. openshift_logging_curator_cpu_limit: openshift_logging_curator_cpu_limit | __openshift_logging_curator_cpu_limit
  179. openshift_logging_curator_cpu_request: openshift_logging_curator_cpu_request | __openshift_logging_curator_cpu_request
  180. openshift_logging_curator_memory_limit: openshift_logging_curator_memory_limit | __openshift_logging_curator_memory_limit
  181. # Curator Ops
  182. openshift_logging_curator_ops_default_days: openshift_logging_curator_ops_default_days | __openshift_logging_curator_ops_default_days
  183. openshift_logging_curator_ops_run_hour: openshift_logging_curator_ops_run_hour | __openshift_logging_curator_ops_run_hour
  184. openshift_logging_curator_ops_run_minute: openshift_logging_curator_ops_run_minute | __openshift_logging_curator_ops_run_minute
  185. openshift_logging_curator_ops_run_timezone: openshift_logging_curator_ops_run_timezone | __openshift_logging_curator_ops_run_timezone
  186. openshift_logging_curator_ops_cpu_limit: openshift_logging_curator_ops_cpu_limit | __openshift_logging_curator_ops_cpu_limit
  187. openshift_logging_curator_ops_cpu_request: openshift_logging_curator_ops_cpu_request | __openshift_logging_curator_ops_cpu_request
  188. openshift_logging_curator_ops_memory_limit: openshift_logging_curator_ops_memory_limit | __openshift_logging_curator_ops_memory_limit
  189. # Fluentd
  190. openshift_logging_fluentd_cpu_limit: openshift_logging_fluentd_cpu_limit | __openshift_logging_fluentd_cpu_limit
  191. openshift_logging_fluentd_cpu_request: openshift_logging_fluentd_cpu_request | __openshift_logging_fluentd_cpu_request
  192. openshift_logging_fluentd_memory_limit: openshift_logging_fluentd_memory_limit | __openshift_logging_fluentd_memory_limit
  193. openshift_logging_fluentd_file_buffer_limit: openshift_logging_fluentd_file_buffer_limit | __openshift_logging_fluentd_file_buffer_limit
  194. openshift_logging_fluentd_buffer_queue_limit: openshift_logging_fluentd_buffer_queue_limit | __openshift_logging_fluentd_buffer_queue_limit
  195. openshift_logging_fluentd_buffer_size_limit: openshift_logging_fluentd_buffer_size_limit | __openshift_logging_fluentd_buffer_size_limit
  196. # Mux
  197. openshift_logging_mux_cpu_limit: openshift_logging_mux_cpu_limit | __openshift_logging_mux_cpu_limit
  198. openshift_logging_mux_cpu_request: openshift_logging_mux_cpu_request | __openshift_logging_mux_cpu_request
  199. openshift_logging_mux_memory_limit: openshift_logging_mux_memory_limit | __openshift_logging_mux_memory_limit
  200. openshift_logging_mux_buffer_queue_limit: openshift_logging_mux_buffer_queue_limit | __openshift_logging_mux_buffer_queue_limit
  201. openshift_logging_mux_buffer_size_limit: openshift_logging_mux_buffer_size_limit | __openshift_logging_mux_buffer_size_limit
  202. openshift_logging_mux_file_buffer_limit: openshift_logging_mux_file_buffer_limit | __openshift_logging_mux_file_buffer_limit
  203. # EventRouter
  204. openshift_logging_eventrouter_cpu_limit: openshift_logging_eventrouter_cpu_limit | __openshift_logging_eventrouter_cpu_limit
  205. openshift_logging_eventrouter_cpu_request: openshift_logging_eventrouter_cpu_request | __openshift_logging_eventrouter_cpu_request
  206. openshift_logging_eventrouter_memory_limit: openshift_logging_eventrouter_memory_limit | __openshift_logging_eventrouter_memory_limit