Feat: add samba shares

This commit is contained in:
2022-06-02 17:54:32 +02:00
parent 9221790ca0
commit 020e81176d
9 changed files with 79 additions and 10 deletions

View File

@@ -1,7 +1,2 @@
---
# defaults file for nfs_server
shares:
- mount_point: /media/nfs/default
server: test.lan
export: /test
options: defaults

View File

@@ -0,0 +1,2 @@
---
# defaults file for samba_server

View File

@@ -0,0 +1,6 @@
---
# handlers file for samba_server
- name: restart smbd
service:
name: smbd
state: restarted

View File

@@ -0,0 +1,7 @@
---
- name: Debian - Install samba
apt:
name:
- samba
#- samba-common
state: present

View File

@@ -0,0 +1,32 @@
---
# tasks file for nfs_server
- name: Install os-specific packages
include_tasks: "{{ ansible_os_family | lower }}.yml"
- name: Ensure directories to export exist
file:
path: "{{ item.path }}"
state: directory
with_items: "{{ samba_exports }}"
- name: Include smb_share.conf
lineinfile:
dest: /etc/samba/smb.conf
backup: yes
line: "include = /etc/samba/smb_share.conf"
- name: Copy exports file.
template:
src: smb_share.conf.j2
dest: /etc/samba/smb_share.conf
owner: root
group: root
mode: 0644
notify: restart smbd
- name: Ensure samba is running.
service:
name: smbd
state: started
enabled: yes
when: samba_exports|length

View File

@@ -0,0 +1,9 @@
{% for export in samba_exports %}
[{{ export.name }}]
comment = {{ export.comment }}
browseable = {{ export.browseable | default("yes")}}
public = {{ export.public | default("yes") }}
path = {{ export.path}}
writable = {{ export.writable | default("yes") }}
{% endfor %}

View File

@@ -0,0 +1,2 @@
---
# vars file for samba_server