1
0
Fork 0
mirror of https://github.com/librenms/docker.git synced 2026-01-23 02:14:48 +00:00

YAML based config (#225)

This commit is contained in:
Tony Murray 2022-07-14 23:23:36 -05:00 committed by GitHub
parent d9dab05eb0
commit 9c30554e81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 43 deletions

View file

@ -37,8 +37,12 @@ ___
* [Command line](#command-line)
* [First launch](#first-launch)
* [Upgrade](#upgrade)
* [Configuration Management](#configuration-management)
* [Initial Configuration](#initial-configuration)
* [Live Configuration](#live-configuration)
* [Re-Apply YAML Config](#re-apply-yaml-config)
* [Live Config](#live-config)
* [Notes](#notes)
* [Edit configuration](#edit-configuration)
* [LNMS command](#lnms-command)
* [Validate](#validate)
* [Dispatcher service container](#dispatcher-service-container)
@ -260,13 +264,40 @@ $ docker-compose pull
$ docker-compose up -d
```
## Notes
## Configuration Management
### Edit configuration
### Initial Configuration
You can edit configuration of LibreNMS by placing `*.php` files inside
`/data/config` folder. Let's say you want to edit the [WebUI config](https://docs.librenms.org/Support/Configuration/#webui-settings).
Create a file called for example `/data/config/webui.php` with this content:
You can set the initial configuration of LibreNMS by placing `*.yaml` files inside `/data/config` folder. Let's say you want to edit the [WebUI config](https://docs.librenms.org/Support/Configuration/#webui-settings).
Create a file called for example `/data/config/webui.yaml` with this content :
```yaml
page_refresh: 300
webui.default_dashboard_id: 0
```
This configuration will be seeded into the LibreNMS database when it is first deployed
and will override the default values.
### Live Configuration
You can edit the running configuration via the LibreNMS web UI or `lnms config:set`
```bash
docker-compose exec librenms lnms config:set page_refresh 300
```
### Re-Apply YAML Config
Set `REAPPLY_YAML_CONFIG=1` to overwrite any settings that are set during initial config
or via user config back to their initial values every time the container is deployed.
### Live Config
Using this config method, configuration changes will be reflected live on the containers, BUT
you will be unable to edit the configured settings from within the LibreNMS web UI or lnms config:set.
The same example using PHP `/data/config/webui.php`
```php
<?php
@ -274,8 +305,7 @@ $config['page_refresh'] = "300";
$config['webui']['default_dashboard_id'] = 0;
```
This configuration will be included in LibreNMS and will override the default
values.
## Notes
### LNMS command
@ -352,11 +382,10 @@ $ docker run -d --name librenms_syslog \
> `librenms` must be a valid volume already attached to a LibreNMS container.
You have to create a configuration file to enable syslog in LibreNMS too. Create
a file called for example `/data/config/syslog.php` with this content:
a file called for example `/data/config/syslog.yaml` with this content :
```php
<?php
$config['enable_syslog'] = 1;
```yaml
enable_syslog: true
```
### Snmptrapd container

View file

@ -117,68 +117,63 @@ DB_PASSWORD=${DB_PASSWORD}
EOL
# Config : Directories
cat >${LIBRENMS_PATH}/config.d/directories.php <<EOL
<?php
\$config['install_dir'] = '${LIBRENMS_PATH}';
\$config['log_dir'] = '/data/logs';
\$config['rrd_dir'] = '/data/rrd';
cat >${LIBRENMS_PATH}/database/seeders/config/directories.yaml <<EOL
install_dir: '${LIBRENMS_PATH}'
log_dir: /data/logs
rrd_dir: /data/rrd
EOL
ln -sf /data/logs ${LIBRENMS_PATH}/logs
# Config : Server
cat >${LIBRENMS_PATH}/config.d/server.php <<EOL
<?php
\$config['own_hostname'] = '$(hostname)';
\$config['base_url'] = '${LIBRENMS_BASE_URL}';
cat >${LIBRENMS_PATH}/database/seeders/config/server.yaml <<EOL
own_hostname: '$(hostname)'
base_url: '${LIBRENMS_BASE_URL}'
EOL
# Config : User
cat >${LIBRENMS_PATH}/config.d/user.php <<EOL
<?php
\$config['user'] = "librenms";
\$config['group'] = "librenms";
cat >${LIBRENMS_PATH}/database/seeders/config/user.yaml <<EOL
user: librenms
group: librenms
EOL
# Config : Fping
cat >${LIBRENMS_PATH}/config.d/fping.php <<EOL
<?php
\$config['fping'] = "/usr/sbin/fping";
\$config['fping6'] = "/usr/sbin/fping6";
cat >${LIBRENMS_PATH}/database/seeders/config/fping.yaml <<EOL
fping: /usr/sbin/fping
fping6: /usr/sbin/fping6
EOL
# Config : ipmitool
cat >${LIBRENMS_PATH}/config.d/ipmitool.php <<EOL
<?php
\$config['ipmitool'] = "/usr/sbin/ipmitool";
cat >${LIBRENMS_PATH}/database/seeders/config/ipmitool.yaml <<EOL
ipmitool: /usr/sbin/ipmitool
EOL
# Config : Disable autoupdate
# Config : Disable autoupdate (set in config.php so it cannot be overridden in the webui)
cat >${LIBRENMS_PATH}/config.d/autoupdate.php <<EOL
<?php
\$config['update'] = 0;
EOL
# Config : Services
cat >${LIBRENMS_PATH}/config.d/services.php <<EOL
<?php
\$config['show_services'] = 1;
\$config['nagios_plugins'] = "/usr/lib/monitoring-plugins";
cat >${LIBRENMS_PATH}/database/seeders/config/services.yaml <<EOL
show_services: true
nagios_plugins: /usr/lib/monitoring-plugins
EOL
# Config : RRDcached
# Config : RRDCached, apply RRDCACHED_SERVER as php as it would be expected to change with the variable
if [ -n "${RRDCACHED_SERVER}" ]; then
cat >${LIBRENMS_PATH}/config.d/rrdcached.php <<EOL
<?php
\$config['rrdcached'] = "${RRDCACHED_SERVER}";
\$config['rrdtool_version'] = "1.7.2";
EOL
cat >${LIBRENMS_PATH}/database/seeders/config/rrdcached.yaml <<EOL
rrdtool_version: "1.7.2"
EOL
fi
# Config : Dispatcher
cat >${LIBRENMS_PATH}/config.d/dispatcher.php <<EOL
<?php
\$config['service_update_enabled'] = false;
\$config['service_watchdog_enabled'] = false;
cat >${LIBRENMS_PATH}/database/seeders/config/dispatcher.yaml <<EOL
service_update_enabled: false
service_watchdog_enabled: false
EOL
# Check plugins