appdynamics-cookbooks
appdynamics-cookbooks copied to clipboard
machine_agent.rb recipe: extracting -> config change -> restart on every chef run
There are some conditions missing in the remote_file agent_zip and execute 'unzip-appdynamics-machine-agent' resource. On each chef run, the ZIP file is extracted again and the configuration file is been altered. This leads to a restart of the machine agent on every chef run.
Add a condition to extract only if the ./bin directory is missing and the default action for the unzip task is nothing.
remote_file agent_zip do
source package_source
checksum agent['checksum']
backup false
mode '0444'
notifies :run, 'execute[unzip-appdynamics-machine-agent]', :immediately
end unless ::File.exist?([agent['install_dir'], '/bin'].join)
...
...
execute 'unzip-appdynamics-machine-agent' do
cwd agent['install_dir']
command "unzip -qqo #{agent_zip}"
action :nothing
end