feat: replace CIFS configuration with SSHFS setup in Ansible tasks for improved flexibility
Some checks failed
Nix Format Check / check-format (push) Failing after 38s

This commit is contained in:
Menno van Leeuwen 2025-03-11 21:30:12 +01:00
parent a3b735f373
commit cb4206c3b7
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
3 changed files with 54 additions and 47 deletions

View File

@ -1,45 +0,0 @@
---
- name: Configure CIFS
block:
- name: Install CIFS utilities
become: true
ansible.builtin.package:
name: cifs-utils
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: Add fstab entry for storage-box
become: true
ansible.builtin.lineinfile:
path: /etc/fstab
line: "//u451316.your-storagebox.de/backup /mnt/storage-box cifs credentials=/root/.smbcredentials,uid=1000,gid=100,iocharset=utf8,vers=3.0 0 0"
regexp: "^//u451316.your-storagebox.de/backup"
state: present
notify: Systemctl daemon-reload
- name: Mount storage-box
become: true
ansible.builtin.mount:
path: /mnt/storage-box
src: //u451316.your-storagebox.de/backup
fstype: cifs
opts: credentials=/root/.smbcredentials,uid=1000,gid=100,iocharset=utf8,vers=3.0
state: mounted
- name: Handlers
ansible.builtin.meta: flush_handlers

View File

@ -7,8 +7,8 @@
state: present state: present
become: true become: true
- name: Include cifs tasks - name: Include SSHFS tasks
ansible.builtin.include_tasks: cifs.yml ansible.builtin.include_tasks: sshfs.yml
when: ansible_hostname == "mennos-cloud-server" when: ansible_hostname == "mennos-cloud-server"
- name: Include services tasks - name: Include services tasks

View File

@ -0,0 +1,52 @@
---
- 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