Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master-chef-11.10-berkshelf' int…
Browse files Browse the repository at this point in the history
…o master-chef-11.10

Conflicts:
	opsworks_custom_cookbooks/attributes/default.rb
  • Loading branch information
jbraeuer committed Mar 14, 2014
2 parents a434251 + 6eec05b commit 3952933
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
22 changes: 22 additions & 0 deletions opsworks_custom_cookbooks/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,26 @@
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'
if node[:opsworks_custom_cookbooks][:berkshelf_version].to_i >= 3
default[:opsworks_custom_cookbooks][:berkshelf_command] = "vendor #{node[:opsworks_custom_cookbooks][:berkshelf_cookbook_path]}"
else
default[:opsworks_custom_cookbooks][:berkshelf_command] = "install --path #{node[:opsworks_custom_cookbooks][:berkshelf_cookbook_path]}"
end

default[:opsworks_custom_cookbooks][:berkshelf_pkg_release] = '1'
default[:opsworks_custom_cookbooks][:berkshelf_binary] = '/opt/aws/opsworks/local/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/2013.09/opsworks-berkshelf-#{node[:opsworks_custom_cookbooks][:berkshelf_version]}-#{node[:opsworks_custom_cookbooks][:berkshelf_pkg_release]}.#{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]}-#{node[:opsworks_custom_cookbooks][:berkshelf_pkg_release]}_#{arch}.deb"
end

include_attribute "opsworks_custom_cookbooks::customize"
67 changes: 66 additions & 1 deletion opsworks_custom_cookbooks/recipes/checkout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,80 @@
end
end

ruby_block 'inform about berkshelf installation with pre-built package' do
block do
Chef::Log.info "Trying to download and install pre-built package for berkshelf version #{node[:opsworks_custom_cookbooks][:berkshelf_version]}"
end

only_if do
node[:opsworks_custom_cookbooks][:manage_berkshelf] && !::File.exists?(node[:opsworks_custom_cookbooks][:berkshelf_binary])
end
end

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

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])
ignore_failure true

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

ruby_block 'inform about berkshelf installation with gem install' do
block do
Chef::Log.info "No pre-built package found for berkshelf version #{node[:opsworks_custom_cookbooks][:berkshelf_version]}, trying to install from rubygems.org" if node[:opsworks_custom_cookbooks][:manage_berkshelf] && !::File.exists?(node[:opsworks_custom_cookbooks][:berkshelf_binary])
end

only_if do
node[:opsworks_custom_cookbooks][:manage_berkshelf] && !::File.exists?(node[:opsworks_custom_cookbooks][:berkshelf_binary])
end
end

execute 'install berkshelf using gem install' do
command "/opt/aws/opsworks/local/bin/gem install berkshelf --version #{node[:opsworks_custom_cookbooks][:berkshelf_version]} --bindir /opt/aws/opsworks/local/bin"

only_if do
node[:opsworks_custom_cookbooks][:manage_berkshelf] &&
!::File.exists?(node[:opsworks_custom_cookbooks][:berkshelf_binary])
end
end

package 'opsworks-berkshelf' do
action :remove

not_if do
node[:opsworks_custom_cookbooks][:manage_berkshelf]
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]} #{node[:opsworks_custom_cookbooks][:berkshelf_command]}"
cwd node[:opsworks_custom_cookbooks][:destination]

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

directory node[:opsworks_custom_cookbooks][:berkshelf_cookbook_path] do
action :delete
recursive true

not_if do
node[:opsworks_custom_cookbooks][:manage_berkshelf]
end
end

execute "ensure correct permissions of custom cookbooks" do
command "chmod -R go-rwx #{node[:opsworks_custom_cookbooks][:destination]}"
only_if do
Expand Down

0 comments on commit 3952933

Please sign in to comment.