Ansible repo for digital ocean projects
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ---
  2. - hosts: mpdb
  3. vars:
  4. share:
  5. - 'MUSIC'
  6. - 'MOVIES'
  7. localpath: '/mnt/'
  8. remotepath: '/pool/'
  9. hostname: "home.thrace-lan.info"
  10. username: "sshfs"
  11. sshfsport: 22000
  12. tasks:
  13. - name: sshfs
  14. ansible.builtin.group:
  15. name: sshfs
  16. state: present
  17. - name: sshfs
  18. ansible.builtin.user:
  19. name: sshfs
  20. state: present
  21. group: sshfs
  22. - name: make ssh home directory
  23. file:
  24. path: "/home/sshfs/.ssh/"
  25. state: directory
  26. owner: sshfs
  27. group: sshfs
  28. mode: '0700'
  29. - name: copy private key
  30. copy:
  31. src: "./sshfs-key"
  32. dest: "/home/sshfs/.ssh/"
  33. owner: sshfs
  34. group: sshfs
  35. mode: '0700'
  36. notify:
  37. - SSHFS
  38. - name: copy ssh config
  39. copy:
  40. src: "./ssh-config"
  41. dest: "/home/sshfs/.ssh/config"
  42. owner: sshfs
  43. group: sshfs
  44. mode: '0700'
  45. notify:
  46. - SSHFS
  47. - name: "sshfs mount {{ item }}"
  48. file:
  49. path: "{{ localpath}}{{ item }}/"
  50. state: directory
  51. owner: root
  52. group: root
  53. mode: '0777'
  54. loop: "{{ share }}"
  55. notify:
  56. - SSHFS
  57. - name: Ensure fstab has sshfs
  58. ansible.builtin.lineinfile:
  59. path: /etc/fstab
  60. regexp: '^sshfs'
  61. line: "{{ [username,'@',hostname,':',remotepath,item,'/',' ',localpath,item,'/' ]|join() }} fuse.sshfs noauto,x-systemd.automount,_netdev,users,idmap=user,IdentityFile=/home/sshfs/.ssh/sshfs-key,allow_other,reconnect 0 0"
  62. loop: "{{ share }}"
  63. handlers:
  64. - name: SSHFS
  65. ansible.builtin.command: "mount {{ [ localpath,item,'/' ]|join() }}"
  66. loop: "{{ share }}"