52 lines
1.5 KiB
YAML
52 lines
1.5 KiB
YAML
|
|
#
|
|
# tasks for mounts
|
|
# systemd uses - for dir separator, so dirs with dashes need escaped according to systemd-escape rules
|
|
#
|
|
|
|
- name: SYSTEMD MOUNT | Install needed packages
|
|
package:
|
|
name: "{{ item }}"
|
|
state: installed
|
|
with_items: "{{ systemd_mount_packages }}"
|
|
become: yes
|
|
|
|
- name: stat mount directory
|
|
stat:
|
|
path: "{{item.value.mount}}"
|
|
with_dict: "{{ systemd_mounts }}"
|
|
register: test_folder
|
|
|
|
- name: create mount directory if doesn't exist
|
|
file:
|
|
path: "{{item.item}}"
|
|
state: directory
|
|
when: item.stat.exists == false
|
|
with_items: "{{test_folder.results}}"
|
|
become: yes
|
|
|
|
- name: SYSTEMD MOUNT | Setup systemd Service for mountpoints
|
|
template:
|
|
src: systemd.mount.j2
|
|
dest: "/etc/systemd/system/{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', '-') }}.mount"
|
|
with_dict: "{{ systemd_mounts }}"
|
|
notify:
|
|
- Reload systemd
|
|
- Enable systemd mount
|
|
become: yes
|
|
when: item.key in systemd_mounts_enabled
|
|
|
|
- name: SYSTEMD MOUNT | Setup systemd Service for automount
|
|
template:
|
|
src: systemd.automount.j2
|
|
dest: "/etc/systemd/system/{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', '-') }}.automount"
|
|
with_dict: "{{ systemd_mounts }}"
|
|
notify:
|
|
- Reload systemd
|
|
- Enable systemd automount
|
|
- Start systemd automount
|
|
become: yes
|
|
when: item.value.automount is defined and item.value.automount == true and item.key in systemd_mounts_enabled
|
|
|
|
- name: execute handler
|
|
meta: flush_handlers |