finish autofs role

This commit is contained in:
vincent 2019-01-27 20:17:42 +01:00
parent c59df1fd13
commit 9950378ea9
3 changed files with 29 additions and 13 deletions

View File

@ -1,12 +1,6 @@
systemd_mounts: {} systemd_mounts: {}
systemd_mounts_enabled: [] systemd_mounts_enabled: []
systemd_mounts_manage_service: {}
systemd_mounts_allow_reload: {}
autofs_mounts_manage_service: {}
autofs_mounts_allow_reload: {}
systemd_mount_packages: systemd_mount_packages:
- cifs-utils - cifs-utils

View File

@ -2,21 +2,21 @@
- name: Reload systemd - name: Reload systemd
systemd: systemd:
daemon_reload: yes daemon_reload: yes
when: systemd_mounts_manage_service become: yes
- name: Start systemd mount - name: Start systemd mount
systemd: systemd:
name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.mount" name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.mount"
state: started state: started
with_dict: "{{ systemd_mounts }}" with_dict: "{{ systemd_mounts }}"
when: systemd_mounts_manage_service become: yes
- name: Start systemd automount - name: Start systemd automount
systemd: systemd:
name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.automount" name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.automount"
state: started state: started
with_dict: "{{ systemd_mounts }}" with_dict: "{{ systemd_mounts }}"
when: systemd_mounts_manage_service become: yes
- name: Enable systemd mount - name: Enable systemd mount
systemd: systemd:
@ -26,12 +26,13 @@
notify: notify:
- Start systemd mount - Start systemd mount
when: item.value.automount == false when: item.value.automount == false
become: yes
- name: Enable systemd automount - name: Enable systemd automount
systemd: systemd:
name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.automount" name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.automount"
enabled: yes enabled: yes
with_dict: "{{ systemd_mounts }}" with_dict: "{{ systemd_mounts }}"
notify:
- Start systemd automount
when: item.value.automount == true when: item.value.automount == true
become: yes

View File

@ -8,7 +8,22 @@
package: package:
name: "{{ item }}" name: "{{ item }}"
state: installed 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 - name: SYSTEMD MOUNT | Setup systemd Service for mountpoints
template: template:
@ -18,6 +33,7 @@
notify: notify:
- Reload systemd - Reload systemd
- Enable systemd mount - Enable systemd mount
become: yes
when: item.key in systemd_mounts_enabled when: item.key in systemd_mounts_enabled
- name: SYSTEMD MOUNT | Setup systemd Service for automount - name: SYSTEMD MOUNT | Setup systemd Service for automount
@ -28,4 +44,9 @@
notify: notify:
- Reload systemd - Reload systemd
- Enable systemd automount - 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 when: item.value.automount is defined and item.value.automount == true and item.key in systemd_mounts_enabled
- name: execute handler
meta: flush_handlers