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

# Configuration export

For persistent processing and routing of email, the configuration export function can export all
domains, users, and settings from MSUI to a single YAML file (*msui-config.yaml*).
This file will then be copied over to each Halon node to `/etc/halon/msui-config.yaml` using **SCP**.
And finally it will compare both the source and destination file for any changes, and reload Halon’s configuration if necessary.

With the MSUI client plugin you can then import the YAML file into any HSL script, for more information check out the [integration](integration.html.md) section.

> **Note**
> 
> Ansible has to be installed on the same server running MSUI.

<a id="configure-msui"></a>

## Configure MSUI

Below is an example of `msui.yaml`, with configuration export enabled. It will copy over the `msui-config.yaml` file to two Halon nodes.

```yaml
servers:
  - id: default
    [...]
    app:
      configexport:
        enabled: true
        interval: 900
        nodes:
          - address: halon@10.0.0.1
          - address: halon@10.0.0.2
```

Upon installation of MSUI, a SSH key-pair will be generated and saved to  the following paths:

> - `/etc/halon/msui-export-ssh-key`
> - `/etc/halon/msui-export-ssh-key.pub`

This key-pair will then be used for authentication by the configuration export function when coping over the `msui-config.yaml` file to each Halon node.

The `/etc/halon/msui-export-ssh-key.pub` needs to be added to each Halon node under the `~/.ssh/authorized_keys`.
In the example above it uses the *halon* user for authentication, the public key should then be added to this user’s `authorized_keys` file.

After the configuration has been saved MSUI will, using Ansible, try to export the `msui-config.yaml` file to the nodes specified in the config. The Ansible output from the logs will provide information stating which changes have been made:

```console
PLAY RECAP *********************************************************************
halon@10.0.0.1 : ok=4 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
[Configuration Export] 2024-06-13 09:35:32 Done after 2.55 seconds
```

<a id="configuration-export-directives"></a>

## Configuration export directives

<a id="confval-servers-.app.configexport"></a>

### servers[].app.configexport

The configuration export settings.

<a id="confval-servers-.app.configexport.enabled"></a>

### servers[].app.configexport.enabled

Enables or disables the export function (*true* or *false*).

<a id="confval-servers-.app.configexport.includepasswords"></a>

### servers[].app.configexport.includepasswords

Includes users hashed passwords in the exported data.

<a id="confval-servers-.app.configexport.interval"></a>

### servers[].app.configexport.interval

Set an interval (in seconds) how often the export should run (min 60 seconds).

<a id="confval-servers-.app.configexport.nodes"></a>

### servers[].app.configexport.nodes[]

A list of hosts that ansible will copy files to over SSH.

<a id="confval-servers-.app.configexport.nodes-.address"></a>

### servers[].app.configexport.nodes[].address

The SSH address (eg. [halon@10.0.0.1](mailto:halon@10.0.0.1)).

<a id="confval-servers-.app.configexport.nodes-.args"></a>

### servers[].app.configexport.nodes[].args

Additional key-value arguments for ansible playbook.

> **Note**
> 
> You can change the default destination path for each host by setting the **remote_path** argument.
> 
> ```yaml
> - address: halon@10.0.0.1
>   args:
>     "remote_path": "/new/path/halon/"
> ```
