forked from jborean93/smbprotocol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
73 lines (64 loc) · 1.63 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
- hosts: all
gather_facts: no
become: yes
tasks:
- name: install samba
package:
name: samba
state: present
- name: template out smb.conf file
copy:
content: |
[global]
workgroup = WORKGROUP
valid users = @smbgroup
server signing = mandatory
ea support = yes
store dos attributes = yes
vfs objects = xattr_tdb streams_xattr
[share]
comment = Test Samba Share
path = /srv/samba/share
browsable = yes
guest ok = no
read only = no
create mask = 0755
[share-encrypted]
command = Test Encrypted Samba Share
path = /srv/samba/share-encrypted
browsable = yes
guest ok = no
read only = no
create mask = 0755
smb encrypt = required
dest: /etc/samba/smb.conf
- name: create smbgroup
group:
name: smbgroup
state: present
- name: create smbuser and add to smbgroup
user:
name: smbuser
password: "{{ 'smbpass' | password_hash('sha512', 'mysecretsalt') }}"
state: present
group: smbgroup
- name: set smbpassword
shell: (echo smbpass; echo smbpass) | smbpasswd -s -a smbuser
- name: create share directories
file:
path: /srv/samba/{{ item }}
state: directory
group: smbgroup
mode: '755'
owner: smbuser
loop:
- share
- share-encrypted
- name: set selinux permissions for samba dir
command: chcon -R -t samba_share_t /srv/samba/
- name: create and start the samba services
systemd:
name: smb
state: started
enabled: yes