Some checks failed
Nix Format Check / check-format (push) Failing after 38s
53 lines
2.1 KiB
YAML
53 lines
2.1 KiB
YAML
---
|
|
- name: Configure SSHFS
|
|
block:
|
|
- name: Install SSHFS package
|
|
become: true
|
|
ansible.builtin.package:
|
|
name: sshfs
|
|
state: present
|
|
|
|
- name: Create mount point directory
|
|
become: true
|
|
ansible.builtin.file:
|
|
path: /mnt/storage-box
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: Create credentials file
|
|
become: true
|
|
ansible.builtin.copy:
|
|
dest: /root/.smbcredentials
|
|
content: |
|
|
username=u451316
|
|
password={{ lookup('onepassword', 'op://j7nmhqlsjmp2r6umly5t75hzb4/5j5y5axfjr3f3sn5nixb6htg4y/new_password') }}
|
|
mode: '0600'
|
|
|
|
- name: Create password file for SSHFS
|
|
become: true
|
|
ansible.builtin.copy:
|
|
dest: /root/.sshfs_password
|
|
content: "{{ lookup('onepassword', 'op://j7nmhqlsjmp2r6umly5t75hzb4/5j5y5axfjr3f3sn5nixb6htg4y/new_password') }}"
|
|
mode: '0600'
|
|
|
|
- name: Add fstab entry for SSHFS mount
|
|
become: true
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/fstab
|
|
line: "sshfs#{{ lookup('onepassword', 'op://j7nmhqlsjmp2r6umly5t75hzb4/5j5y5axfjr3f3sn5nixb6htg4y/username') }}@{{ lookup('onepassword', 'op://j7nmhqlsjmp2r6umly5t75hzb4/5j5y5axfjr3f3sn5nixb6htg4y/host') }}: /mnt/storage-box fuse.sshfs defaults,_netdev,port=23,password_stdin,password_file=/root/.sshfs_password,uid=1000,gid=100,reconnect,allow_other,ServerAliveInterval=15 0 0"
|
|
regexp: "^sshfs#.*{{ lookup('onepassword', 'op://j7nmhqlsjmp2r6umly5t75hzb4/5j5y5axfjr3f3sn5nixb6htg4y/host') }}:"
|
|
state: present
|
|
notify: Systemctl daemon-reload
|
|
|
|
- name: Mount SSHFS storage
|
|
become: true
|
|
ansible.builtin.mount:
|
|
path: /mnt/storage-box
|
|
src: "sshfs#{{ lookup('onepassword', 'op://j7nmhqlsjmp2r6umly5t75hzb4/5j5y5axfjr3f3sn5nixb6htg4y/username') }}@{{ lookup('onepassword', 'op://j7nmhqlsjmp2r6umly5t75hzb4/5j5y5axfjr3f3sn5nixb6htg4y/host') }}:"
|
|
fstype: fuse.sshfs
|
|
opts: "defaults,_netdev,port=23,password_stdin,password_file=/root/.sshfs_password,uid=1000,gid=100,reconnect,allow_other,ServerAliveInterval=15"
|
|
state: mounted
|
|
|
|
- name: Handlers
|
|
ansible.builtin.meta: flush_handlers
|