Skip to content

Commit e7850e0

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
docs: document the availability of yaml and toml formatted confs
Mention that sambacc support yaml and toml and give brief examples of both. Signed-off-by: John Mulligan <[email protected]>
1 parent ecf9abe commit e7850e0

File tree

1 file changed

+102
-2
lines changed

1 file changed

+102
-2
lines changed

docs/configuration.md

Lines changed: 102 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11

22
# JSON Configuration Format
33

4-
Much of the behavior of sambacc is driven by the JSON based
5-
configuration file. The following is a high level example of the JSON
4+
Much of the behavior of sambacc is driven by the
5+
configuration files. The following is a high level example of the JSON
66
structure and a description of these sections.
77

8+
If sambacc is installed with the `yaml` extra it can support [YAML](#yaml)
9+
based configuration files. If sambacc is installed with the `toml` extra it can
10+
support [TOML](#toml) based configuration files. The JSON support is the
11+
default and is always present.
12+
813
```json
914
{
1015
"samba-container-config": "v0",
@@ -278,3 +283,98 @@ A domain user entry is as follows:
278283
* `password` - A plain-text password.
279284
* `member_of` - Optional. List of group names. The user will be added to the listed
280285
groups.
286+
287+
288+
# YAML
289+
290+
The [YAML](https://yaml.org/) format may be used to configure sambacc when
291+
PyYAML library is available. The YAML configuration is effectively converted to
292+
JSON internally when processed. All of the documentation applying to the JSON
293+
based configuration applies but in a somewhat easier to write format. The
294+
filename must end with `.yaml` or `.yml` for sambacc to parse the file as YAML.
295+
296+
An example of a YAML based configuration file:
297+
```yaml
298+
samba-container-config: v0
299+
# Define top-level configurations
300+
configs:
301+
try2:
302+
globals: ["default"]
303+
shares:
304+
- "example"
305+
- "Other Name"
306+
# Define Global Options
307+
globals:
308+
default:
309+
options:
310+
load printers: "no"
311+
printing: "bsd"
312+
printcap name: "/dev/null"
313+
disable spoolss: "yes"
314+
guest ok: "no"
315+
security: "user"
316+
server min protocol: "SMB2"
317+
# Define Shares
318+
shares:
319+
example:
320+
options:
321+
path: /srv/a
322+
read only: "no"
323+
Other Name:
324+
options:
325+
path: /srv/b
326+
read only: "no"
327+
# Define users
328+
users:
329+
all_entries:
330+
- {"name": "sambauser", "password": "samba"}
331+
- {"name": "otheruser", "password": "insecure321"}
332+
```
333+
334+
# TOML
335+
336+
The [TOML](https://toml.io/en/) format may be used to configure sambacc when
337+
used on Python 3.11 or later or when the tomli library is available. The TOML
338+
format may seem similar to the INI-style format used by Samba. The TOML
339+
configuration is effectively converted to JSON internally when processed. All
340+
of the documentation applying to the JSON based configuration applies but in a
341+
somewhat easier to read and write format. The filename must end with `.toml` for
342+
sambacc to parse the file as TOML.
343+
344+
An example of a TOML based configuration file:
345+
```toml
346+
samba-container-config = "v0"
347+
348+
# Define top level configurations
349+
[configs.try1]
350+
globals = ["default"]
351+
shares = ["example", "Other Name"]
352+
353+
# Define shares
354+
[shares.example.options]
355+
path = "/srv/a"
356+
"read only" = "no"
357+
358+
[shares."Other Name".options]
359+
path = "/srv/b"
360+
"read only" = "no"
361+
362+
# Define global options
363+
[globals.default.options]
364+
"load printers" = "no"
365+
printing = "bsd"
366+
"printcap name" = "/dev/null"
367+
"disable spoolss" = "yes"
368+
"guest ok" = "no"
369+
security = "user"
370+
"server min protocol" = "SMB2"
371+
372+
# Define users
373+
[[users.all_entries]]
374+
name = "sambauser"
375+
password = "samba"
376+
377+
[[users.all_entries]]
378+
name = "otheruser"
379+
password = "insecure321"
380+
```

0 commit comments

Comments
 (0)