nfs.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ---
  2. - name: Install NFS storage plugin dependencies
  3. package:
  4. name: nfs-utils
  5. state: present
  6. register: result
  7. until: result is succeeded
  8. - name: Check for existence of nfs sebooleans
  9. command: getsebool {{ item }}
  10. register: nfs_getsebool_status
  11. when:
  12. - ansible_selinux
  13. - ansible_selinux.status == "enabled"
  14. failed_when: false
  15. changed_when: false
  16. with_items:
  17. - virt_use_nfs
  18. - virt_sandbox_use_nfs
  19. - name: Set seboolean to allow nfs storage plugin access from containers
  20. seboolean:
  21. name: "{{ item.item }}"
  22. state: yes
  23. persistent: yes
  24. when:
  25. - ansible_selinux
  26. - ansible_selinux.status == "enabled"
  27. - item.rc == 0
  28. # We need to detect whether or not the boolean is an alias, since `seboolean`
  29. # will error if it is an alias. We do this by inspecting stdout for the boolean name,
  30. # since getsebool prints the resolved name. (At some point Ansible's seboolean module
  31. # should learn to deal with aliases)
  32. - item.item in item.stdout # Boolean does not have an alias.
  33. - ansible_python_version is version('3', '<')
  34. with_items: "{{ nfs_getsebool_status.results }}"
  35. # Workaround for https://github.com/openshift/openshift-ansible/issues/4438
  36. # Use command module rather than seboolean module to set NFS booleans.
  37. # TODO: Remove this task and the ansible_python_version comparison in
  38. # the previous task when the problem has been addressed in current
  39. # ansible release.
  40. - name: Set seboolean to allow nfs storage plugin access from containers (python 3)
  41. command: setsebool -P {{ item.item }} on
  42. when:
  43. - ansible_selinux
  44. - ansible_selinux.status == "enabled"
  45. - item.rc == 0
  46. # We need to detect whether or not the boolean is an alias, since `seboolean`
  47. # will error if it is an alias. We do this by inspecting stdout for the boolean name,
  48. # since getsebool prints the resolved name. (At some point Ansible's seboolean module
  49. # should learn to deal with aliases)
  50. - item.item in item.stdout # Boolean does not have an alias.
  51. - ('--> off' in item.stdout) # Boolean is currently off.
  52. - ansible_python_version is version('3', '>=')
  53. with_items: "{{ nfs_getsebool_status.results }}"