Ansible repo for digital ocean projects
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

sshfs.yaml 1.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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: "mount {{ item}}"
  58. ansible.builtin.command: /usr/bin/sshfs "{{ [username,'@',hostname,':',remotepath,item,'/',' ',localpath,item,'/' ]|join() }} -o IdentityFile=/home/sshfs/.ssh/sshfs-key,allow_other,reconnect"
  59. loop: "{{ share }}"
  60. handlers:
  61. - name: SSHFS
  62. ansible.builtin.command: "mount {{ [ localpath,item,'/' ]|join() }}"
  63. loop: "{{ share }}"