nfs_server.yml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ---
  2. - name: Share a directory with NFS
  3. hosts: serverc.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: #FIXME: install the required package for an NFS server
  11. state: present
  12. - name: the directory exists
  13. file:
  14. path: "{{ shared_dir }}"
  15. owner: root
  16. group: operators
  17. mode: '2770'
  18. state: directory
  19. - name: the directory is shared
  20. copy:
  21. #FIXME: declare the {{ shared_dir }} directory as an NFS share.
  22. # Only servera.lab.example.com must be able to access the share.
  23. # servera has read/write access to the share.
  24. # The root user on servera must have no access to the share.
  25. content: "{{ shared_dir }} #FIXME#(#FIXME#)\n"
  26. dest: /etc/exports.d/share.exports
  27. owner: root
  28. group: root
  29. mode: '0644'
  30. notify: reload exports
  31. - name: NFS is started and enabled
  32. service:
  33. name: #FIXME: the NFS server service must be started and enabled
  34. state: started
  35. enabled: yes
  36. - name: the firewall is opened for NFS
  37. firewalld:
  38. service: #FIXME: configure the firewall to allow NFS traffic
  39. state: enabled
  40. immediate: yes
  41. permanent: yes
  42. handlers:
  43. - name: reload exports
  44. service:
  45. name: #FIXME: the NFS server service must be reloaded
  46. state: reloaded