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

systemd service should match configured command_file location #565

Open
sspans opened this issue Mar 19, 2018 · 1 comment
Open

systemd service should match configured command_file location #565

sspans opened this issue Mar 19, 2018 · 1 comment
Labels
Bug Something isn't working hacktoberfest An issue highlighted for the digital ocean Hacktoberfest Event

Comments

@sspans
Copy link

sspans commented Mar 19, 2018

Cookbook version

Latest

Platform Details

CentOS 7

Scenario:

The nagios command_file is partially managed via the packaged systemd service

> grep cmd  /usr/lib/systemd/system/nagios.service
ExecStopPost=/usr/bin/rm -f /var/spool/nagios/cmd/nagios.cmd

When a different command_file location is specified in the cookbook this management will break.
Resulting in a broken command_file after a nagios restart.

Steps to Reproduce:

echo '{ "nagios": { "conf": { "command_file": "/var/log/nagios/rw/nagios.cmd" } } }' | sudo chef-client -j /dev/stdin
systemctl restart nagios
/usr/lib64/nagios/plugins/eventhandlers/nagios_command STOP_EXECUTING_SVC_CHECKS

Expected Result:

A command arriving at the running nagios server

Actual Result:

Write blocks, because the command_file is broken

Possible solution

directory '/etc/systemd/system/nagios.service.d/'

file '/etc/systemd/system/nagios.service.d/command_file.conf' do
  content "[Service]\nExecStopPost=/usr/bin/rm -f #{node['nagios']['conf']['command_file']}"
  mode 0644
  notifies :run, 'execute[reload_systemd_nagios]', :immediately
end

execute 'reload_systemd_nagios' do
  command <<-EOF
    systemctl daemon-reload
  EOF
  action :nothing
end
@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 label Sep 30, 2020
@xorimabot xorimabot removed the Stale label Sep 30, 2020
@ramereth ramereth added Bug Something isn't working hacktoberfest An issue highlighted for the digital ocean Hacktoberfest Event labels Oct 4, 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 hacktoberfest An issue highlighted for the digital ocean Hacktoberfest Event
Projects
None yet
Development

No branches or pull requests

3 participants