nfs-client/tasks/config.yaml
2026-04-07 16:43:41 +02:00

41 lines
1.5 KiB
YAML

---
# transform __nfs_mount['local_dir_path']
- name: "set variables"
ansible.builtin.set_fact:
__systemctl_unit_name: "{{ __nfs_mount['local_dir_path'][1:] | replace('-', '\\x2d') | replace('/', '-') }}"
# create local data folder
- name: "directory - create folder {{ __nfs_mount['local_dir_path'] }}"
ansible.builtin.file:
path: "{{ __nfs_mount['local_dir_path'] }}"
state: "directory"
owner: "{{ __nfs_mount['local_dir_owner'] | default('root') }}"
group: "{{ __nfs_mount['local_dir_group'] | default('root') }}"
mode: "{{ __nfs_mount['local_dir_mode'] | default('0775') }}"
# set systemd mount file
- name: "systemd - config - {{ __systemctl_unit_name }}.mount"
ansible.builtin.template:
src: "templates/systemd/mount.j2"
dest: "/etc/systemd/system/{{ __systemctl_unit_name }}.mount"
owner: "root"
group: "root"
mode: "0644"
# start service one time
- name: "systemd - service - start"
ansible.builtin.systemd:
name: "{{ __systemctl_unit_name }}.mount"
daemon_reload: true
state: "started"
enabled: true
# fix permissions local folder
- name: "directory - fix folder permissions {{ __nfs_mount['local_dir_path'] }}"
ansible.builtin.file:
path: "{{ __nfs_mount['local_dir_path'] }}"
state: "directory"
owner: "{{ __nfs_mount['local_dir_owner'] | default('root') }}"
group: "{{ __nfs_mount['local_dir_group'] | default('root') }}"
mode: "{{ __nfs_mount['local_dir_mode'] | default('0775') }}"