WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

systemd service should match configured command_file location #565

@sspans

Description

@sspans

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workinghacktoberfestAn issue highlighted for the digital ocean Hacktoberfest Event

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions