autofs/tasks/main.yml

52 lines
1.5 KiB
YAML
Raw Normal View History

2019-01-12 18:12:55 +00:00
#
# 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
2019-01-27 19:17:42 +00:00
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
2019-01-12 18:12:55 +00:00
- 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
2019-01-27 19:17:42 +00:00
become: yes
2019-01-12 18:12:55 +00:00
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
2019-01-27 19:17:42 +00:00
- 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