nfs_server.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ---
  2. - name: Share a directory with NFS
  3. hosts: serverd.lab.example.com
  4. become: true
  5. vars:
  6. shared_dir: /srv/operators
  7. tasks:
  8. - name: the package for NFS server is installed
  9. yum:
  10. name: nfs-utils
  11. state: present
  12. - name: the directory exists
  13. file:
  14. name: "{{ shared_dir }}"
  15. owner: root
  16. group: operators
  17. mode: 2770
  18. state: directory
  19. #FIXME: create the {{ shared_dir }} directory as follows:
  20. # Directory ownership: root
  21. # Directory group ownership: operators
  22. # Group access: read/write
  23. # Other users access: none
  24. # All contents created in the directory must automatically
  25. # belong to the operators group.
  26. - name: the directory is shared
  27. copy:
  28. content: "{{ shared_dir }} servera.lab.example.com(rw)\n"
  29. dest: /etc/exports.d/operators.exports
  30. owner: root
  31. group: root
  32. mode: 0644
  33. #FIXME: declare the {{ shared_dir }} directory as an NFS share.
  34. # Only servera.lab.example.com must be able to access the share.
  35. # servera has read/write access to the share.
  36. # The root user on servera must have no access to the share.
  37. notify: reload exports
  38. - name: NFS is started and enabled
  39. service:
  40. name: nfs-server
  41. state: started
  42. enabled: yes
  43. #FIXME: the service must be started and enabled
  44. - name: the firewall is opened for NFS
  45. firewalld:
  46. service: nfs
  47. state: enabled
  48. permanent: yes
  49. immediate: yes
  50. #FIXME: configure the firewall to allow NFS traffic
  51. handlers:
  52. - name: reload exports
  53. #FIXME: reload the NFS service