nagios icon indicating copy to clipboard operation
nagios copied to clipboard

stop_apache attribute is not being respected

Open jasmeralia opened this issue 6 years ago • 1 comments

Cookbook version

8.0.0

Chef-client version

13.3.42

Platform Details

bento/ubuntu-14.04

Scenario:

I'm using the nagios cookbook to write out the various configuration files for my environment, but I have a few tweaks as I'm actually then loading those configs into Shinken running inside a Docker container. After updating the newest cookbook version while testing Chef 13 fixes, I'm hitting an issue where it tries to stop the apache service because I am using nginx, even though I have node['nagios']['server']['stop_apache'] set to false. Looking at the code there does not seem to be any guards around this:

service node['apache']['service_name'] do
  action [:disable, :stop]
  notifies :start, 'service[nginx]', :delayed
  notifies :restart, 'service[nagios]', :delayed
end

This is problematic, as Apache processes are seen on the host, but running inside the container, so trying to stop Apache throws this error: There are processes named 'apache2' running which do not match your pid file which are left untouched in the name of safety, Please review the situation by hand.

Expected Result:

The cookbook does not try to stop the Apache service.

Actual Result:

================================================================================
Error executing action `stop` on resource 'service[apache2]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /etc/init.d/apache2 stop ----
STDOUT: * Stopping web server apache2
* 
* There are processes named 'apache2' running which do not match your pid file which are left untouched in the name of safety, Please review the situation by hand.
STDERR: 
---- End output of /etc/init.d/apache2 stop ----
Ran /etc/init.d/apache2 stop returned 1
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/nagios/recipes/nginx.rb
 
117: service node['apache']['service_name'] do
118:   action [:disable, :stop]
119:   notifies :start, 'service[nginx]', :delayed
120:   notifies :restart, 'service[nagios]', :delayed
121: end
122: 
 
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/nagios/recipes/nginx.rb:117:in `from_file'
 
service("apache2") do
  action [:disable, :stop]
  default_guard_interpreter :default
  service_name "apache2"
  enabled false
  running true
  masked nil
  pattern "apache2"
  declared_type :service
  cookbook_name "nagios"
  recipe_name "nginx"
end
 
System Info:
------------
chef_version=13.3.42
platform=ubuntu
platform_version=14.04
ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
program_name=chef-client worker: ppid=18625;start=20:56:11;
executable=/opt/chef/bin/chef-client

jasmeralia avatar Sep 19 '17 21:09 jasmeralia

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 Sep 30 '20 00:09 github-actions[bot]