Feat: add samba shares
This commit is contained in:
parent
9221790ca0
commit
020e81176d
4
home.yml
4
home.yml
@ -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:
|
||||||
|
@ -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
|
|
||||||
|
2
roles/samba_server/defaults/main.yml
Normal file
2
roles/samba_server/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for samba_server
|
6
roles/samba_server/handlers/main.yml
Normal file
6
roles/samba_server/handlers/main.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
# handlers file for samba_server
|
||||||
|
- name: restart smbd
|
||||||
|
service:
|
||||||
|
name: smbd
|
||||||
|
state: restarted
|
7
roles/samba_server/tasks/debian.yml
Normal file
7
roles/samba_server/tasks/debian.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
- name: Debian - Install samba
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- samba
|
||||||
|
#- samba-common
|
||||||
|
state: present
|
32
roles/samba_server/tasks/main.yml
Normal file
32
roles/samba_server/tasks/main.yml
Normal 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
|
9
roles/samba_server/templates/smb_share.conf.j2
Normal file
9
roles/samba_server/templates/smb_share.conf.j2
Normal 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 %}
|
||||||
|
|
2
roles/samba_server/vars/main.yml
Normal file
2
roles/samba_server/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for samba_server
|
@ -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"
|
||||||
|
Loading…
Reference in New Issue
Block a user