Dynatrace / Dynatrace-AppMon-Chef

Installs the Dynatrace Application Monitoring solution using Chef.
MIT License
12 stars 15 forks source link

wsagent_package #25

Closed tobymaro closed 7 years ago

tobymaro commented 7 years ago

Hello,

Recently were corrected recipes for collector and server. Could you please correct recipe for wsagent_package to use it with cron? For now it restarts agent and apache server every run.

pozieblo commented 7 years ago

Please look at commit 8746708a4906860479a348baf032a5bb097773ea on master branch. We will make an official release later on.

tobymaro commented 7 years ago

Hi,

Thank You, could you please take a look on apache_wsagent.rb as well? There is the same situation. I didn't mention it. Actually I use apache_wsagent.rb that includes wsagent_package.rb.

pozieblo commented 7 years ago

Yes, we are working on that. The fix should be ready by tomorrow.

pozieblo commented 7 years ago

The fix is ready in commit 6e18751244. Please note that a new dependency to the 'line' cookbook has been added so Berkshelf has to be launched before trying to launch the recipes

tobymaro commented 7 years ago

Hi, apache_wsagent.rb still restarts httpd service every run. I see it in chef log.

Recipe: dynatrace::apache_wsagent
  * service[httpd] action restart
    - restart service service[httpd]

just to check i changed action on reload and got

Recipe: dynatrace::apache_wsagent
  * service[httpd] action reload
    - reload service service[httpd]

Looks like "replace_or_add" is changed every run. Could you please check?

pozieblo commented 7 years ago

I tried to reproduce the issue and it appears only when executing apache2 and dynatrace::apache_wsagent recipes in the same Chef run. The apache2 recipe will overwrite the httpd.conf file each time it is run.

           - update content in file /etc/httpd/conf/httpd.conf from 836a66 to 928919
           --- /etc/httpd/conf/httpd.conf   2016-12-06 15:37:07.791313681 +0000
           +++ /etc/httpd/conf/.chef-apache2.conf20161206-10101-1bskw4w 2016-12-06 15:38:56.677726012 +0000

In that case it is normal that the service is restarted as the httpd.conf needs to be patched. The only potential enhancement would be to reload the service instead of restarting it... Assuming the apache server is already installed, and the apache_wsagent is launched the second time there should be no httpd service restart, at least I do not observe it (I tried on Centos-6 and Ubuntu 12.04). If the issue is still occurring please provide more details about your setup (specifically the target system, the recipes that are being run and logs from Chef execution).

tobymaro commented 7 years ago

Hi, Got it, thank for investigation. i found another way to add the module. I load the module using a bit another way. Maybe it will help someone with the same issue:

I redefined attribute 'apache_config_file_path' and added new one 'apache_config_file_link'

apache_config_file_path = node['dynatrace']['apache_wsagent']['apache']['config_folder'] + '/mods-available/agent_dynatrace.load'
apache_config_file_link = node['dynatrace']['apache_wsagent']['apache']['config_folder'] + '/mods-enabled/agent_dynatrace.load

and before resource 'replace_or_add' i added 2 new resources

file apache_config_file_path do
  owner 'root'
  group 'root'
  mode '0644'
end

link apache_config_file_link do
  to apache_config_file_path
  mode '0777'
end

Works well. Issue can be closed.

pozieblo commented 7 years ago

Actually, in case of running apache2 and dynatrace::apache_wsagent recipes in the same run list it would be enough to override the node['dynatrace']['apache_wsagent']['linux']['apache_daemon'] attribute and set its value to an empty string (see apache_wsagent test in .kitchen.yml). The apache2 cookbook always defers apache service restart to the end of a run list so changes done by our recipe would be taken into account anyway.