Using this cookbook (v7.0.1) with Chef (16.5.77), I get the undesired behavior of NGINX logs getting logged twice in syslog and messages because the way the 35-server-per-host.conf.erb template is written.
According to NGINX docs, by default the severity is set as info, and in the 35-server-per-host.conf.erb template we can find that:
$template PerHostSyslog,"<%= node['rsyslog']['log_dir'] %>/<%= node['rsyslog']['per_host_dir'] %>/syslog"
...
$template PerHostMessages,"<%= node['rsyslog']['log_dir'] %>/<%= node['rsyslog']['per_host_dir'] %>/messages"
...
*.*;auth,authpriv.none -?PerHostSyslog
...
*.=info;*.=notice;*.=warn;\
auth,authpriv.none;\
cron,daemon.none;\
mail,news.none -?PerHostMessages
so it matches both PerHostSyslog and PerHostMessages templates.
I've found a workaround in NGINX, which is set the severity to crit so it gets only logged in syslog, but I don't really know if this is OK (my experience with rsyslog and syslog is very limited).
Would it be possible that the server.rb recipe had the source property set via attribute so we can tune it to match our specific needs? E.g:
diff --git a/recipes/server.rb b/recipes/server.rb
index 7ea0e53..0eeb0bc 100644
--- a/recipes/server.rb
+++ b/recipes/server.rb
@@ -30,7 +30,7 @@ directory node['rsyslog']['log_dir'] do
end
template "#{node['rsyslog']['config_prefix']}/rsyslog.d/35-server-per-host.conf" do
- source '35-server-per-host.conf.erb'
+ source node['rsyslog']['server-per-host-template']
owner node['rsyslog']['config_files']['owner']
group node['rsyslog']['config_files']['group']
mode node['rsyslog']['config_files']['mode']
Using this cookbook (
v7.0.1) with Chef (16.5.77), I get the undesired behavior of NGINX logs getting logged twice insyslogandmessagesbecause the way the 35-server-per-host.conf.erb template is written.According to NGINX docs, by default the
severityis set asinfo, and in the 35-server-per-host.conf.erb template we can find that:so it matches both PerHostSyslog and PerHostMessages templates.
I've found a workaround in NGINX, which is set the
severitytocritso it gets only logged insyslog, but I don't really know if this is OK (my experience withrsyslogandsyslogis very limited).Would it be possible that the server.rb recipe had the
sourceproperty set via attribute so we can tune it to match our specific needs? E.g: