diff options
author | clarkzjw <[email protected]> | 2023-01-13 16:20:40 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-01-13 16:20:40 -0800 |
commit | af2cda33cf39262a3dc8bc7260168684d4ce4c06 (patch) | |
tree | b57b1a6f412a8d4f6c8e7dee008112f932a6c596 | |
parent | 61b24b7f9da768902886747ea70e5b91695edad0 (diff) | |
download | homelab-af2cda33cf39262a3dc8bc7260168684d4ce4c06.tar.gz |
update samba config
-rw-r--r-- | clarkzjw.ca/config/atlas/README.md | 3 | ||||
-rw-r--r-- | clarkzjw.ca/config/atlas/roles/debian_init/tasks/main.yaml | 1 | ||||
-rw-r--r-- | clarkzjw.ca/config/atlas/roles/samba/defaults/main.yaml | 3 | ||||
-rw-r--r-- | clarkzjw.ca/config/atlas/roles/samba/tasks/main.yaml | 41 | ||||
-rw-r--r-- | clarkzjw.ca/config/atlas/roles/samba/templates/smb.conf.j2 | 243 | ||||
-rw-r--r-- | clarkzjw.ca/config/atlas/samba.yaml | 2 | ||||
-rw-r--r-- | clarkzjw.ca/config/atlas/setup.yaml | 4 |
7 files changed, 64 insertions, 233 deletions
diff --git a/clarkzjw.ca/config/atlas/README.md b/clarkzjw.ca/config/atlas/README.md index 37e39b3..55f8989 100644 --- a/clarkzjw.ca/config/atlas/README.md +++ b/clarkzjw.ca/config/atlas/README.md | |||
@@ -29,5 +29,6 @@ zpool export pool1 | |||
29 | 29 | ||
30 | ### Setup Samba | 30 | ### Setup Samba |
31 | ```bash | 31 | ```bash |
32 | source admin-rc | ||
32 | ansible-playbook samba.yaml | 33 | ansible-playbook samba.yaml |
33 | ``` \ No newline at end of file | 34 | ``` |
diff --git a/clarkzjw.ca/config/atlas/roles/debian_init/tasks/main.yaml b/clarkzjw.ca/config/atlas/roles/debian_init/tasks/main.yaml index 4cfc23d..e53d3eb 100644 --- a/clarkzjw.ca/config/atlas/roles/debian_init/tasks/main.yaml +++ b/clarkzjw.ca/config/atlas/roles/debian_init/tasks/main.yaml | |||
@@ -39,6 +39,7 @@ | |||
39 | - name: Install ZFS | 39 | - name: Install ZFS |
40 | apt: | 40 | apt: |
41 | name: | 41 | name: |
42 | - linux-headers-amd64 | ||
42 | - linux-headers-{{ ansible_kernel }} | 43 | - linux-headers-{{ ansible_kernel }} |
43 | - zfsutils-linux | 44 | - zfsutils-linux |
44 | - zfs-dkms | 45 | - zfs-dkms |
diff --git a/clarkzjw.ca/config/atlas/roles/samba/defaults/main.yaml b/clarkzjw.ca/config/atlas/roles/samba/defaults/main.yaml new file mode 100644 index 0000000..88c23b1 --- /dev/null +++ b/clarkzjw.ca/config/atlas/roles/samba/defaults/main.yaml | |||
@@ -0,0 +1,3 @@ | |||
1 | samba_users: | ||
2 | - username: clarkzjw | ||
3 | password: "{{ lookup('env', 'SAMBA_PASSWORD') }}" \ No newline at end of file | ||
diff --git a/clarkzjw.ca/config/atlas/roles/samba/tasks/main.yaml b/clarkzjw.ca/config/atlas/roles/samba/tasks/main.yaml index 7c1edec..0ada38a 100644 --- a/clarkzjw.ca/config/atlas/roles/samba/tasks/main.yaml +++ b/clarkzjw.ca/config/atlas/roles/samba/tasks/main.yaml | |||
@@ -6,9 +6,48 @@ | |||
6 | - cifs-utils | 6 | - cifs-utils |
7 | update_cache: true | 7 | update_cache: true |
8 | 8 | ||
9 | - name: Disable Samba NetBIOS server nmbd | ||
10 | systemd: | ||
11 | name: nmbd | ||
12 | state: stopped | ||
13 | enabled: false | ||
9 | 14 | ||
10 | - name: render samba config file | 15 | - name: render samba config file |
11 | template: | 16 | template: |
12 | src: smb.conf.j2 | 17 | src: smb.conf.j2 |
13 | dest: "/etc/samba/smb.conf" | 18 | dest: "/etc/samba/smb.conf" |
14 | mode: 0644 \ No newline at end of file | 19 | mode: 0644 |
20 | |||
21 | # https://stackoverflow.com/questions/44762488/non-interactive-samba-user-creation-via-ansible | ||
22 | - name: shell - create samba users | ||
23 | shell: > | ||
24 | set -e -o pipefail | ||
25 | && (pdbedit --user={{ item.username }} 2>&1 > /dev/null) | ||
26 | || (echo '{{ item.password }}'; echo '{{ item.password }}') | ||
27 | | smbpasswd -s -a {{ item.username }} | ||
28 | args: | ||
29 | executable: /bin/bash | ||
30 | register: samba_create_users | ||
31 | changed_when: "'Added user' in samba_create_users.stdout" | ||
32 | loop: "{{ samba_users }}" | ||
33 | # no_log: true | ||
34 | |||
35 | - name: shell - set samba passwords correctly | ||
36 | shell: > | ||
37 | set -e -o pipefail | ||
38 | && (smbclient -U {{ item.username }}%{{ item.password }} -L 127.0.0.1 2>&1 > /dev/null) | ||
39 | || (echo '{{ item.password }}'; echo '{{ item.password }}') | ||
40 | | smbpasswd {{ item.username }} | ||
41 | args: | ||
42 | executable: /bin/bash | ||
43 | register: samba_verify_users | ||
44 | changed_when: "'New SMB password' in samba_verify_users.stdout" | ||
45 | loop: "{{ samba_users }}" | ||
46 | # no_log: true | ||
47 | |||
48 | - name: Restart SMB service | ||
49 | systemd: | ||
50 | name: smbd | ||
51 | state: restarted | ||
52 | enabled: true | ||
53 | daemon_reload: true | ||
diff --git a/clarkzjw.ca/config/atlas/roles/samba/templates/smb.conf.j2 b/clarkzjw.ca/config/atlas/roles/samba/templates/smb.conf.j2 index 5b59497..06e2567 100644 --- a/clarkzjw.ca/config/atlas/roles/samba/templates/smb.conf.j2 +++ b/clarkzjw.ca/config/atlas/roles/samba/templates/smb.conf.j2 | |||
@@ -1,240 +1,27 @@ | |||
1 | # | ||
2 | # Sample configuration file for the Samba suite for Debian GNU/Linux. | ||
3 | # | ||
4 | # | ||
5 | # This is the main Samba configuration file. You should read the | ||
6 | # smb.conf(5) manual page in order to understand the options listed | ||
7 | # here. Samba has a huge number of configurable options most of which | ||
8 | # are not shown in this example | ||
9 | # | ||
10 | # Some options that are often worth tuning have been included as | ||
11 | # commented-out examples in this file. | ||
12 | # - When such options are commented with ";", the proposed setting | ||
13 | # differs from the default Samba behaviour | ||
14 | # - When commented with "#", the proposed setting is the default | ||
15 | # behaviour of Samba but the option is considered important | ||
16 | # enough to be mentioned here | ||
17 | # | ||
18 | # NOTE: Whenever you modify this file you should run the command | ||
19 | # "testparm" to check that you have not made any basic syntactic | ||
20 | # errors. | ||
21 | |||
22 | #======================= Global Settings ======================= | ||
23 | |||
24 | [global] | 1 | [global] |
25 | 2 | workgroup = WORKGROUP | |
26 | ## Browsing/Identification ### | 3 | interfaces = 192.168.1.0/24 tailscale0 |
27 | 4 | bind interfaces only = yes | |
28 | # Change this to the workgroup/NT-domain name your Samba server will part of | 5 | log file = /var/log/samba/log.%m |
29 | workgroup = WORKGROUP | 6 | max log size = 1000 |
30 | 7 | logging = file | |
31 | #### Networking #### | 8 | panic action = /usr/share/samba/panic-action %d |
32 | 9 | server role = standalone server | |
33 | # The specific set of interfaces / networks to bind to | 10 | obey pam restrictions = yes |
34 | # This can be either the interface name or an IP address/netmask; | 11 | unix password sync = yes |
35 | # interface names are normally preferred | 12 | passwd program = /usr/bin/passwd %u |
36 | ; interfaces = 127.0.0.0/8 eth0 | 13 | passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . |
37 | 14 | pam password change = yes | |
38 | # Only bind to the named interfaces and/or networks; you must use the | 15 | map to guest = bad user |
39 | # 'interfaces' option above to use this. | ||
40 | # It is recommended that you enable this feature if your Samba machine is | ||
41 | # not protected by a firewall or is a firewall itself. However, this | ||
42 | # option cannot handle dynamic or non-broadcast interfaces correctly. | ||
43 | ; bind interfaces only = yes | ||
44 | |||
45 | |||
46 | |||
47 | #### Debugging/Accounting #### | ||
48 | |||
49 | # This tells Samba to use a separate log file for each machine | ||
50 | # that connects | ||
51 | log file = /var/log/samba/log.%m | ||
52 | |||
53 | # Cap the size of the individual log files (in KiB). | ||
54 | max log size = 1000 | ||
55 | |||
56 | # We want Samba to only log to /var/log/samba/log.{smbd,nmbd}. | ||
57 | # Append syslog@1 if you want important messages to be sent to syslog too. | ||
58 | logging = file | ||
59 | |||
60 | # Do something sensible when Samba crashes: mail the admin a backtrace | ||
61 | panic action = /usr/share/samba/panic-action %d | ||
62 | |||
63 | |||
64 | ####### Authentication ####### | ||
65 | |||
66 | # Server role. Defines in which mode Samba will operate. Possible | ||
67 | # values are "standalone server", "member server", "classic primary | ||
68 | # domain controller", "classic backup domain controller", "active | ||
69 | # directory domain controller". | ||
70 | # | ||
71 | # Most people will want "standalone server" or "member server". | ||
72 | # Running as "active directory domain controller" will require first | ||
73 | # running "samba-tool domain provision" to wipe databases and create a | ||
74 | # new domain. | ||
75 | server role = standalone server | ||
76 | |||
77 | obey pam restrictions = yes | ||
78 | |||
79 | # This boolean parameter controls whether Samba attempts to sync the Unix | ||
80 | # password with the SMB password when the encrypted SMB password in the | ||
81 | # passdb is changed. | ||
82 | unix password sync = yes | ||
83 | |||
84 | # For Unix password sync to work on a Debian GNU/Linux system, the following | ||
85 | # parameters must be set (thanks to Ian Kahan <<[email protected]> for | ||
86 | # sending the correct chat script for the passwd program in Debian Sarge). | ||
87 | passwd program = /usr/bin/passwd %u | ||
88 | passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . | ||
89 | |||
90 | # This boolean controls whether PAM will be used for password changes | ||
91 | # when requested by an SMB client instead of the program listed in | ||
92 | # 'passwd program'. The default is 'no'. | ||
93 | pam password change = yes | ||
94 | |||
95 | # This option controls how unsuccessful authentication attempts are mapped | ||
96 | # to anonymous connections | ||
97 | map to guest = bad user | ||
98 | |||
99 | ########## Domains ########### | ||
100 | |||
101 | # | ||
102 | # The following settings only takes effect if 'server role = classic | ||
103 | # primary domain controller', 'server role = classic backup domain controller' | ||
104 | # or 'domain logons' is set | ||
105 | # | ||
106 | |||
107 | # It specifies the location of the user's | ||
108 | # profile directory from the client point of view) The following | ||
109 | # required a [profiles] share to be setup on the samba server (see | ||
110 | # below) | ||
111 | ; logon path = \\%N\profiles\%U | ||
112 | # Another common choice is storing the profile in the user's home directory | ||
113 | # (this is Samba's default) | ||
114 | # logon path = \\%N\%U\profile | ||
115 | |||
116 | # The following setting only takes effect if 'domain logons' is set | ||
117 | # It specifies the location of a user's home directory (from the client | ||
118 | # point of view) | ||
119 | ; logon drive = H: | ||
120 | # logon home = \\%N\%U | ||
121 | |||
122 | # The following setting only takes effect if 'domain logons' is set | ||
123 | # It specifies the script to run during logon. The script must be stored | ||
124 | # in the [netlogon] share | ||
125 | # NOTE: Must be store in 'DOS' file format convention | ||
126 | ; logon script = logon.cmd | ||
127 | |||
128 | # This allows Unix users to be created on the domain controller via the SAMR | ||
129 | # RPC pipe. The example command creates a user account with a disabled Unix | ||
130 | # password; please adapt to your needs | ||
131 | ; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u | ||
132 | |||
133 | # This allows machine accounts to be created on the domain controller via the | ||
134 | # SAMR RPC pipe. | ||
135 | # The following assumes a "machines" group exists on the system | ||
136 | ; add machine script = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u | ||
137 | |||
138 | # This allows Unix groups to be created on the domain controller via the SAMR | ||
139 | # RPC pipe. | ||
140 | ; add group script = /usr/sbin/addgroup --force-badname %g | ||
141 | |||
142 | ############ Misc ############ | ||
143 | |||
144 | # Using the following line enables you to customise your configuration | ||
145 | # on a per machine basis. The %m gets replaced with the netbios name | ||
146 | # of the machine that is connecting | ||
147 | ; include = /home/samba/etc/smb.conf.%m | ||
148 | |||
149 | # Some defaults for winbind (make sure you're not using the ranges | ||
150 | # for something else.) | ||
151 | ; idmap config * : backend = tdb | ||
152 | ; idmap config * : range = 3000-7999 | ||
153 | ; idmap config YOURDOMAINHERE : backend = tdb | ||
154 | ; idmap config YOURDOMAINHERE : range = 100000-999999 | ||
155 | ; template shell = /bin/bash | ||
156 | |||
157 | # Setup usershare options to enable non-root users to share folders | ||
158 | # with the net usershare command. | ||
159 | |||
160 | # Maximum number of usershare. 0 means that usershare is disabled. | ||
161 | # usershare max shares = 100 | ||
162 | |||
163 | # Allow users who've been granted usershare privileges to create | ||
164 | # public shares, not just authenticated ones | ||
165 | usershare allow guests = yes | ||
166 | |||
167 | #======================= Share Definitions ======================= | ||
168 | 16 | ||
169 | [homes] | 17 | [homes] |
170 | comment = Home Directories | 18 | comment = Home Directories |
171 | browseable = no | 19 | browseable = no |
172 | |||
173 | # By default, the home directories are exported read-only. Change the | ||
174 | # next parameter to 'no' if you want to be able to write to them. | ||
175 | read only = yes | 20 | read only = yes |
176 | |||
177 | # File creation mask is set to 0700 for security reasons. If you want to | ||
178 | # create files with group=rw permissions, set next parameter to 0775. | ||
179 | create mask = 0700 | 21 | create mask = 0700 |
180 | |||
181 | # Directory creation mask is set to 0700 for security reasons. If you want to | ||
182 | # create dirs. with group=rw permissions, set next parameter to 0775. | ||
183 | directory mask = 0700 | 22 | directory mask = 0700 |
184 | |||
185 | # By default, \\server\username shares can be connected to by anyone | ||
186 | # with access to the samba server. | ||
187 | # The following parameter makes sure that only "username" can connect | ||
188 | # to \\server\username | ||
189 | # This might need tweaking when using external authentication schemes | ||
190 | valid users = %S | 23 | valid users = %S |
191 | 24 | ||
192 | # Un-comment the following and create the netlogon directory for Domain Logons | ||
193 | # (you need to configure Samba to act as a domain controller too.) | ||
194 | ;[netlogon] | ||
195 | ; comment = Network Logon Service | ||
196 | ; path = /home/samba/netlogon | ||
197 | ; guest ok = yes | ||
198 | ; read only = yes | ||
199 | |||
200 | # Un-comment the following and create the profiles directory to store | ||
201 | # users profiles (see the "logon path" option above) | ||
202 | # (you need to configure Samba to act as a domain controller too.) | ||
203 | # The path below should be writable by all users so that their | ||
204 | # profile directory may be created the first time they log on | ||
205 | ;[profiles] | ||
206 | ; comment = Users profiles | ||
207 | ; path = /home/samba/profiles | ||
208 | ; guest ok = no | ||
209 | ; browseable = no | ||
210 | ; create mask = 0600 | ||
211 | ; directory mask = 0700 | ||
212 | |||
213 | #[printers] | ||
214 | # comment = All Printers | ||
215 | # browseable = no | ||
216 | # path = /var/spool/samba | ||
217 | # printable = yes | ||
218 | # guest ok = no | ||
219 | # read only = yes | ||
220 | # create mask = 0700 | ||
221 | |||
222 | # Windows clients look for this share name as a source of downloadable | ||
223 | # printer drivers | ||
224 | #[print$] | ||
225 | # comment = Printer Drivers | ||
226 | # path = /var/lib/samba/printers | ||
227 | # browseable = yes | ||
228 | # read only = yes | ||
229 | # guest ok = no | ||
230 | # Uncomment to allow remote administration of Windows print drivers. | ||
231 | # You may need to replace 'lpadmin' with the name of the group your | ||
232 | # admin users are members of. | ||
233 | # Please note that you also need to set appropriate Unix permissions | ||
234 | # to the drivers directory for these users to have write rights in it | ||
235 | ; write list = root, @lpadmin | ||
236 | |||
237 | |||
238 | [pool1] | 25 | [pool1] |
239 | comment = NAS Share | 26 | comment = NAS Share |
240 | path = /pool1/clarkzjw | 27 | path = /pool1/clarkzjw |
@@ -243,4 +30,4 @@ | |||
243 | valid users = @clarkzjw | 30 | valid users = @clarkzjw |
244 | force create mode = 770 | 31 | force create mode = 770 |
245 | force directory mode = 770 | 32 | force directory mode = 770 |
246 | inherit permissions = yes \ No newline at end of file | 33 | inherit permissions = yes |
diff --git a/clarkzjw.ca/config/atlas/samba.yaml b/clarkzjw.ca/config/atlas/samba.yaml index 374943c..f363afc 100644 --- a/clarkzjw.ca/config/atlas/samba.yaml +++ b/clarkzjw.ca/config/atlas/samba.yaml | |||
@@ -1,5 +1,5 @@ | |||
1 | - name: Setup Samba | 1 | - name: Setup Samba |
2 | hosts: storinator | 2 | hosts: atlas |
3 | remote_user: clarkzjw | 3 | remote_user: clarkzjw |
4 | gather_facts: true | 4 | gather_facts: true |
5 | 5 | ||
diff --git a/clarkzjw.ca/config/atlas/setup.yaml b/clarkzjw.ca/config/atlas/setup.yaml index 08592d3..0dbbd4a 100644 --- a/clarkzjw.ca/config/atlas/setup.yaml +++ b/clarkzjw.ca/config/atlas/setup.yaml | |||
@@ -1,5 +1,5 @@ | |||
1 | - name: Setup Storinator | 1 | - name: Install ZFS and setup Debian |
2 | hosts: storinator | 2 | hosts: atlas |
3 | remote_user: clarkzjw | 3 | remote_user: clarkzjw |
4 | gather_facts: true | 4 | gather_facts: true |
5 | 5 | ||