finish autofs role
This commit is contained in:
parent
9950378ea9
commit
1ea2fb3f5f
@ -5,4 +5,11 @@ systemd_mounts_enabled: []
|
||||
systemd_mount_packages:
|
||||
- cifs-utils
|
||||
- nfs-utils
|
||||
- davfs2
|
||||
- davfs2
|
||||
|
||||
#credentials_files:
|
||||
# - 1:
|
||||
# type:
|
||||
# path:
|
||||
# username:
|
||||
# password:
|
@ -4,27 +4,11 @@
|
||||
daemon_reload: yes
|
||||
become: yes
|
||||
|
||||
- name: Start systemd mount
|
||||
systemd:
|
||||
name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.mount"
|
||||
state: started
|
||||
with_dict: "{{ systemd_mounts }}"
|
||||
become: yes
|
||||
|
||||
- name: Start systemd automount
|
||||
systemd:
|
||||
name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.automount"
|
||||
state: started
|
||||
with_dict: "{{ systemd_mounts }}"
|
||||
become: yes
|
||||
|
||||
- name: Enable systemd mount
|
||||
systemd:
|
||||
name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.mount"
|
||||
enabled: yes
|
||||
with_dict: "{{ systemd_mounts }}"
|
||||
notify:
|
||||
- Start systemd mount
|
||||
when: item.value.automount == false
|
||||
become: yes
|
||||
|
||||
@ -35,4 +19,21 @@
|
||||
with_dict: "{{ systemd_mounts }}"
|
||||
|
||||
when: item.value.automount == true
|
||||
become: yes
|
||||
become: yes
|
||||
|
||||
|
||||
- name: Start systemd mount
|
||||
systemd:
|
||||
name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.mount"
|
||||
state: started
|
||||
with_dict: "{{ systemd_mounts }}"
|
||||
when: item.value.automount == false
|
||||
become: yes
|
||||
|
||||
- name: Start systemd automount
|
||||
systemd:
|
||||
name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.automount"
|
||||
state: started
|
||||
with_dict: "{{ systemd_mounts }}"
|
||||
when: item.value.automount == true
|
||||
become: yes
|
||||
|
@ -4,6 +4,39 @@
|
||||
# systemd uses - for dir separator, so dirs with dashes need escaped according to systemd-escape rules
|
||||
#
|
||||
|
||||
|
||||
|
||||
- name: Make sure destination dir exists
|
||||
file:
|
||||
path: "{{ item.value.path | dirname }}"
|
||||
state: directory
|
||||
recurse: yes
|
||||
with_dict: "{{ credentials_files }}"
|
||||
become: true
|
||||
when: item is defined
|
||||
|
||||
|
||||
- name: set smb content to credential file
|
||||
copy:
|
||||
content: |
|
||||
username={{ item.value.username }}
|
||||
password={{ item.value.password }}
|
||||
dest: "{{ item.value.path }}"
|
||||
mode: 0600
|
||||
with_dict: "{{ credentials_files }}"
|
||||
become: true
|
||||
when: item is defined and item.value.type == "smb"
|
||||
|
||||
- name: set davfs content to credential file
|
||||
copy:
|
||||
content: |
|
||||
{{ item.value.adress }} {{ item.value.username }} {{ item.value.password }}
|
||||
dest: "{{ item.value.path }}"
|
||||
mode: 0600
|
||||
with_dict: "{{ credentials_files }}"
|
||||
become: true
|
||||
when: item is defined and item.value.type == "davfs"
|
||||
|
||||
- name: SYSTEMD MOUNT | Install needed packages
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
@ -11,18 +44,11 @@
|
||||
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}}"
|
||||
path: "{{item.value.mount}}"
|
||||
state: directory
|
||||
when: item.stat.exists == false
|
||||
with_items: "{{test_folder.results}}"
|
||||
with_dict: "{{ systemd_mounts }}"
|
||||
become: yes
|
||||
|
||||
- name: SYSTEMD MOUNT | Setup systemd Service for mountpoints
|
||||
@ -33,6 +59,7 @@
|
||||
notify:
|
||||
- Reload systemd
|
||||
- Enable systemd mount
|
||||
- Start systemd mount
|
||||
become: yes
|
||||
when: item.key in systemd_mounts_enabled
|
||||
|
||||
@ -48,5 +75,5 @@
|
||||
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
|
||||
|
||||
|
@ -5,8 +5,8 @@ After=network.target multi-user.target
|
||||
[Mount]
|
||||
What={{ item.value.share }}
|
||||
Where={{ item.value.mount }}
|
||||
Type={{ item.value.type | default ('mounts_type') }}
|
||||
Options={{ item.value.options | join(',') | default ('mounts_options') }}
|
||||
Type={{ item.value.type | default ('mounts_type') }}
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
Loading…
Reference in New Issue
Block a user