-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall_samba.yml
76 lines (65 loc) · 1.87 KB
/
install_samba.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
74
75
---
- name: Install Samba
hosts: nuc
become: true
vars_files:
- secret.yml
tasks:
- name: Update apt cache
apt:
update_cache: yes
- name: Install samba package
apt:
name: samba
- name: Verify samba installation
command: systemctl status smbd
changed_when: False
- name: Configure workgroup in smb.conf
lineinfile:
dest: /etc/samba/smb.conf
regexp: '^ workgroup = .*'
line: ' workgroup = REXGROUP'
- name: Configure server string in smb.conf
lineinfile:
dest: /etc/samba/smb.conf
regexp: '^ server string = .*'
line: ' server string = rex_samba'
- name: Configure multi channel in smb.conf
blockinfile:
dest: /etc/samba/smb.conf
marker: "# {mark} ANSIBLE MANAGED BLOCK - multi channel"
insertbefore: '#### Networking ####'
block: |
{% set text = '''
server multi channel support = yes
aio read size = 1
aio write size = 1
''' %}
{{ text | trim | indent(width=3, first=True) }}
- name: Configure path in smb.conf
blockinfile:
dest: /etc/samba/smb.conf
marker: "# {mark} ANSIBLE MANAGED BLOCK - home path"
block: |
[Home]
comment = Shared home
path = /home/rex
browseable = yes
writable = yes
read only = no
guest ok = no
valid users = @rex
- name: Set up samba user
expect:
command: smbpasswd -a rex
responses:
"New SMB password:": "{{ samba_password }}"
"Retype new SMB password:": "{{ samba_password }}"
no_log: true
- name: Allow samba in UFW
ufw:
rule: allow
- name: Restart Samba service
service:
name: smbd
state: restarted