xoxys.smb/tasks/main.yml
Robert Kaussow 76d86bcf9b
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/notify Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/docs Pipeline was successful
ci: migrate to woodpecker
2024-02-19 10:37:58 +01:00

36 lines
1.1 KiB
YAML

---
- name: Install requirements
ansible.builtin.package:
name: "{{ item }}"
state: present
loop: "{{ smb_packages }}"
- name: Ensure credentials folder exist
ansible.builtin.file:
path: /root/.smbcredentials
owner: root
group: root
mode: "0600"
state: directory
- name: Create secrets file
ansible.builtin.template:
src: "smbcredentials.j2"
dest: "/root/.smbcredentials/{{ item.name }}"
mode: "0600"
loop: "{{ smb_shares }}"
loop_control:
label: "/root/.smbcredentials/{{ item.name }}"
when: item.password is defined and item.password
- name: Mount volume
ansible.posix.mount:
path: "{{ item.mountpoint }}"
src: "{{ item.source }}"
fstype: "cifs"
opts: "{{ ((item.mountopts | default([])) if not (item.password is defined and item.password) else ((item.mountopts | default([])) + ['credentials=/root/.smbcredentials/' + item.name])) | join(',') }}"
state: "{{ item.state | default('mounted') }}"
loop: "{{ smb_shares }}"
loop_control:
label: "mount: {{ item.source }} {{ item.mountpoint }} cifs {% if item.mountopts is defined %}{{ item.mountopts | join(',') }}{% endif %}"