rsyslog icon indicating copy to clipboard operation
rsyslog copied to clipboard

remote.conf not removed when remote-servers list becomes empty

Open bish0polis opened this issue 5 years ago • 5 comments

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:

  1. 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\"}\]}})'
  1. 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.

bish0polis avatar Mar 09 '19 07:03 bish0polis

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

bish0polis avatar Mar 09 '19 07:03 bish0polis

https://github.com/gesinc-com/rsyslog/commit/43371ea071174613ed1805adf18179a8be29f368

bish0polis avatar Mar 09 '19 07:03 bish0polis

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.

github-actions[bot] avatar Oct 22 '20 00:10 github-actions[bot]

But there's a patch RIGHT THERE!

bish0polis avatar Oct 22 '20 05:10 bish0polis

@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.

ramereth avatar Oct 22 '20 17:10 ramereth