feat: add CIFS utilities installation and configuration tasks
Some checks failed
Nix Format Check / check-format (push) Failing after 39s
Some checks failed
Nix Format Check / check-format (push) Failing after 39s
This commit is contained in:
parent
fd6b5ee127
commit
bb944b21a9
49
config/ansible/tasks/servers/cifs.yml
Normal file
49
config/ansible/tasks/servers/cifs.yml
Normal file
@ -0,0 +1,49 @@
|
||||
---
|
||||
- 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={{ storage_box_password | default('CHANGE_ME') }}
|
||||
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
|
||||
- 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
|
@ -5,59 +5,10 @@
|
||||
state: present
|
||||
become: true
|
||||
|
||||
- name: Check if /mnt/services is a mount point
|
||||
ansible.builtin.shell: mountpoint -q /mnt/services || echo "not_mounted"
|
||||
register: mnt_services_check
|
||||
changed_when: false
|
||||
ignore_errors: true
|
||||
become: true
|
||||
- name: Include cifs tasks
|
||||
ansible.builtin.include_tasks: cifs.yml
|
||||
when: ansible_hostname == "mennos-cloud-server"
|
||||
|
||||
- name: Check if services git repo already exists
|
||||
ansible.builtin.stat:
|
||||
path: "/mnt/services/.git"
|
||||
register: git_dir_check
|
||||
become: true
|
||||
when: mnt_services_check.rc == 0
|
||||
|
||||
- name: Check if /mnt/services directory exists
|
||||
ansible.builtin.stat:
|
||||
path: "/mnt/services"
|
||||
register: mnt_services_dir
|
||||
changed_when: false
|
||||
become: true
|
||||
|
||||
- name: Clean /mnt/services directory
|
||||
ansible.builtin.shell: find /mnt/services -mindepth 1 -maxdepth 1 -exec rm -rf {} \;
|
||||
become: true
|
||||
when: mnt_services_check.rc == 0 and not git_dir_check.stat.exists|default(false) and mnt_services_dir.stat.exists
|
||||
|
||||
- name: Clone /mnt/services repository (initial clone)
|
||||
ansible.builtin.git:
|
||||
repo: "https://git.mvl.sh/vleeuwenmenno/services.git"
|
||||
dest: "/mnt/services"
|
||||
version: "main"
|
||||
become: true
|
||||
register: git_result
|
||||
changed_when: git_result.changed
|
||||
when: mnt_services_check.rc == 0 and not git_dir_check.stat.exists|default(false)
|
||||
|
||||
- name: Update /mnt/services repository (if already exists)
|
||||
ansible.builtin.git:
|
||||
repo: "https://git.mvl.sh/vleeuwenmenno/services.git"
|
||||
dest: "/mnt/services"
|
||||
update: true
|
||||
version: "main"
|
||||
force: true
|
||||
become: true
|
||||
register: git_result
|
||||
changed_when: git_result.changed
|
||||
when: mnt_services_check.rc == 0 and git_dir_check.stat.exists|default(false)
|
||||
|
||||
- name: Ensure /mnt/services ownership to users
|
||||
ansible.builtin.file:
|
||||
path: "/mnt/services"
|
||||
group: "users"
|
||||
recurse: true
|
||||
state: directory
|
||||
become: true
|
||||
when: mnt_services_check.rc == 0
|
||||
- name: Include services-repo tasks
|
||||
ansible.builtin.include_tasks: services-repo.yml
|
||||
when: ansible_hostname == "mennos-cloud-server"
|
||||
|
58
config/ansible/tasks/servers/services-repo.yml
Normal file
58
config/ansible/tasks/servers/services-repo.yml
Normal file
@ -0,0 +1,58 @@
|
||||
|
||||
|
||||
- name: Check if /mnt/storage-box/services is a mount point
|
||||
ansible.builtin.shell: mountpoint -q /mnt/storage-box/services || echo "not_mounted"
|
||||
register: mnt_services_check
|
||||
changed_when: false
|
||||
ignore_errors: true
|
||||
become: true
|
||||
|
||||
- name: Check if services git repo already exists
|
||||
ansible.builtin.stat:
|
||||
path: "/mnt/storage-box/services/.git"
|
||||
register: git_dir_check
|
||||
become: true
|
||||
when: mnt_services_check.rc == 0
|
||||
|
||||
- name: Check if /mnt/storage-box/services directory exists
|
||||
ansible.builtin.stat:
|
||||
path: "/mnt/storage-box/services"
|
||||
register: mnt_services_dir
|
||||
changed_when: false
|
||||
become: true
|
||||
|
||||
- name: Clean /mnt/storage-box/services directory
|
||||
ansible.builtin.shell: find /mnt/storage-box/services -mindepth 1 -maxdepth 1 -exec rm -rf {} \;
|
||||
become: true
|
||||
when: mnt_services_check.rc == 0 and not git_dir_check.stat.exists|default(false) and mnt_services_dir.stat.exists
|
||||
|
||||
- name: Clone /mnt/storage-box/services repository (initial clone)
|
||||
ansible.builtin.git:
|
||||
repo: "https://git.mvl.sh/vleeuwenmenno/services.git"
|
||||
dest: "/mnt/storage-box/services"
|
||||
version: "main"
|
||||
become: true
|
||||
register: git_result
|
||||
changed_when: git_result.changed
|
||||
when: mnt_services_check.rc == 0 and not git_dir_check.stat.exists|default(false)
|
||||
|
||||
- name: Update /mnt/storage-box/services repository (if already exists)
|
||||
ansible.builtin.git:
|
||||
repo: "https://git.mvl.sh/vleeuwenmenno/services.git"
|
||||
dest: "/mnt/storage-box/services"
|
||||
update: true
|
||||
version: "main"
|
||||
force: true
|
||||
become: true
|
||||
register: git_result
|
||||
changed_when: git_result.changed
|
||||
when: mnt_services_check.rc == 0 and git_dir_check.stat.exists|default(false)
|
||||
|
||||
- name: Ensure /mnt/storage-box/services ownership to users
|
||||
ansible.builtin.file:
|
||||
path: "/mnt/storage-box/services"
|
||||
group: "users"
|
||||
recurse: true
|
||||
state: directory
|
||||
become: true
|
||||
when: mnt_services_check.rc == 0
|
Loading…
x
Reference in New Issue
Block a user