install_elasticsearch.yaml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. ---
  2. - name: Getting current ES deployment size
  3. set_fact: openshift_logging_current_es_size={{ openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | length }}
  4. - set_fact: openshift_logging_es_pvc_prefix="logging-es"
  5. when: not openshift_logging_es_pvc_prefix or openshift_logging_es_pvc_prefix == ''
  6. - set_fact: es_indices={{ es_indices | default([]) + [item | int - 1] }}
  7. with_sequence: count={{ openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count }}
  8. ### evaluate if the PVC attached to the dc currently matches the provided vars
  9. ## if it does then we reuse that pvc in the DC
  10. - include: set_es_storage.yaml
  11. vars:
  12. es_component: es
  13. es_name: "{{ deployment.0 }}"
  14. es_spec: "{{ deployment.1 }}"
  15. es_pvc_count: "{{ deployment.2 | int }}"
  16. es_node_selector: "{{ openshift_logging_es_nodeselector | default({}) }}"
  17. es_pvc_names_count: "{{ openshift_logging_facts.elasticsearch.pvcs.keys() | count }}"
  18. es_pvc_size: "{{ openshift_logging_es_pvc_size }}"
  19. es_pvc_prefix: "{{ openshift_logging_es_pvc_prefix }}"
  20. es_pvc_dynamic: "{{ openshift_logging_es_pvc_dynamic | bool }}"
  21. es_pv_selector: "{{ openshift_logging_es_pv_selector }}"
  22. es_cpu_limit: "{{ openshift_logging_es_cpu_limit }}"
  23. es_memory_limit: "{{ openshift_logging_es_memory_limit }}"
  24. with_together:
  25. - "{{ openshift_logging_facts.elasticsearch.deploymentconfigs.keys() }}"
  26. - "{{ openshift_logging_facts.elasticsearch.deploymentconfigs.values() }}"
  27. - "{{ es_indices | default([]) }}"
  28. loop_control:
  29. loop_var: deployment
  30. ## if it does not then we should create one that does and attach it
  31. ## create new dc/pvc is needed
  32. - include: set_es_storage.yaml
  33. vars:
  34. es_component: es
  35. es_name: "logging-es-{{'abcdefghijklmnopqrstuvwxyz0123456789'|random_word(8)}}"
  36. es_spec: "{}"
  37. es_pvc_count: "{{ item | int - 1 }}"
  38. es_node_selector: "{{ openshift_logging_es_nodeselector | default({}) }}"
  39. es_pvc_names_count: "{{ [openshift_logging_facts.elasticsearch.pvcs.keys() | count, openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count] | max }}"
  40. es_pvc_size: "{{ openshift_logging_es_pvc_size }}"
  41. es_pvc_prefix: "{{ openshift_logging_es_pvc_prefix }}"
  42. es_pvc_dynamic: "{{ openshift_logging_es_pvc_dynamic | bool }}"
  43. es_pv_selector: "{{ openshift_logging_es_pv_selector }}"
  44. es_cpu_limit: "{{ openshift_logging_es_cpu_limit }}"
  45. es_memory_limit: "{{ openshift_logging_es_memory_limit }}"
  46. with_sequence: count={{ openshift_logging_es_cluster_size | int - openshift_logging_facts.elasticsearch.deploymentconfigs | count }}
  47. # --------- Tasks for Operation clusters ---------
  48. - name: Getting current ES deployment size
  49. set_fact: openshift_logging_current_es_ops_size={{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | length }}
  50. - set_fact: openshift_logging_es_ops_pvc_prefix="{{ openshift_logging_es_ops_pvc_prefix | default('logging-es-ops') }}"
  51. - name: Validate Elasticsearch cluster size for Ops
  52. fail: msg="The openshift_logging_es_ops_cluster_size may not be scaled down more than 1 less (or 0) the number of Elasticsearch nodes already deployed"
  53. vars:
  54. es_dcs: "{{openshift_logging_facts.elasticsearch_ops.deploymentconfigs}}"
  55. cluster_size: "{{openshift_logging_es_ops_cluster_size|int}}"
  56. when:
  57. - openshift_logging_use_ops | bool
  58. - "{{es_dcs | length - openshift_logging_es_ops_cluster_size|int | abs > 1}}"
  59. check_mode: no
  60. - set_fact: openshift_logging_es_ops_pvc_prefix="logging-es-ops"
  61. when: not openshift_logging_es_ops_pvc_prefix or openshift_logging_es_ops_pvc_prefix == ''
  62. - set_fact: es_ops_indices={{ es_ops_indices | default([]) + [item | int - 1] }}
  63. with_sequence: count={{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count }}
  64. when:
  65. - openshift_logging_use_ops | bool
  66. - include: set_es_storage.yaml
  67. vars:
  68. es_component: es-ops
  69. es_name: "{{ deployment.0 }}"
  70. es_spec: "{{ deployment.1 }}"
  71. es_pvc_count: "{{ deployment.2 | int }}"
  72. es_node_selector: "{{ openshift_logging_es_ops_nodeselector | default({}) }}"
  73. es_pvc_names_count: "{{ openshift_logging_facts.elasticsearch_ops.pvcs.keys() | count }}"
  74. es_pvc_size: "{{ openshift_logging_es_ops_pvc_size }}"
  75. es_pvc_prefix: "{{ openshift_logging_es_ops_pvc_prefix }}"
  76. es_pvc_dynamic: "{{ openshift_logging_es_ops_pvc_dynamic | bool }}"
  77. es_pv_selector: "{{ openshift_logging_es_ops_pv_selector }}"
  78. es_cpu_limit: "{{ openshift_logging_es_ops_cpu_limit }}"
  79. es_memory_limit: "{{ openshift_logging_es_ops_memory_limit }}"
  80. with_together:
  81. - "{{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() }}"
  82. - "{{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.values() }}"
  83. - "{{ es_ops_indices | default([]) }}"
  84. loop_control:
  85. loop_var: deployment
  86. when:
  87. - openshift_logging_use_ops | bool
  88. ## if it does not then we should create one that does and attach it
  89. ## create new dc/pvc is needed
  90. - include: set_es_storage.yaml
  91. vars:
  92. es_component: es-ops
  93. es_name: "logging-es-ops-{{'abcdefghijklmnopqrstuvwxyz0123456789'|random_word(8)}}"
  94. es_spec: "{}"
  95. es_pvc_count: "{{ item | int - 1 }}"
  96. es_node_selector: "{{ openshift_logging_es_ops_nodeselector | default({}) }}"
  97. es_pvc_names_count: "{{ [openshift_logging_facts.elasticsearch_ops.pvcs.keys() | count, openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count] | max }}"
  98. es_pvc_size: "{{ openshift_logging_es_ops_pvc_size }}"
  99. es_pvc_prefix: "{{ openshift_logging_es_ops_pvc_prefix }}"
  100. es_pvc_dynamic: "{{ openshift_logging_es_ops_pvc_dynamic | bool }}"
  101. es_pv_selector: "{{ openshift_logging_es_ops_pv_selector }}"
  102. es_cpu_limit: "{{ openshift_logging_es_ops_cpu_limit }}"
  103. es_memory_limit: "{{ openshift_logging_es_ops_memory_limit }}"
  104. with_sequence: count={{ openshift_logging_es_ops_cluster_size | int - openshift_logging_facts.elasticsearch_ops.deploymentconfigs | count }}
  105. when:
  106. - openshift_logging_use_ops | bool