rsyslog
rsyslog copied to clipboard
remote.conf not removed when remote-servers list becomes empty
Cookbook version
6.0.8 + #152
Chef-client version
chef-14.10.9-1.el7.x86_64
Platform Details
rpm -qf /etc/issue
centos-release-7-6.1810.2.el7.centos.x86_64
Scenario:
As rsyslog servers drop to 0 members in the list, the 49-remote.conf is not removed.
Steps to Reproduce:
- with the search confirmed empty, throw an IP in to invoke the template instantiation:
knife ssh testmonkey \
-- \
chef-client -W -o rsyslog::client \
-j '<(echo {\"rsyslog\":{\"custom_remote\":\[{\"server\":\"10.10.4.4\"}\]}})'
- and then again without the forced value:
knife ssh testmonkey \
-- \
chef-client -W -o rsyslog::client
Expected Result:
Remote.conf file should be removed to reflect empty forward-server list.
Actual Result:
Nothing: file is not changed nor removed.
Oh wow! It's a patch!!
Indentation around the template wasn't changed, specifically so the minimal change would be clear. Feel free to re-indent for sanity.
--- a/recipes/client.rb
+++ b/recipes/client.rb
@@ -49,7 +49,9 @@ end
if rsyslog_servers.empty?
Chef::Log.warn('The rsyslog::client recipe was unable to determine the remote syslog server. Checked both the server_ip attribute\
and search! Not forwarding logs.')
-else
+end
+
+# create or delete config as appropriate
remote_type = node['rsyslog']['use_relp'] ? 'relp' : 'remote'
template "#{node['rsyslog']['config_prefix']}/rsyslog.d/49-remote.conf" do
source "49-#{remote_type}.conf.erb"
@@ -60,6 +62,7 @@ else
notifies :run, 'execute[validate_config]'
notifies :restart, "service[#{node['rsyslog']['service_name']}]"
only_if { node['rsyslog']['remote_logs'] }
+ action rsyslog_servers.empty? ? :delete : :create
end
file "#{node['rsyslog']['config_prefix']}/rsyslog.d/server.conf" do
@@ -67,4 +70,3 @@ else
notifies :run, 'execute[validate_config]'
notifies :restart, "service[#{node['rsyslog']['service_name']}]"
end
-end
https://github.com/gesinc-com/rsyslog/commit/43371ea071174613ed1805adf18179a8be29f368
Marking stale due to inactivity. Remove stale label or comment or this will be closed in 7 days. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.
But there's a patch RIGHT THERE!
@bish0polis this cookbook was recently transferred to the Sous Chefs and this bot was part of the standardization process. Rest assured, we'll get to this soon once we get this properly adopted.