generate_pvcs.yaml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ---
  2. - name: Init pool of PersistentVolumeClaim names
  3. set_fact: es_pvc_pool={{es_pvc_pool|default([]) + [pvc_name]}}
  4. vars:
  5. pvc_name: "{{es_pvc_prefix}}-{{item| int}}"
  6. start: "{{es_pvc_names | map('regex_search', es_pvc_prefix+'.*')|select('string')|list|length}}"
  7. with_sequence: start={{start}} end={{ (start|int > es_cluster_size|int - 1) | ternary(start, es_cluster_size|int - 1)}}
  8. when:
  9. - "{{ es_dc_names|default([]) | length <= es_cluster_size|int }}"
  10. - es_pvc_size | search('^\d.*')
  11. check_mode: no
  12. - name: Generating PersistentVolumeClaims
  13. template: src=pvc.j2 dest={{mktemp.stdout}}/templates/logging-{{obj_name}}-pvc.yaml
  14. vars:
  15. obj_name: "{{claim_name}}"
  16. size: "{{es_pvc_size}}"
  17. access_modes: "{{ es_access_modes | list }}"
  18. pv_selector: "{{es_pv_selector}}"
  19. with_items:
  20. - "{{es_pvc_pool | default([])}}"
  21. loop_control:
  22. loop_var: claim_name
  23. when:
  24. - not es_pvc_dynamic
  25. - es_pvc_pool is defined
  26. check_mode: no
  27. changed_when: no
  28. - name: Generating PersistentVolumeClaims - Dynamic
  29. template: src=pvc.j2 dest={{mktemp.stdout}}/templates/logging-{{obj_name}}-pvc.yaml
  30. vars:
  31. obj_name: "{{claim_name}}"
  32. annotations:
  33. volume.alpha.kubernetes.io/storage-class: "dynamic"
  34. size: "{{es_pvc_size}}"
  35. access_modes: "{{ es_access_modes | list }}"
  36. pv_selector: "{{es_pv_selector}}"
  37. with_items:
  38. - "{{es_pvc_pool|default([])}}"
  39. loop_control:
  40. loop_var: claim_name
  41. when:
  42. - es_pvc_dynamic
  43. - es_pvc_pool is defined
  44. check_mode: no
  45. changed_when: no