install_efs.yaml 2.4 KB

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