summaryrefslogtreecommitdiff
path: root/data/templates/rsyslog/rsyslog.conf.j2
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-05-08 21:27:14 +0200
committerChristian Breunig <christian@breunig.cc>2023-05-08 22:45:53 +0200
commit1dc79cebc6d27a8f9d2f9ca9c2e0f2fd0809d940 (patch)
tree74b294e319ebad8c046756e91ce0f17a32fdcb3e /data/templates/rsyslog/rsyslog.conf.j2
parent43b4d30ed0298565ce7cf891fbd72c5a7484dac6 (diff)
downloadvyos-1x-1dc79cebc6d27a8f9d2f9ca9c2e0f2fd0809d940.tar.gz
vyos-1x-1dc79cebc6d27a8f9d2f9ca9c2e0f2fd0809d940.zip
syslog: T2778: migrate to get_config_dict()
Diffstat (limited to 'data/templates/rsyslog/rsyslog.conf.j2')
-rw-r--r--data/templates/rsyslog/rsyslog.conf.j271
1 files changed, 71 insertions, 0 deletions
diff --git a/data/templates/rsyslog/rsyslog.conf.j2 b/data/templates/rsyslog/rsyslog.conf.j2
new file mode 100644
index 000000000..0460ae5f0
--- /dev/null
+++ b/data/templates/rsyslog/rsyslog.conf.j2
@@ -0,0 +1,71 @@
+### Autogenerated by system-syslog.py ###
+
+{% if global.marker is vyos_defined %}
+$ModLoad immark
+{% if global.marker.interval is vyos_defined %}
+$MarkMessagePeriod {{ global.marker.interval }}
+{% endif %}
+{% endif %}
+{% if global.preserve_fqdn is vyos_defined %}
+$PreserveFQDN on
+{% endif %}
+
+# We always log to /var/log/messages
+$outchannel global,/var/log/messages,262144,/usr/sbin/logrotate {{ logrotate }}
+{% if global.facility is vyos_defined %}
+{% set tmp = [] %}
+{% for facility, facility_options in global.facility.items() %}
+{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level) %}
+{% endfor %}
+{{ tmp | join(';') }} :omfile:$global
+{% endif %}
+
+{% if file is vyos_defined %}
+# File based configuration section
+{% for file_name, file_options in file.items() %}
+$outchannel {{ file_name }},/var/log/user/{{ file_name }},{{ file_options.archive.size }},/usr/sbin/logrotate {{ logrotate }}
+{% set tmp = [] %}
+{% for facility, facility_options in file_options.facility.items() %}
+{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level) %}
+{% endfor %}
+{{ tmp | join(';') }} :omfile:${{ file }}
+{% endfor %}
+{% endif %}
+
+{% if console.facility is vyos_defined %}
+# Console logging
+{% set tmp = [] %}
+{% for facility, facility_options in console.facility.items() %}
+{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level) %}
+{% endfor %}
+{{ tmp | join(';') }} /dev/console
+{% endif %}
+
+{% if host is vyos_defined %}
+# Remote logging
+{% for host_name, host_options in host.items() %}
+{% set tmp = [] %}
+{% for facility, facility_options in host_options.facility.items() %}
+{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level) %}
+{% endfor %}
+{% if host_options.protocol is vyos_defined('tcp') %}
+{% if host_options.oct_count is vyos_defined %}
+{{ tmp | join(';') }} @@(o){{ host_name | bracketize_ipv6 }}:{{ host_options.port }};RSYSLOG_SyslogProtocol23Format
+{% else %}
+{{ tmp | join(';') }} @@{{ host_name | bracketize_ipv6 }}:{{ host_options.port }}
+{% endif %}
+{% else %}
+{{ tmp | join(';') }} @{{ host_name | bracketize_ipv6 }}:{{ host_options.port }}{{ ';RSYSLOG_SyslogProtocol23Format' if host_options.format.octet_counted is vyos_defined }}
+{% endif %}
+{% endfor %}
+{% endif %}
+
+{% if user is defined and user is not none %}
+# Log to user terminal
+{% for username, user_options in user.items() %}
+{% for facility, facility_options in user_options.facility.items() %}
+{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level) %}
+{% endfor %}
+{{ tmp | join(';') }} :omusrmsg:{{ username }}
+{% endfor %}
+{% endif %}