added logging config template and updated config template

This commit is contained in:
muppeth 2022-05-14 00:01:09 +02:00
parent a77b9b3c88
commit c6a9fb87ef
Signed by: muppeth
GPG Key ID: 0EBC7B9848D04031
4 changed files with 101 additions and 16 deletions

View File

@ -28,7 +28,7 @@ lacre_mail_templates: '{{ lacre_homedir }}/register_templates'
lacre_webpanel_url: 'http://example.org'
lacre_notification_email: 'gpg-mailgate@example.org'
lacre_mail_templates: '{{ lacre_homedir }}/cron_templates'
lacre_verbose: 'yes'
lacre_logfile: '/etc/gpg-lacre-logging.conf'
lacre_relay: '127.0.0.1'
lacre_port: '10028'
lacre_enc_port: '25'
@ -40,6 +40,22 @@ lacre_db_host: 'localhost'
lacre_db_username: 'user'
lacre_db_password: 'password'
#lacre logger
lacre_log_loggers_keys: 'root'
lacre_log_logger_level: 'NOTSET'
lacre_logger_handlers: 'syslog'
lacre_log_handlers_keys: 'syslog'
lacre_log_formatters: 'postfixfmt'
lacre_log_handler: 'FileHandler'
lacre_log_level: 'DEBUG'
lacre_log_formatter: 'postfixfmt'
lacre_log_syslog_class: 'handlers.SysLogHandler'
lacre_log_syslog_level: 'INFO'
lacre_log_syslog_formatter: 'postfixfmt'
lacre_log_postfix_format: '%(asctime)s %(module)s[%(process)d]: %(message)s'
lacre_log_postfix_datefmt: '%b %e %H:%M:%S'
lacre_log_postfix_style: '%'
lacre_log_postfix_validate: 'True'
#lacre webgate
lacre_smtp_enabled: 'false'
lacre_smtp_username: 'no-reply'

View File

@ -4,10 +4,18 @@
template:
src: 'etc/gpg-mailgate.conf.j2'
dest: '/etc/gpg-mailgate.conf'
owner: root
group: root
owner: '{{ lacre_username }}'
group: '{{ lacre_group }}'
mode: 0644
- name: '[LACRE] - Configure lacre logger'
template:
src: 'etc/gpg-lacre-logging.conf.j2'
dest: '/etc/gpg-lacre-logging.conf'
owner: '{{ lacre_userame }}'
group: '{{ lacre_group }}'
mode: 0644
- name: '[LACRE] - Add lacre config to postfix'
blockinfile:
dest: '/etc/postfix/master.cf'

View File

@ -0,0 +1,58 @@
# Example configuration for Lacre logging. If you don't intend to change the
# log format, you can just keep this file unchanged.
# HANDLERS:
#
# Two main targets for log entries are defined here: syslog and a plain text
# log file. They are available as "handlers" named "syslog" and "lacrelog"
# respectively.
[loggers]
keys={{ lacre_log_loggers_keys }}
[logger_root]
level={{ lacre_log_logger_level }}
# Comma-separated handler names, see HANDLERS note at the top.
handlers={{ lacre_logger_handlers }}
[handlers]
# Comma-separated handler names, see HANDLERS note at the top.
keys={{ lacre_log_handlers_keys }}
[formatters]
keys={{ lacre_log_formatters }}
#
# By default, include messages from all log levels up to DEBUG.
# However, productive systems may use something less verbose, like
# WARN or even ERROR.
#
[handler_lacrelog]
class={{ lacre_log_handler }}
level={{ lacre_log_level }}
formatter={{ lacre_log_formatter }}
args=('test/logs/lacre.log', 'a+')
# You may want to change the second argument (handlers.SysLogHandler.LOG_MAIL)
# to change the syslog facility used to record messages from Lacre.
#
# Options you can consider are "localX" facilities, available under names from
# handlers.SysLogHandler.LOG_LOCAL0 to handlers.SysLogHandler.LOG_LOCAL7.
#
# Please refer to your syslog configuration for details on how to separate
# records from different facilities.
[handler_syslog]
class={{ lacre_log_syslog_class }}
level={{ lacre_log_syslog_level }}
formatter={{ lacre_log_syslog_formatter }}
args=('/dev/log', handlers.SysLogHandler.LOG_MAIL)
#
# Default Postfix log format.
#
[formatter_postfixfmt]
format={{ lacre_log_postfix_format }}
datefmt={{ lacre_log_postfix_datefmt }}
style={{ lacre_log_postfix_style }}
validate={{ lacre_log_postfix_validate }}

View File

@ -65,19 +65,11 @@ send_email = yes
notification_email = {{ lacre_notification_email }}
mail_templates = {{ lacre_mail_templates }}
[smtp]
# Settings for sending emails from your configured smtp server
enabled = {{ lacre_smtp_enabled }}
username = {{ lacre_smtp_username }}
password = {{ lacre_smtp_password }}
host = {{ lacre_smtp_host }}
port = {{ lacre_smtp_port }}
starttls = {{ lacre_smtp_starttls }}
[logging]
# For logging to syslog. 'file = syslog', otherwise use path to the file.
file = syslog
verbose = {{ lacre_verbose }}
[logging]
# path to the logging configuration; see documentation for details:
# https://docs.python.org/3/library/logging.config.html#logging-config-fileformat
config = {{ lacre_logfile }
[relay]
# the relay settings to use for Postfix
@ -92,13 +84,24 @@ enc_port = {{ lacre_enc_port }}
# Set this option to yes to use TLS for SMTP Servers which require TLS.
starttls = {{ lacre_starttls }}
[smtp]
# Options when smtp auth is required to send out emails
enabled = {{ lacre_smtp_enabled }}
username = {{ lacre_smtp_username }}
password = {{ lacre_smtp_password }}
host = {{ lacre_smtp_host }}
port = {{ lacre_smtp_port }}
starttls = {{ lacre_smtp_starttls }}
[database]
{% if lacre_db_backend == 'sqlite' %}
url = sqlite://{{ lacre_db_name }}
{% endif %}
{% if lacre_db_backend == 'mysql' %}
url = url = mysql://{{ lacre_db_username }}:{{ lacre_db_password }}@{{ lacre_db_host }}/{{ lacre_db_name }}
url = mysql://{{ lacre_db_username }}:{{ lacre_db_password }}@{{ lacre_db_host }}/{{ lacre_db_name }}
{% endif %}
[enc_keymap]
# You can find these by running the following command:
# gpg --list-keys --keyid-format long user@example.com