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
Some checks failed
Nix Format Check / check-format (push) Failing after 38s
This commit is contained in:
parent
a3b735f373
commit
cb4206c3b7
@ -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
|
|
@ -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
|
||||||
|
52
config/ansible/tasks/servers/sshfs.yml
Normal file
52
config/ansible/tasks/servers/sshfs.yml
Normal 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
|
Loading…
x
Reference in New Issue
Block a user