dev
diff --git a/rsyslog/common.sls b/rsyslog/common.sls
index 9aa108e..51d814d 100644
--- a/rsyslog/common.sls
+++ b/rsyslog/common.sls
@@ -1,19 +1,28 @@
-{%- from "rsyslog/map.jinja" import client,server with context %}
+{%- from "rsyslog/map.jinja" import client,server,common with context %}
-{%- if server.enabled %}
+{%- if common.enabled %}
rsyslog_packages:
pkg.latest:
- - names: {{ server.pkgs }}
+ - names: {{ common.pkgs }}
/etc/rsyslog.conf:
file.managed:
- - source: salt://rsyslog/files/rsyslog.conf.{{ grains.os_family }}
+ - source: salt://rsyslog/files/rsyslog.default.conf
- template: jinja
- mode: 0640
- require:
- pkg: rsyslog_packages
+/etc/rsyslog.d:
+ file.directory:
+ - mode: 0755
+ - require:
+ - pkg: rsyslog_packages
+ {% if common.purge_rsyslog_d is defined and common.purge_rsyslog_d == true %}
+ - clean: true
+ {% endif %}
+
/etc/rsyslog.d/50-default.conf:
file.managed:
- source: salt://rsyslog/files/default.conf
@@ -29,7 +38,8 @@
- watch:
- file: /etc/rsyslog.conf
-{% for output,type in server.output.file.iteritems() %}
+{% if common.manage_file_perms is defined and common.manage_file_perms == true %}
+{% for output,type in common.output.file.iteritems() %}
{{ output }}:
file.managed:
- mode: "{{ type['createmode'] }}"
@@ -40,5 +50,6 @@
- watch_in:
- service: rsyslog_service
{% endfor %}
+{% endif %}
{%- endif %}
diff --git a/rsyslog/files/default.conf b/rsyslog/files/default.conf
deleted file mode 100644
index 2824135..0000000
--- a/rsyslog/files/default.conf
+++ /dev/null
@@ -1,28 +0,0 @@
-{%- from "rsyslog/map.jinja" import client,server with context -%}
-{%- for name,config in server.output.file.iteritems() %}
-{% if config.owner is defined %}
-$FileOwner: {{ config['owner'] }}
-{% endif %}
-{% if config.group is defined %}
-$FileGroup: {{ config['group'] }}
-{% endif %}
-{% if config.createmode is defined %}
-$FileCreateMode: "{{ config['createmode'] }}"
-{% endif %}
-{% if config.umask is defined %}
-$Umask: "{{ config['umask'] }}"
-{% endif %}
-{{ config['filter'] }} {% if config.sync == true %}-{% endif %}{{ name }}
-{% endfor %}
-
-{% if server.output.console is defined %}
-{% for name,config in server.output.console.iteritems() %}
-{{ config['filter'] }} {{ config['action'] }}
-{% endfor %}
-{% endif %}
-
-{% if server.output.remote is defined %}
-{% for name,config in server.output.console.iteritems() %}
-{{ config['filter'] }} {{ config['action'] }}
-{% endfor %}
-{% endif %}
diff --git a/rsyslog/files/rsyslog.default.conf b/rsyslog/files/rsyslog.default.conf
new file mode 100644
index 0000000..a67f94d
--- /dev/null
+++ b/rsyslog/files/rsyslog.default.conf
@@ -0,0 +1,68 @@
+{%- from "rsyslog/map.jinja" import client,server,common with context -%}
+
+{% if common.preserve_fqdn is defined and preserve_fqdn == true %}
+$PreserveFQDN
+{% endif %}
+
+{% if common.non_kernel_facility is defined and common.non_kernel_facility == true %}
+$KLogPermitNonKernelFacility on
+{% endif %}
+
+{% if common.omit_local_logging is defined and common.omit_local_logging == true %}
+$OmitLocalLogging on
+{% endif %}
+
+{% if common.msg_reduction == true %}
+$RepeatedMsgReduction on
+{% endif %}
+
+{% if common.max_message_size is defined %}
+$MaxMessageSize {{ common.max_message_size }}
+{% endif %}
+
+{% if common.system_log_rate_limit_interval is defined %}
+$SystemLogRateLimitInterval {{ common.system_log_rate_limit_interval }}
+{% endif %}
+
+{% if common.system_log_rateLimit_burst is defined %}
+$SystemLogRateLimitBurst {{ common.system_log_rateLimit_burst }}
+{% endif %}
+
+{% for modname in common.module %}
+$ModLoad {{ modname }}
+{% endfor %}
+
+$DirCreateMode {{ common.perm_dir }}
+$PrivDropToUser {{ common.run_user }}
+$PrivDropToGroup {{ common.run_group }}
+$WorkDirectory {{ common.spool_dir }}
+
+$IncludeConfig {{ common.rsyslog_d }}/*.conf
+
+{%- for name,config in common.output.file.iteritems() %}
+{% if config.owner is defined %}
+$FileOwner: {{ config['owner'] }}
+{% endif %}
+{% if config.group is defined %}
+$FileGroup: {{ config['group'] }}
+{% endif %}
+{% if config.createmode is defined %}
+$FileCreateMode: "{{ config['createmode'] }}"
+{% endif %}
+{% if config.umask is defined %}
+$Umask: "{{ config['umask'] }}"
+{% endif %}
+{{ config['filter'] }} {% if config.sync == true %}-{% endif %}{{ name }}
+{% endfor %}
+
+{% if common.output.console is defined %}
+{% for name,config in common.output.console.iteritems() %}
+{{ config['filter'] }} {{ config['action'] }}
+{% endfor %}
+{% endif %}
+
+{% if common.output.remote is defined %}
+{% for name,config in common.output.console.iteritems() %}
+{{ config['filter'] }} {{ config['action'] }}
+{% endfor %}
+{% endif %}
diff --git a/rsyslog/map.jinja b/rsyslog/map.jinja
index 2b141fc..4dc9e63 100644
--- a/rsyslog/map.jinja
+++ b/rsyslog/map.jinja
@@ -4,7 +4,20 @@
- rsyslog
service:
- rsyslogd
- workdirectory: /var/spool/rsyslog
+ spool_dir: /var/spool/rsyslog
+ omit_local_logging: false
+ preserve_fqdn: true
+ non_kernel_facility: true
+ msg_reduction: true
+ purge_rsyslog_d: true
+ manage_file_perms: true
+ perm_dir: "0755"
+ run_user: syslog
+ run_group: syslog
+ rsyslog_d: /etc/rsyslog.d
+ modules:
+ - imuxsock
+ - imklog
output:
file:
/var/log/syslog:
@@ -67,7 +80,16 @@
- rsyslog
service:
- rsyslogd
- workdirectory: /var/lib/rsyslog
+ spool_dir: /var/lib/rsyslog
+ omit_local_logging: true
+ preserve_fqdn: false
+ non_kernel_facility: false
+ msg_reduction: false
+ manage_file_perms: true
+ rsyslog_d: /etc/rsyslog.d
+ modules:
+ - imjournal
+ - imuxsock
output:
file:
/var/log/messages:
diff --git a/tests/pillar/client_single.sls b/tests/pillar/client_single.sls
index 87bcd6b..3e08232 100644
--- a/tests/pillar/client_single.sls
+++ b/tests/pillar/client_single.sls
@@ -2,11 +2,5 @@
client:
enabled: true
format:
- name: TraditionalFormatWithPRI
+ name: custom
template: '"%syslogpriority% %syslogfacility% %timestamp:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"'
- file:
- owner: root
- group: root
- createmode: 0640
- umask: 0022
-