autofs/tasks/main.yml

84 lines
2.2 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: Include OS-specific variables.
include_vars: "{{ ansible_os_family }}.yml"
2019-04-08 21:08:29 +00:00
- 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
2019-10-24 18:45:46 +00:00
2019-04-08 21:08:29 +00:00
copy:
content: |
username={{ item.value.username }}
password={{ item.value.password }}
dest: "{{ item.value.path }}"
mode: 0600
with_dict: "{{ credentials_files }}"
become: true
2019-10-03 19:58:45 +00:00
no_log: true
2019-04-08 21:08:29 +00:00
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
2019-10-24 18:45:46 +00:00
no_log: true
2019-04-08 21:08:29 +00:00
when: item is defined and item.value.type == "davfs"
2019-01-12 18:12:55 +00:00
- name: SYSTEMD MOUNT | Install needed packages
package:
name: "{{ item }}"
state: present
2019-01-27 19:17:42 +00:00
with_items: "{{ systemd_mount_packages }}"
become: yes
- name: create mount directory if doesn't exist
file:
2019-04-08 21:08:29 +00:00
path: "{{item.value.mount}}"
2019-01-27 19:17:42 +00:00
state: directory
2019-04-23 17:16:51 +00:00
mode: 0777
2019-04-08 21:08:29 +00:00
with_dict: "{{ systemd_mounts }}"
2019-01-27 19:17:42 +00:00
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-04-08 21:08:29 +00:00
- Start 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
2019-04-08 21:08:29 +00:00