install_elasticsearch.yaml 5.6 KB

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