install_efs.yaml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ---
  2. - name: Check efs current replica count
  3. command: >
  4. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig get dc provisioners-efs
  5. -o jsonpath='{.spec.replicas}' -n {{openshift_provisioners_project}}
  6. register: efs_replica_count
  7. when: not ansible_check_mode
  8. ignore_errors: yes
  9. changed_when: no
  10. - name: Generate efs PersistentVolumeClaim
  11. template:
  12. src: pvc.j2
  13. dest: "{{ mktemp.stdout }}/templates/{{ obj_name }}-pvc.yaml"
  14. vars:
  15. obj_name: "provisioners-efs"
  16. size: "1Mi"
  17. access_modes:
  18. - "ReadWriteMany"
  19. pv_selector:
  20. provisioners-efs: efs
  21. check_mode: no
  22. changed_when: no
  23. - name: Generate efs PersistentVolume
  24. template:
  25. src: pv.j2
  26. dest: "{{ mktemp.stdout }}/templates/{{ obj_name }}-pv.yaml"
  27. vars:
  28. obj_name: "provisioners-efs"
  29. size: "1Mi"
  30. access_modes:
  31. - "ReadWriteMany"
  32. labels:
  33. provisioners-efs: efs
  34. volume_plugin: "nfs"
  35. volume_source:
  36. - {key: "server", value: "{{openshift_provisioners_efs_fsid}}.efs.{{openshift_provisioners_efs_region}}.amazonaws.com"}
  37. - {key: "path", value: "{{openshift_provisioners_efs_path}}"}
  38. claim_name: "provisioners-efs"
  39. check_mode: no
  40. changed_when: no
  41. - name: Generate efs DeploymentConfig
  42. template:
  43. src: efs.j2
  44. dest: "{{ mktemp.stdout }}/templates/{{deploy_name}}-dc.yaml"
  45. vars:
  46. name: efs
  47. deploy_name: "provisioners-efs"
  48. deploy_serviceAccount: "provisioners-efs"
  49. replica_count: "{{efs_replica_count.stdout | default(0)}}"
  50. node_selector: "{{openshift_provisioners_efs_nodeselector | default('') }}"
  51. claim_name: "provisioners-efs"
  52. check_mode: no
  53. changed_when: false
  54. # anyuid in order to run as root & chgrp shares with allocated gids
  55. - name: "Check efs anyuid permissions"
  56. command: >
  57. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig
  58. get scc/anyuid -o jsonpath='{.users}'
  59. register: efs_anyuid
  60. check_mode: no
  61. changed_when: no
  62. - name: "Set anyuid permissions for efs"
  63. command: >
  64. {{ openshift.common.admin_binary}} --config={{ mktemp.stdout }}/admin.kubeconfig policy
  65. add-scc-to-user anyuid system:serviceaccount:{{openshift_provisioners_project}}:provisioners-efs
  66. register: efs_output
  67. failed_when: efs_output.rc == 1 and 'exists' not in efs_output.stderr
  68. check_mode: no
  69. when: efs_anyuid.stdout.find("system:serviceaccount:" + openshift_provisioners_project + ":provisioners-efs") == -1