Skip to content

Commit

Permalink
Use a custom berkshelf package instead of the one from the agent's bu…
Browse files Browse the repository at this point in the history
  • Loading branch information
githuesch committed Feb 27, 2014
1 parent 04228ae commit f44cda7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
15 changes: 15 additions & 0 deletions opsworks_custom_cookbooks/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,18 @@

default[:opsworks_custom_cookbooks][:scm][:revision] = 'HEAD'
default[:opsworks_custom_cookbooks][:enable_submodules] = true

default[:opsworks_custom_cookbooks][:berkshelf_cookbook_path] = ChefClientConfigSimpleParser.get_attribute(Chef::Config[:config_file], 'cookbook_path').detect{|dir| dir =~ /berkshelf-cookbooks/}
default[:opsworks_custom_cookbooks][:berkshelf_version] = '2.0.14'
default[:opsworks_custom_cookbooks][:berkshelf_binary] = '/opt/aws/opsworks/local/lib/ruby/gems/2.0.0/bin/berks'

case node[:platform]
when 'redhat', 'centos', 'fedora', 'amazon'
arch = RUBY_PLATFORM.match(/64/) ? 'x86_64' : 'i686'
default[:opsworks_custom_cookbooks][:berkshelf_package_file] = "berkshelf_#{node[:opsworks_custom_cookbooks][:berkshelf_version]}.rpm"
default[:opsworks_custom_cookbooks][:berkshelf_package_url] = "https://s3.amazonaws.com/huesch-dummy/packages/amazon/2012.09/opsworks-berkshelf-#{node[:opsworks_custom_cookbooks][:berkshelf_version]}-1.#{arch}.rpm"
when 'ubuntu', 'debian'
arch = RUBY_PLATFORM.match(/64/) ? 'amd64' : 'i386'
default[:opsworks_custom_cookbooks][:berkshelf_package_file] = "berkshelf_#{node[:opsworks_custom_cookbooks][:berkshelf_version]}.deb"
default[:opsworks_custom_cookbooks][:berkshelf_package_url] = "https://s3.amazonaws.com/huesch-dummy/packages/ubuntu/12.04/opsworks-berkshelf_#{node[:opsworks_custom_cookbooks][:berkshelf_version]}_#{arch}.deb"
end
19 changes: 18 additions & 1 deletion opsworks_custom_cookbooks/recipes/checkout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,25 @@
end
end

remote_file "/tmp/#{node[:opsworks_custom_cookbooks][:berkshelf_package_file]}" do
source node[:opsworks_custom_cookbooks][:berkshelf_package_url]

only_if do
node[:opsworks_custom_cookbooks][:manage_berkshelf] && ::File.exists?(File.join(node[:opsworks_custom_cookbooks][:destination], 'Berksfile'))
end
end

package 'berkshelf' do
source "/tmp/#{node[:opsworks_custom_cookbooks][:berkshelf_package_file]}"
provider Chef::Provider::Package::Dpkg if ['ubuntu', 'debian'].include?(node[:platform])

only_if do
::File.exists?("/tmp/#{node[:opsworks_custom_cookbooks][:berkshelf_package_file]}")
end
end

execute 'run berks install' do
command '/opt/aws/opsworks/current/bin/berks install --path /var/lib/aws/opsworks/berkshelf-cookbooks'
command "#{node[:opsworks_custom_cookbooks][:berkshelf_binary]} install --path #{node[:opsworks_custom_cookbooks][:berkshelf_cookbook_path]}"
cwd node[:opsworks_custom_cookbooks][:destination]

only_if do
Expand Down

0 comments on commit f44cda7

Please sign in to comment.