Skip to content

Commit

Permalink
extend Helpers within individual actions to avoid blanket definition …
Browse files Browse the repository at this point in the history
…name conflicts
  • Loading branch information
Justin Early authored and Justin Early committed Apr 26, 2016
1 parent 521fa74 commit 317d06b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,15 +26,15 @@
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'
else
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'
Expand Down
4 changes: 2 additions & 2 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion recipes/_windows.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion recipes/configure_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
3 changes: 2 additions & 1 deletion recipes/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
#

::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
end

# let ubuntu know to use dpkg not apt
package agent_basename do
extend(AlAgents::Helpers)
source cached_package
action :install
version '>=0'
Expand Down
2 changes: 1 addition & 1 deletion recipes/provision_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion recipes/start.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
::Chef::Recipe.send(:include, AlAgents::Helpers)
service service_name do
service al_agent_service do
action :start
end

0 comments on commit 317d06b

Please sign in to comment.