From 317d06bb1e213f62ea51f29be9e75840a495f9bb Mon Sep 17 00:00:00 2001 From: Justin Early Date: Tue, 26 Apr 2016 06:51:59 -0500 Subject: [PATCH] extend Helpers within individual actions to avoid blanket definition name conflicts --- attributes/default.rb | 6 +++--- libraries/helpers.rb | 4 ++-- recipes/_windows.rb | 3 ++- recipes/configure_agent.rb | 2 +- recipes/install.rb | 3 ++- recipes/provision_agent.rb | 2 +- recipes/start.rb | 2 +- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 0d1bffe..dd42192 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -14,7 +14,7 @@ case node['platform_family'] when 'rhel', 'fedora' - default['al_agents']['agent']['service_name'] = 'al-agent' + default['al_agents']['agent']['al_agent_service'] = 'al-agent' if node['platform_version'].to_i >= 6 default['al_agents']['syslog_ng']['source_log'] = 's_all' else @@ -26,7 +26,7 @@ default['al_agents']['package']['url'] = 'https://scc.alertlogic.net/software/al-agent-LATEST-1.i386.rpm' end when 'debian' - default['al_agents']['agent']['service_name'] = 'al-agent' + default['al_agents']['agent']['al_agent_service'] = 'al-agent' default['al_agents']['syslog_ng']['source_log'] = 's_src' if node['kernel']['machine'] == 'x86_64' default['al_agents']['package']['url'] = 'https://scc.alertlogic.net/software/al-agent_LATEST_amd64.deb' @@ -34,7 +34,7 @@ default['al_agents']['package']['url'] = 'https://scc.alertlogic.net/software/al-agent_LATEST_i386.deb' end when 'windows' - default['al_agents']['agent']['service_name'] = 'al_agent' + default['al_agents']['agent']['al_agent_service'] = 'al_agent' default['al_agents']['package']['url'] = 'https://scc.alertlogic.net/software/al_agent-LATEST.msi' if node['kernel']['machine'] == 'x86_64' default['al_agents']['windows_install_guard'] = 'C:\Program Files (x86)\Common Files\AlertLogic\host_key.pem' diff --git a/libraries/helpers.rb b/libraries/helpers.rb index 208c114..778cb19 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -18,8 +18,8 @@ def agent_basename agent_file(node['al_agents']['package']['url']) end - def service_name - node['al_agents']['agent']['service_name'] + def al_agent_service + node['al_agents']['agent']['al_agent_service'] end def windows_install_guard diff --git a/recipes/_windows.rb b/recipes/_windows.rb index 0482875..bf2c281 100644 --- a/recipes/_windows.rb +++ b/recipes/_windows.rb @@ -1,10 +1,10 @@ ::Chef::Recipe.send(:include, AlAgents::Helpers) -::Chef::Resource::Batch.send(:include, AlAgents::Helpers) cache_dir = Chef::Config[:file_cache_path] cached_package = ::File.join(cache_dir, agent_basename) remote_file agent_basename do + extend(AlAgents::Helpers) path cached_package source node['al_agents']['package']['url'] action :create_if_missing @@ -13,6 +13,7 @@ # test kitchen issue: the reinstall causes an issue # https://github.com/chef/chef/issues/3055s package agent_basename do + extend(AlAgents::Helpers) source cached_package action :install options windows_options diff --git a/recipes/configure_agent.rb b/recipes/configure_agent.rb index e424482..00ec76a 100644 --- a/recipes/configure_agent.rb +++ b/recipes/configure_agent.rb @@ -6,9 +6,9 @@ # ::Chef::Recipe.send(:include, AlAgents::Helpers) -::Chef::Resource::Batch.send(:include, AlAgents::Helpers) execute "configure #{agent_basename}" do + extend(AlAgents::Helpers) user 'root' cwd '/etc/init.d' command "./al-agent configure #{configure_options}" diff --git a/recipes/install.rb b/recipes/install.rb index 6547b61..c002d10 100644 --- a/recipes/install.rb +++ b/recipes/install.rb @@ -6,12 +6,12 @@ # ::Chef::Recipe.send(:include, AlAgents::Helpers) -::Chef::Resource::Batch.send(:include, AlAgents::Helpers) cache_dir = Chef::Config[:file_cache_path] cached_package = ::File.join(cache_dir, agent_basename) remote_file agent_basename do + extend(AlAgents::Helpers) path cached_package source node['al_agents']['package']['url'] action :create_if_missing @@ -19,6 +19,7 @@ # let ubuntu know to use dpkg not apt package agent_basename do + extend(AlAgents::Helpers) source cached_package action :install version '>=0' diff --git a/recipes/provision_agent.rb b/recipes/provision_agent.rb index ba5bc4c..4ff76ea 100644 --- a/recipes/provision_agent.rb +++ b/recipes/provision_agent.rb @@ -6,9 +6,9 @@ # ::Chef::Recipe.send(:include, AlAgents::Helpers) -::Chef::Resource::Batch.send(:include, AlAgents::Helpers) execute "provision #{agent_basename}" do + extend(AlAgents::Helpers) user 'root' cwd '/etc/init.d' command "./al-agent provision #{provision_options}" diff --git a/recipes/start.rb b/recipes/start.rb index 8713f24..d5cd0c5 100644 --- a/recipes/start.rb +++ b/recipes/start.rb @@ -1,4 +1,4 @@ ::Chef::Recipe.send(:include, AlAgents::Helpers) -service service_name do +service al_agent_service do action :start end