main.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ---
  2. - name: Create temp directory for volume definitions
  3. command: mktemp -d /tmp/openshift-ansible-XXXXXXX
  4. register: mktemp
  5. changed_when: False
  6. - name: Copy the admin client config(s)
  7. command: >
  8. cp {{ openshift_master_config_dir }}/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
  9. changed_when: False
  10. - name: Deploy PersistentVolume definitions
  11. template:
  12. dest: "{{ mktemp.stdout }}/persistent-volumes.yml"
  13. src: persistent-volume.yml.j2
  14. when: persistent_volumes | length > 0
  15. changed_when: False
  16. - name: Create PersistentVolumes
  17. command: >
  18. {{ openshift.common.client_binary }} create
  19. -f {{ mktemp.stdout }}/persistent-volumes.yml
  20. --config={{ mktemp.stdout }}/admin.kubeconfig
  21. register: pv_create_output
  22. when: persistent_volumes | length > 0
  23. failed_when: ('already exists' not in pv_create_output.stderr) and ('created' not in pv_create_output.stdout)
  24. changed_when: ('created' in pv_create_output.stdout)
  25. - name: Deploy PersistentVolumeClaim definitions
  26. template:
  27. dest: "{{ mktemp.stdout }}/persistent-volume-claims.yml"
  28. src: persistent-volume-claim.yml.j2
  29. when: persistent_volume_claims | length > 0
  30. changed_when: False
  31. - name: Create PersistentVolumeClaims
  32. command: >
  33. {{ openshift.common.client_binary }} create
  34. -f {{ mktemp.stdout }}/persistent-volume-claims.yml
  35. --config={{ mktemp.stdout }}/admin.kubeconfig
  36. register: pvc_create_output
  37. when: persistent_volume_claims | length > 0
  38. failed_when: ('already exists' not in pvc_create_output.stderr) and ('created' not in pvc_create_output.stdout)
  39. changed_when: ('created' in pvc_create_output.stdout)
  40. - name: Delete temp directory
  41. file:
  42. name: "{{ mktemp.stdout }}"
  43. state: absent
  44. changed_when: False