Feat: add samba shares

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

View File

@ -39,8 +39,8 @@
name: nfs_server name: nfs_server
- name: Set up samba network shares - name: Set up samba network shares
debug: include_role:
msg: Todo name: samba_server
- name: Install docker - name: Install docker
debug: debug:

View File

@ -1,7 +1,2 @@
--- ---
# defaults file for nfs_server # 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

View File

@ -6,13 +6,29 @@ ssh_publickey: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB7aeBuq7TC8bRATkXa3QY4icPSz
#ansible_become_pass: "{{ lookup('passwordstore', 'home/nas/admin')}}" #ansible_become_pass: "{{ lookup('passwordstore', 'home/nas/admin')}}"
nfs_exports: nfs_exports:
- src: '/mnt/DocNas/Benjamin' - src: '/mnt/DocNas/Benjamin'
allowedIP: '192.168.2.0/24' allowedIP: '192.168.2.0/24'
options: 'rw,sync,no_root_squash' options: 'rw,sync,all_squash,anonuid=998,anongid=100,no_subtree_check'
- src: '/mnt/DocNas/Commun' - src: '/mnt/DocNas/Commun'
allowedIP: '192.168.2.0/24' allowedIP: '192.168.2.0/24'
options: 'rw,sync,no_root_squash' options: 'rw,sync,all_squash,anonuid=998,anongid=100,no_subtree_check'
- src: '/mnt/DocNas/Margot' - src: '/mnt/DocNas/Margot'
allowedIP: '192.168.2.0/24' allowedIP: '192.168.2.0/24'
options: 'rw,sync,no_root_squash' options: 'rw,sync,all_squash,anonuid=998,anongid=100,no_subtree_check'
samba_exports:
- name: Scans
comment: "Dépots des documents scannés"
browsable: 'yes'
public: 'yes'
writable: 'yes'
path: "/mnt/DocNas/Commun/Scans"
- name: Margot
comment: "Documents de Margot pour accès depuis windows"
browsable: 'yes'
public: 'yes'
writable: 'yes'
path: "/mnt/DocNas/Margot"