From 4400077a901e4fbf2ce66196f258eddc1d96d602 Mon Sep 17 00:00:00 2001 From: Wolfgang Jung Date: Tue, 29 Mar 2022 22:10:01 +0200 Subject: [PATCH] Enables logging to syslog if openvpn_log_file is not set --- README.md | 12 ++++++------ templates/server.conf.j2 | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b0d2e01a..27d1cc96 100644 --- a/README.md +++ b/README.md @@ -136,13 +136,13 @@ These options change how OpenVPN itself works. | openvpn_client_config_dir | string | | ccd | Path of `client-config-dir` | | openvpn_client_configs | dict | | {} | Dict of settings custom client configs | -## Logrotate +## Logrotate/Syslog Set your own custom logrotate options -| Variable | Type | Choices | Default | Comment | -|--------------------------|--------|---------|-------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------| -| openvpn_log_dir | string | | /var/log | Set location of openvpn log files. This parameter is a part of `log-append` configuration value. | -| openvpn_log_file | string | | openvpn.log | Set log filename. This parameter is a part of `log-append` configuration value. | -| openvpn_logrotate_config | string | | rotate 4
weekly
missingok
notifempty
sharedscripts
copytruncate
delaycompress | Configure logrotate script. | +| Variable | Type | Choices | Default | Comment | +|--------------------------|--------|---------|-------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------| +| openvpn_log_dir | string | | /var/log | Set location of openvpn log files. This parameter is a part of `log-append` configuration value. | +| openvpn_log_file | string | | openvpn.log | Set log filename. This parameter is a part of `log-append` configuration value. If empty, syslog is used. | +| openvpn_logrotate_config | string | | rotate 4
weekly
missingok
notifempty
sharedscripts
copytruncate
delaycompress | Configure logrotate script. | ## Packaging This role pulls in a bunch of different packages. Override the names as necessary. diff --git a/templates/server.conf.j2 b/templates/server.conf.j2 index 09b2c547..b430164e 100644 --- a/templates/server.conf.j2 +++ b/templates/server.conf.j2 @@ -91,7 +91,12 @@ group {{ openvpn_service_group }} status status-{{ openvpn_config_file }}.log status-version {{ openvpn_status_version }} + +{% if openvpn_log_file is defined %} log-append {{ openvpn_log_dir }}/{{ openvpn_log_file }} +{% else %} +syslog openvpn +{% endif %} verb 3 {% if openvpn_verify_cn|bool %}