Skip to content

Commit

Permalink
docs: document the availability of yaml and toml formatted confs
Browse files Browse the repository at this point in the history
Mention that sambacc support yaml and toml and give brief examples
of both.

Signed-off-by: John Mulligan <[email protected]>
  • Loading branch information
phlogistonjohn committed Apr 24, 2023
1 parent 52f8bd2 commit 95ae94b
Showing 1 changed file with 100 additions and 2 deletions.
102 changes: 100 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@

# JSON Configuration Format

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

If sambacc is installed with the yaml extra it can support [YAML](#yaml) based
configuration files. If sambacc is installed with the toml extra it can support
[TOML](#toml) based configuration files. The JSON support is the default and is
always present.

```json
{
"samba-container-config": "v0",
Expand Down Expand Up @@ -278,3 +283,96 @@ A domain user entry is as follows:
* `password` - A plain-text password.
* `member_of` - Optional. List of group names. The user will be added to the listed
groups.


# YAML

The [YAML](https://yaml.org/) format may be used to configure sambacc when
PyYAML library is available. The YAML configuration is effectively converted to
JSON internally when processed. All of the documentation applying to the JSON
based configuration applies but in a somewhat eaiser to write format.

An example of a YAML based configuration file:
```yaml
samba-container-config: v0
# Define top-level configurations
configs:
try2:
globals: ["default"]
shares:
- "example"
- "Other Name"
# Define Global Options
globals:
default:
options:
load printers: "no"
printing: "bsd"
printcap name: "/dev/null"
disable spoolss: "yes"
guest ok: "no"
security: "user"
server min protocol: "SMB2"
# Define Shares
shares:
example:
options:
path: /srv/a
read only: "no"
Other Name:
options:
path: /srv/b
read only: "no"
# Define users
users:
all_entries:
- {"name": "sambauser", "password": "samba"}
- {"name": "otheruser", "password": "insecure321"}
```
# TOML
The [TOML](https://toml.io/en/) format may be used to configure sambacc when
used on Python 3.11 or later or when the tomli library is available. The TOML
format may seem similar to the INI-style format used by Samba. The TOML
configuration is effectively converted to JSON internally when processed. All
of the documentation applying to the JSON based configuration applies but in a
somewhat eaiser to read and write format.
An example of a TOML based configuration file:
```toml
samba-container-config = "v0"

# Define top level configurations
[configs.try1]
globals = ["default"]
shares = ["example", "Other Name"]

# Define shares
[shares.example.options]
path = "/srv/a"
"read only" = "no"

[shares."Other Name".options]
path = "/srv/b"
"read only" = "no"

# Define global options
[globals.default.options]
"load printers" = "no"
printing = "bsd"
"printcap name" = "/dev/null"
"disable spoolss" = "yes"
"guest ok" = "no"
security = "user"
"server min protocol" = "SMB2"

# Define users
[[users.all_entries]]
name = "sambauser"
password = "samba"

[[users.all_entries]]
name = "otheruser"
password = "insecure321"
```

0 comments on commit 95ae94b

Please sign in to comment.