sous-chefs / rsyslog

Development repository for the rsyslog cookbook
https://supermarket.chef.io/cookbooks/rsyslog
Apache License 2.0
65 stars 199 forks source link

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

Open bish0polis opened 5 years ago

bish0polis commented 5 years ago

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\"}\]}})'
  2. 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 commented 5 years ago

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 commented 5 years ago

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

github-actions[bot] commented 4 years ago

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.

bish0polis commented 4 years ago

But there's a patch RIGHT THERE!

ramereth commented 4 years ago

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