Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better upgrade and distro package installation. #180

Merged
merged 4 commits into from
Dec 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@ class Chef::Resource # rubocop:disable all
package 'logrotate'

if node['rabbitmq']['use_distro_version']
package 'rabbitmq-server'
package 'rabbitmq-server' do
action :install
version node['rabbitmq']['version']
end
else
# we need to download the package
deb_package = "https://www.rabbitmq.com/releases/rabbitmq-server/v#{node['rabbitmq']['version']}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb"
remote_file "#{Chef::Config[:file_cache_path]}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" do
source deb_package
action :create_if_missing
end
dpkg_package "#{Chef::Config[:file_cache_path]}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb"
dpkg_package "#{Chef::Config[:file_cache_path]}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" do
action :install
end
end

# Configure job control
Expand Down Expand Up @@ -92,7 +97,10 @@ class Chef::Resource # rubocop:disable all
end

if node['rabbitmq']['use_distro_version']
package 'rabbitmq-server'
package 'rabbitmq-server' do
action :install
version node['rabbitmq']['version']
end
else
# We need to download the rpm
rpm_package = "https://www.rabbitmq.com/releases/rabbitmq-server/v#{node['rabbitmq']['version']}/rabbitmq-server-#{node['rabbitmq']['version']}-1.noarch.rpm"
Expand All @@ -112,14 +120,23 @@ class Chef::Resource # rubocop:disable all
# rabbitmq-server-plugins needs to be first so they both get installed
# from the right repository. Otherwise, zypper will stop and ask for a
# vendor change.
package 'rabbitmq-server-plugins'
package 'rabbitmq-server'
package 'rabbitmq-server-plugins' do
action :install
version node['rabbitmq']['version']
end
package 'rabbitmq-server' do
action :install
version node['rabbitmq']['version']
end

service node['rabbitmq']['service_name'] do
action [:enable, :start]
end
when 'smartos'
package 'rabbitmq'
package 'rabbitmq'do
action :install
version node['rabbitmq']['version']
end

service 'epmd' do
action :start
Expand Down
4 changes: 0 additions & 4 deletions spec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
expect(chef_run).to create_remote_file_if_missing("#{Chef::Config[:file_cache_path]}/rabbitmq-server-#{version}.noarch.rpm")
end

it 'installs the rabbitmq-server rpm_package with the default action' do
expect(chef_run).to install_rpm_package("#{Chef::Config[:file_cache_path]}/rabbitmq-server-#{version}.noarch.rpm")
end

it 'creates a template rabbitmq.config with attributes' do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This totally didn't work how i expected. I'll need to investigate this.

expect(chef_run).to create_template('/etc/rabbitmq/rabbitmq.config').with(
:user => 'root',
Expand Down