set_es_storage.yaml 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ---
  2. - set_fact: es_storage_type="{{ es_spec.volumes['elasticsearch-storage'] }}"
  3. when: es_spec.volumes is defined
  4. - set_fact: es_storage_claim="{{ es_spec.volumes['elasticsearch-storage'].persistentVolumeClaim.claimName }}"
  5. when:
  6. - es_spec.volumes is defined
  7. - es_storage_type.persistentVolumeClaim is defined
  8. - set_fact: es_storage_claim=""
  9. when:
  10. - not es_spec.volumes is defined or not es_storage_type.persistentVolumeClaim is defined
  11. ## take an ES dc and evaluate its storage option
  12. # if it is a hostmount or emptydir we don't do anything with it
  13. # if its a pvc we see if the corresponding pvc matches the provided specs (if they exist)
  14. - oc_obj:
  15. state: list
  16. kind: pvc
  17. name: "{{ es_storage_claim }}"
  18. namespace: "{{ openshift_logging_namespace }}"
  19. register: pvc_spec
  20. failed_when: pvc_spec.results.stderr is defined
  21. when:
  22. - es_spec.volumes is defined
  23. - es_storage_type.persistentVolumeClaim is defined
  24. - set_fact: pvc_size="{{ pvc_spec.results.results[0].spec.resources.requests.storage }}"
  25. when:
  26. - pvc_spec.results is defined
  27. - pvc_spec.results.results[0].spec is defined
  28. # if not create the pvc and use it
  29. - block:
  30. - name: Generating PersistentVolumeClaims
  31. template: src=pvc.j2 dest={{mktemp.stdout}}/templates/logging-{{obj_name}}-pvc.yaml
  32. vars:
  33. obj_name: "{{ es_pvc_prefix }}-{{ es_pvc_names_count | int + es_pvc_count | int }}"
  34. size: "{{ es_pvc_size }}"
  35. access_modes: "{{ openshift_logging_storage_access_modes }}"
  36. pv_selector: "{{ es_pv_selector }}"
  37. when: not es_pvc_dynamic | bool
  38. check_mode: no
  39. changed_when: no
  40. - name: Generating PersistentVolumeClaims - Dynamic
  41. template: src=pvc.j2 dest={{mktemp.stdout}}/templates/logging-{{obj_name}}-pvc.yaml
  42. vars:
  43. obj_name: "{{ es_pvc_prefix }}-{{ es_pvc_names_count | int + es_pvc_count | int }}"
  44. annotations:
  45. volume.alpha.kubernetes.io/storage-class: "dynamic"
  46. size: "{{ es_pvc_size }}"
  47. access_modes: "{{ openshift_logging_storage_access_modes }}"
  48. pv_selector: "{{ es_pv_selector }}"
  49. when: es_pvc_dynamic | bool
  50. check_mode: no
  51. changed_when: no
  52. - set_fact: es_storage_claim="{{ es_pvc_prefix }}-{{ es_pvc_names_count | int + es_pvc_count | int }}"
  53. when:
  54. - es_pvc_size | search('^\d.*')
  55. - not es_spec.volumes is defined or not es_storage_claim | search( es_pvc_prefix ) or ( not pvc_size | search( es_pvc_size ) and not es_pvc_size | search( pvc_size ) )
  56. - name: Generate Elasticsearch DeploymentConfig
  57. template: src=es.j2 dest={{mktemp.stdout}}/templates/logging-{{deploy_name}}-dc.yaml
  58. vars:
  59. component: "{{ es_component }}"
  60. deploy_name: "{{ es_name }}"
  61. logging_component: elasticsearch
  62. deploy_name_prefix: "logging-{{ es_component }}"
  63. image: "{{openshift_logging_image_prefix}}logging-elasticsearch:{{openshift_logging_image_version}}"
  64. es_cluster_name: "{{component}}"
  65. es_cpu_limit: "{{ es_cpu_limit }}"
  66. es_memory_limit: "{{ es_memory_limit }}"
  67. es_node_selector: "{{ es_node_selector }}"
  68. es_storage: "{{ openshift_logging_facts | es_storage( es_name, es_storage_claim ) }}"
  69. check_mode: no
  70. changed_when: no