glusterfs.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ---
  2. - name: Install GlusterFS storage plugin dependencies
  3. package:
  4. name: glusterfs-fuse
  5. state: present
  6. register: result
  7. until: result is succeeded
  8. - name: Check for existence of fusefs sebooleans
  9. command: getsebool {{ item }}
  10. register: fusefs_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_fusefs
  18. - virt_sandbox_use_fusefs
  19. - name: Set seboolean to allow gluster 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: "{{ fusefs_getsebool_status.results }}"
  35. # Workaround for https://github.com/openshift/openshift-ansible/issues/4438
  36. # Use command module rather than seboolean module to set GlusterFS 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 gluster storage plugin access from containers (python 3)
  41. command: >
  42. setsebool -P {{ item.item }} on
  43. when:
  44. - ansible_selinux
  45. - ansible_selinux.status == "enabled"
  46. - item.rc == 0
  47. # We need to detect whether or not the boolean is an alias, since `seboolean`
  48. # will error if it is an alias. We do this by inspecting stdout for the boolean name,
  49. # since getsebool prints the resolved name. (At some point Ansible's seboolean module
  50. # should learn to deal with aliases)
  51. - item.item in item.stdout # Boolean does not have an alias.
  52. - ('--> off' in item.stdout) # Boolean is currently off.
  53. - ansible_python_version is version('3', '>=')
  54. with_items: "{{ fusefs_getsebool_status.results }}"