generate_cassandra_pvcs.yaml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ---
  2. - name: Check to see if PVC already exists in actual namespace
  3. oc_obj:
  4. state: list
  5. kind: pvc
  6. name: "{{ openshift_metrics_cassandra_pvc_prefix }}-{{ metrics_pvc_index }}"
  7. namespace: "{{openshift_metrics_project}}"
  8. register: metrics_pvc
  9. # Migration process for PV to another namespace.
  10. - name: Check if we need to move cassandra PV to another namespace.
  11. include_tasks: migrate_cassandra_pvcs.yaml
  12. # _metrics_pvc.results.results | length > 0 returns a false positive
  13. # so we check for the presence of 'stderr' to determine if the obj exists or not
  14. # the RC for existing and not existing is both 0
  15. # No PVC exist (either new or old namespace), so it's a new installation
  16. - when:
  17. - metrics_pvc.results.stderr is defined and not openshift_metrics_migrate_namespace
  18. block:
  19. - name: generate hawkular-cassandra persistent volume claims
  20. template:
  21. src: pvc.j2
  22. dest: "{{ mktemp.stdout }}/templates/hawkular-cassandra-pvc{{ metrics_pvc_index }}.yaml"
  23. vars:
  24. obj_name: "{{ openshift_metrics_cassandra_pvc_prefix }}-{{ metrics_pvc_index }}"
  25. labels:
  26. metrics-infra: hawkular-cassandra
  27. access_modes: "{{ openshift_metrics_cassandra_pvc_access | list }}"
  28. size: "{{ openshift_metrics_cassandra_pvc_size }}"
  29. pv_selector: "{{ openshift_metrics_cassandra_pv_selector }}"
  30. storage_class_name: "{{ openshift_metrics_cassanda_pvc_storage_class_name | default('', true) }}"
  31. when:
  32. - openshift_metrics_cassandra_storage_type != 'emptydir'
  33. - openshift_metrics_cassandra_storage_type != 'dynamic'
  34. changed_when: false
  35. - name: generate hawkular-cassandra persistent volume claims (dynamic)
  36. template:
  37. src: pvc.j2
  38. dest: "{{ mktemp.stdout }}/templates/hawkular-cassandra-pvc{{ metrics_pvc_index }}.yaml"
  39. vars:
  40. obj_name: "{{ openshift_metrics_cassandra_pvc_prefix }}-{{ metrics_pvc_index }}"
  41. labels:
  42. metrics-infra: hawkular-cassandra
  43. access_modes: "{{ openshift_metrics_cassandra_pvc_access | list }}"
  44. size: "{{ openshift_metrics_cassandra_pvc_size }}"
  45. pv_selector: "{{ openshift_metrics_cassandra_pv_selector }}"
  46. storage_class_name: "{{ openshift_metrics_cassanda_pvc_storage_class_name | default('', true) }}"
  47. when: openshift_metrics_cassandra_storage_type == 'dynamic'
  48. changed_when: false