From 9950378ea9edf8cbee9a9631f6f9a9000a5fe88f Mon Sep 17 00:00:00 2001 From: vincent Date: Sun, 27 Jan 2019 20:17:42 +0100 Subject: [PATCH] finish autofs role --- defaults/main.yml | 6 ------ handlers/main.yml | 11 ++++++----- tasks/main.yml | 25 +++++++++++++++++++++++-- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 89ab376..9e5a327 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,12 +1,6 @@ systemd_mounts: {} systemd_mounts_enabled: [] -systemd_mounts_manage_service: {} -systemd_mounts_allow_reload: {} -autofs_mounts_manage_service: {} -autofs_mounts_allow_reload: {} - - systemd_mount_packages: - cifs-utils diff --git a/handlers/main.yml b/handlers/main.yml index 51d5955..fa1021c 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -2,21 +2,21 @@ - name: Reload systemd systemd: daemon_reload: yes - when: systemd_mounts_manage_service + become: yes - name: Start systemd mount systemd: name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.mount" state: started with_dict: "{{ systemd_mounts }}" - when: systemd_mounts_manage_service + become: yes - name: Start systemd automount systemd: name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.automount" state: started with_dict: "{{ systemd_mounts }}" - when: systemd_mounts_manage_service + become: yes - name: Enable systemd mount systemd: @@ -26,12 +26,13 @@ notify: - Start systemd mount when: item.value.automount == false + become: yes - name: Enable systemd automount systemd: name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.automount" enabled: yes with_dict: "{{ systemd_mounts }}" - notify: - - Start systemd automount + when: item.value.automount == true + become: yes \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index d0505a7..17cd669 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,7 +8,22 @@ package: name: "{{ item }}" state: installed - with_items: "{{ systemd_mount_packages }}" + 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: @@ -18,6 +33,7 @@ notify: - Reload systemd - Enable systemd mount + become: yes when: item.key in systemd_mounts_enabled - name: SYSTEMD MOUNT | Setup systemd Service for automount @@ -28,4 +44,9 @@ notify: - Reload systemd - Enable systemd automount - when: item.value.automount is defined and item.value.automount == true and item.key in systemd_mounts_enabled \ No newline at end of file + - 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 \ No newline at end of file