finish autofs role
This commit is contained in:
parent
9950378ea9
commit
1ea2fb3f5f
@ -6,3 +6,10 @@ systemd_mount_packages:
|
|||||||
- cifs-utils
|
- cifs-utils
|
||||||
- nfs-utils
|
- nfs-utils
|
||||||
- davfs2
|
- davfs2
|
||||||
|
|
||||||
|
#credentials_files:
|
||||||
|
# - 1:
|
||||||
|
# type:
|
||||||
|
# path:
|
||||||
|
# username:
|
||||||
|
# password:
|
@ -4,27 +4,11 @@
|
|||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
become: 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
|
- name: Enable systemd mount
|
||||||
systemd:
|
systemd:
|
||||||
name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.mount"
|
name: "{{ item.value.mount[1:] | replace('-', '\\x2d') | replace('/', \"-\") }}.mount"
|
||||||
enabled: yes
|
enabled: yes
|
||||||
with_dict: "{{ systemd_mounts }}"
|
with_dict: "{{ systemd_mounts }}"
|
||||||
notify:
|
|
||||||
- Start systemd mount
|
|
||||||
when: item.value.automount == false
|
when: item.value.automount == false
|
||||||
become: yes
|
become: yes
|
||||||
|
|
||||||
@ -36,3 +20,20 @@
|
|||||||
|
|
||||||
when: item.value.automount == true
|
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
|
# 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
|
- name: SYSTEMD MOUNT | Install needed packages
|
||||||
package:
|
package:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
@ -11,18 +44,11 @@
|
|||||||
with_items: "{{ systemd_mount_packages }}"
|
with_items: "{{ systemd_mount_packages }}"
|
||||||
become: yes
|
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
|
- name: create mount directory if doesn't exist
|
||||||
file:
|
file:
|
||||||
path: "{{item.item}}"
|
path: "{{item.value.mount}}"
|
||||||
state: directory
|
state: directory
|
||||||
when: item.stat.exists == false
|
with_dict: "{{ systemd_mounts }}"
|
||||||
with_items: "{{test_folder.results}}"
|
|
||||||
become: yes
|
become: yes
|
||||||
|
|
||||||
- name: SYSTEMD MOUNT | Setup systemd Service for mountpoints
|
- name: SYSTEMD MOUNT | Setup systemd Service for mountpoints
|
||||||
@ -33,6 +59,7 @@
|
|||||||
notify:
|
notify:
|
||||||
- Reload systemd
|
- Reload systemd
|
||||||
- Enable systemd mount
|
- Enable systemd mount
|
||||||
|
- Start systemd mount
|
||||||
become: yes
|
become: yes
|
||||||
when: item.key in systemd_mounts_enabled
|
when: item.key in systemd_mounts_enabled
|
||||||
|
|
||||||
@ -48,5 +75,5 @@
|
|||||||
become: yes
|
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
|
|
@ -5,8 +5,8 @@ After=network.target multi-user.target
|
|||||||
[Mount]
|
[Mount]
|
||||||
What={{ item.value.share }}
|
What={{ item.value.share }}
|
||||||
Where={{ item.value.mount }}
|
Where={{ item.value.mount }}
|
||||||
Type={{ item.value.type | default ('mounts_type') }}
|
|
||||||
Options={{ item.value.options | join(',') | default ('mounts_options') }}
|
Options={{ item.value.options | join(',') | default ('mounts_options') }}
|
||||||
|
Type={{ item.value.type | default ('mounts_type') }}
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=default.target
|
WantedBy=default.target
|
Loading…
Reference in New Issue
Block a user