Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bish0polis opened this issue Mar 9, 2019 · 5 comments
Open

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

bish0polis opened this issue Mar 9, 2019 · 5 comments
Labels
Bug Something isn't working

Comments

@bish0polis
Copy link

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
Copy link
Author

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
Copy link
Author

gesinc-com@43371ea

@github-actions
Copy link

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 github-actions bot added the Stale This is marked as stale and will be closed shortly label Oct 22, 2020
@bish0polis
Copy link
Author

But there's a patch RIGHT THERE!

@ramereth
Copy link
Contributor

@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 ramereth added Bug Something isn't working and removed Stale This is marked as stale and will be closed shortly labels Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants