- ---
- - 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: "/home/sshfs/.ssh/"
- owner: sshfs
- group: sshfs
- mode: '0700'
- notify:
- - name: SSHFS
- - name: copy ssh config
- copy:
- src: "./ssh-config"
- dest: "/home/sshfs/.ssh/config"
- owner: sshfs
- group: sshfs
- mode: '0700'
- notify:
- - name: SSHFS
- - name: "sshfs mount {{ item }}"
- file:
- path: "{{ localpath}}{{ item }}/"
- state: directory
- owner: root
- group: root
- mode: '0777'
- loop: "{{ share }}"
- notify:
- - name: SSHFS
- - name: setup service sshfs
- template:
- src: sshfs.service.j2
- dest: "/usr/lib/systemd/system/sshfs-{{ item }}.service"
- mode: 0644
- owner: root
- group: root
- loop: "{{ share }}"
- notify:
- - name: SSHFS
- - name: "sshfs {{ item }} service start"
- systemd:
- name: "sshfs-{{ item }}"
- state: started
- enabled: yes
- masked: no
- daemon_reload: yes
- loop: "{{ share }}"
- handlers:
- - name: SSHFS
- ansible.builtin.service:
- name: sshfs {{ item }} service start"
- state: restarted
- loop: "{{ share }}"
|