--- - hosts: mpdb vars: share: - 'MUSIC' - 'MOVIES' localpath: '/mnt/' remotepath: '/pool/' hostname: "home.thrace-lan.info" username: "sshfs" sshfsport: 22000 tasks: - name: sshfs ansible.builtin.group: name: sshfs state: present - name: sshfs ansible.builtin.user: name: sshfs state: present group: sshfs - name: make ssh home directory file: path: "/home/sshfs/.ssh/" state: directory owner: sshfs group: sshfs mode: '0700' - name: copy private key copy: src: "./sshfs-key" dest: "/root/.ssh/" owner: root group: root mode: '0700' - name: copy ssh config copy: src: "./ssh-config" dest: "/root/.ssh/config" owner: root group: root mode: '0700' - name: "sshfs mount {{ item }}" file: path: "{{ localpath}}{{ item }}/" state: directory owner: root group: root mode: '0777' loop: "{{ share }}" - name: "mount {{ item}}" ansible.builtin.shell: "/usr/bin/sshfs -v -o reconnect,allow_root,allow_other,default_permissions {{ [username,'@',hostname,':',remotepath,item,'/',' ',localpath,item,'/' ]|join() }}" loop: "{{ share }}"