main.yml 742 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. - name: Create mountable dir
  2. file:
  3. path: /nfs
  4. state: directory
  5. mode: u=rwx,g=r,o=r
  6. owner: '{{ user }}'
  7. group: '{{ user }}'
  8. - name: Ensure NFS utilities are installed.
  9. apt:
  10. name: '{{ packages }}'
  11. state: present
  12. update_cache: yes
  13. vars:
  14. packages:
  15. - nfs-common
  16. - nfs-kernel-server
  17. - name: Format the data drive
  18. filesystem:
  19. fstype: ext4
  20. dev: /dev/sdb1
  21. - name: Mount the data drive
  22. mount:
  23. src: /dev/sdb1
  24. path: /nfs
  25. fstype: ext4
  26. state: mounted
  27. - name: copy /etc/exports
  28. template:
  29. src: templates/nas/etc/exports.j2
  30. dest: /etc/exports
  31. owner: root
  32. group: root
  33. - name: restart nfs server
  34. service:
  35. name: nfs-kernel-server
  36. state: restarted