Skip to content

Commit 1186783

Browse files
committed
How to setup local samba SMB server
Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si>
1 parent 71a4cbc commit 1186783

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

DEVELOPMENT.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,38 @@ Details:
109109
- IP 10.5.11.39 (see `tests/integration/integration_config.yml.j2`)
110110
- CI tests should use only `/cidata` and subdirectories
111111
112+
#### Local SMB server
113+
114+
Use `ci-infra/smb-server/compose.yml` to start a local SMB server.
115+
The HyperCore cluster needs to have access to the SMB server.
116+
Execute the commands on machine that is accessible to HyperCore cluster -
117+
e.g. VM on the HyperCore NUC.
118+
119+
Usage:
120+
121+
```bash
122+
cd ci-infra/smb-server/
123+
docker compose up
124+
125+
# test it works
126+
smbclient "//IP_ADDRESS/Home" -U "alice%alipass" -D "/" -c "ls"
127+
smbclient "//IP_ADDRESS/Home" -U "alice%alipass" -D "/" -c "put compose.yml"
128+
smbclient "//IP_ADDRESS/Home" -U "alice%alipass" -D "/" -c "ls"
129+
```
130+
131+
To use this SMB server in `ansible-test integration ...`,
132+
set in `tests/integration/integration_config.yml`:
133+
134+
```yaml
135+
smb_server: "IP_ADDRESS"
136+
smb_share: "/home"
137+
smb_username: "alice"
138+
smb_password: "alipass"
139+
```
140+
141+
Notice - windows SMB server username is `;administrator`, it starts with `;`.
142+
This Samba SMB server username does not start with `;`.
143+
112144
### CI NTP server
113145
114146
NTP server is running on VM with github runner.

ci-infra/smb-server/compose.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
# docker-compose.yml example for https://github.com/ServerContainers/samba
3+
4+
services:
5+
samba:
6+
# build: .
7+
# image: ghcr.io/servercontainers/samba
8+
image: servercontainers/samba:smbd-only-a3.22.1-s4.21.4-r4
9+
restart: always
10+
# note that this network_mode makes it super easy (especially for zeroconf) but is not as safe as exposing ports directly
11+
# more about that here: https://book.hacktricks.wiki/en/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/index.html#hostnetwork
12+
network_mode: host
13+
# uncomment to solve bug: https://github.com/ServerContainers/samba/issues/50 - wsdd2 only - not needed for samba
14+
#cap_add:
15+
# - CAP_NET_ADMIN
16+
environment:
17+
# uncomment to enable fail fast (currently only fails fast if there are conflicts/errors during user/group creation)
18+
#FAIL_FAST: 1
19+
20+
MODEL: 'TimeCapsule'
21+
AVAHI_NAME: StorageServer
22+
23+
SAMBA_CONF_LOG_LEVEL: 3
24+
25+
# uncomment to disable optional services
26+
WSDD2_DISABLE: 1
27+
AVAHI_DISABLE: 1
28+
NETBIOS_DISABLE: 1
29+
30+
GROUP_family: 1500
31+
32+
ACCOUNT_alice: alipass
33+
UID_alice: 1000
34+
GROUPS_alice: family
35+
36+
ACCOUNT_bob: bobpass
37+
UID_bob: 1001
38+
GROUPS_bob: family
39+
40+
# example for hashed password (user: foo | password: bar) - generated using create-hash.sh script.
41+
ACCOUNT_foo: "foo:1000:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:86C156FC198B358CCCF6278D8BD49B6A:[U ]:LCT-61B0859A:"
42+
# example for password hashes in the list format:
43+
# - "ACCOUNT_foo=foo:1000:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:8846F7EAEE8FB117AD06BDD830B7586C:[U ]:LCT-5FE1F7DF:"
44+
UID_foo: 1002
45+
GROUPS_foo: family
46+
47+
SAMBA_VOLUME_CONFIG_shared_home: "[Home]; path=/shares/homes/%U; valid users = alice, bob, foo; guest ok = no; read only = no; browseable = yes"
48+
49+
# SAMBA_VOLUME_CONFIG_aliceonly: "[Alice Share]; path=/shares/alice; valid users = alice; guest ok = no; read only = no; browseable = yes"
50+
# SAMBA_VOLUME_CONFIG_alicehidden: "[Alice Hidden Share]; path=/shares/alice-hidden; valid users = alice; guest ok = no; read only = no; browseable = no"
51+
52+
# SAMBA_VOLUME_CONFIG_bobonly: "[Bob Share]; path=/shares/bob; valid users = bob; guest ok = no; read only = no; browseable = yes"
53+
54+
# SAMBA_VOLUME_CONFIG_public: "[Public]; path=/shares/public; valid users = alice, bob, foo; guest ok = no; read only = no; browseable = yes; force group = family"
55+
# SAMBA_VOLUME_CONFIG_public_ro: "[Public ReadOnly]; path=/shares/public; guest ok = yes; read only = yes; browseable = yes; force group = family"
56+
57+
# SAMBA_VOLUME_CONFIG_timemachine: "[TimeMachine]; path=/shares/timemachine/%U; valid users = alice, bob, foo; guest ok = no; read only = no; browseable = yes; fruit:time machine = yes; fruit:time machine max size = 500G"
58+
59+
# SAMBA_VOLUME_CONFIG_guestmultilineexample: |
60+
# [Guest Share]
61+
# path = /shares/guest
62+
# guest ok = yes
63+
# browseable = yes
64+
65+
volumes:
66+
# - /etc/avahi/services/:/external/avahi
67+
68+
# avoid loops when mounting folders to /shares (I'd recommend explicit mapping for each share)
69+
# - ./shares/alice:/shares/alice
70+
# - ./shares/alice-hidden:/shares/alice-hidden
71+
# - ./shares/bob:/shares/bob
72+
# - ./shares/public:/shares/public
73+
# - ./shares/homes:/shares/homes
74+
# - ./shares/timemachine:/shares/timemachine
75+
- ./shares-homes:/shares/homes

0 commit comments

Comments
 (0)