<a id="cli-config"></a>

<a id="configuration-management"></a>

# Configuration management

These sub-commands can reload the [running configuration](config_smtpd.html.md)
(including its Halon [script](https://docs.halon.io/hsl/archive/6.12-stable/))
and control the built-in blue-green testing that we call “live stage”.
See the [configuration](config.html.md) section for more information.

<a id="script-syntax-and-packing"></a>

## Script syntax and packing

The [script](https://docs.halon.io/hsl/archive/6.12-stable/) is normally edited as individual files
using the [Visual Studio Code integration](vscode.html.md) or simply a text editor.
Those are then checked and “packed” into an actual configuration
file by the *halonconfig* script as described in the
[script directive](config_smtpd.html.md#config-script) section.

Given that the folder *test* contains *halonconfig*’s
standard file structure (see  */opt/halon/share/examples*) you can
pack, validate and reload the configuration directly on the MTA by:

```console
$ cd test
(editing configuration files)
$ halonconfig
# cp dist/* /etc/halon/
# service halon reload
```

If you want to exclude any files inside the *src/files* folder from being packed
you can add a  *.halonignore* file which supports regular glob patterns.

The *halonconfig* command may also be used to “unpack” the configuration,
reversing the described process above.

<a id="cli-reload"></a>

<a id="reloading-configurations"></a>

## Reloading configurations

You can also invoke the individual reload commands directly:

```console
$ halonctl config reload                   # /etc/halon/smtpd-app.yaml
$ halonctl queue policy reload             # /etc/halon/smtpd-policy.yaml
$ halonctl queue suspend reload            # /etc/halon/smtpd-suspend.yaml
$ halonctl queue delivery reload           # /etc/halon/smtpd-delivery.yaml
```

<a id="cli-bluegreen"></a>

<a id="blue-green-testing"></a>

## Blue-green testing

Halon has built-in blue-green testing, which allows you to deploy a
parallel [running configuration](config_smtpd.html.md) for only a selection of the
traffic, for example connections from certain IP addresses or a certain percentage
chosen by random. The following example will deploy a parallel configuration
for 10% of connecting clients during one hour:

```console
$ halonctl config livestage start --id t1 --file dist/smtpd-app.yaml --probability 0.1 --time 3600
$ halonctl config livestage status
t1: 2 connections(s), 30/3600 runtime
$ halonctl config livestage cancel
```

<a id="remote-configuration"></a>

## Remote configuration

The `halonconfig` script can be used to pack and validate configuration
folders on any computer that runs Python. You can copy it from the MTA:

```console
$ python -m venv env
$ source env/bin/activate
$ pip install pyyaml
$ pip install jsonschema
$ scp mta:/opt/halon/bin/halonconfig .
$ scp mta:/opt/halon/share/json-schemas json
```

and run it by specifying the JSON schema path and disabling the script linter:

```console
$ python halonconfig --schema-dir json --no-check-hsl
```

You can start a live stage directly from a remote computer by using SSH stdin redirection:

```console
$ cat dist/smtpd-app.yaml | ssh mta "halonctl config livestage start --file /dev/stdin --id t2"
$ ssh mta "halonctl config livestage status"
t2: 2 connections(s), 3 runtime
```
