add cifsmount role

This commit is contained in:
aaron
2021-08-24 13:18:59 +02:00
parent fe73f4f03d
commit 87808eb999
11 changed files with 222 additions and 0 deletions

23
tasks/configuration.yaml Normal file
View File

@@ -0,0 +1,23 @@
---
- name: push samba credentials for each configured connection
template:
src: smbcredentials.j2
dest: '{{ cifs_credsfile_path }}/.smbcredentials_{{ item.name }}'
owner: '{{ cifs_credsfile_owner }}'
mode: '{{ cifs_credsfile_mode }}'
vars:
cifs_user: '{{ item.user }}'
cifs_pass: '{{ item.pass }}'
cifs_domain: '{{ item.domain | upper }}'
loop: '{{ cifs_connections }}'
- name: mount shared drive and persist configuration to fstab
mount:
fstype: cifs
state: mounted
path: '{{ cifs_mount_root_path }}/{{ item.name }}'
opts: 'credentials={{ cifs_credsfile_path }}/.smbcredentials_{{ item.name }},file_mode={{ cifs_file_mode }},dir_mode={{ cifs_dir_mode }}'
src: '{{ item.share }}'
loop: '{{ cifs_connections }}'
when: cifs_persist_config == true

6
tasks/installation.yaml Normal file
View File

@@ -0,0 +1,6 @@
---
- name: install all components for a working cifs mount
package:
name: '{{ cifs_packages }}'
state: present

19
tasks/main.yaml Normal file
View File

@@ -0,0 +1,19 @@
---
- name: load variables based on distribution type
include_vars: '{{ item }}'
with_first_found:
- '{{ ansible_distribution }}_{{ ansible_distribution_major_version }}.yaml'
- '{{ ansible_os_family }}.yaml'
tags:
- 'cifs_vars'
- name: install cifs and dependencies
import_tasks: installation.yaml
tags:
- 'cifs_installation'
- name: push cifs config
import_tasks: configuration.yaml
tags:
- 'cifs_configuration'