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

Modules-1242 always use credentials in rabbitmqadmin URL #221

Merged
merged 2 commits into from
Aug 7, 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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,17 @@ For Debian systems:
ensure => 'latest',
}

### Downgrade Issues

Be advised that there were configuration file syntax and other changes made between RabbitMQ
versions 2 and 3. In order to downgrade from 3 to 2 (not that this is a terribly good idea)
you will need to manually remove all RabbitMQ configuration files (``/etc/rabbitmq``) and
the mnesia directory (usually ``/var/lib/rabbitmq/mnesia``). The latter action will delete
any and all messages stored to disk.

Failure to do this will result in RabbitMQ failing to start with a cryptic error message about
"init terminating in do_boot", containing "rabbit_upgrade,maybe_upgrade_mnesia".

##Development

Puppet Labs modules on the Puppet Forge are open projects, and community
Expand Down
4 changes: 3 additions & 1 deletion manifests/install/rabbitmqadmin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
class rabbitmq::install::rabbitmqadmin {

$management_port = $rabbitmq::management_port
$default_user = $rabbitmq::default_user
$default_pass = $rabbitmq::default_pass

staging::file { 'rabbitmqadmin':
target => '/var/lib/rabbitmq/rabbitmqadmin',
source => "http://localhost:${management_port}/cli/rabbitmqadmin",
source => "http://${default_user}:${default_pass}@localhost:${management_port}/cli/rabbitmqadmin",
require => [
Class['rabbitmq::service'],
Rabbitmq_plugin['rabbitmq_management']
Expand Down
39 changes: 39 additions & 0 deletions spec/acceptance/rabbitmqadmin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,43 @@ class { 'erlang': epel_enable => true}
it { should be_file }
end
end

context 'works with specified default credentials' do
it 'should run successfully' do
# make sure credential change takes effect before admin_enable
pp_pre = <<-EOS
class { 'rabbitmq':
service_manage => true,
default_user => 'foobar',
default_pass => 'bazblam',
}
if $::osfamily == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

pp = <<-EOS
class { 'rabbitmq':
admin_enable => true,
service_manage => true,
default_user => 'foobar',
default_pass => 'bazblam',
}
if $::osfamily == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

shell('rm -f /var/lib/rabbitmq/rabbitmqadmin')
apply_manifest(pp_pre, :catch_failures => true)
apply_manifest(pp, :catch_failures => true)
end

describe file('/var/lib/rabbitmq/rabbitmqadmin') do
it { should be_file }
end
end

end
213 changes: 213 additions & 0 deletions spec/acceptance/zz281_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
require 'spec_helper_acceptance'
#
# beacuse of some serious issues with upgrading and downgrading rabbitmq on RedHat,
# we need to run all of the 2.8.1 tests last.
#
# NOTE that this is only tested on RedHat and probably only works there. But I can't seem
# to get 'confine' to work...
#

describe 'rabbitmq class with 2.8.1:' do
case fact('osfamily')
when 'RedHat'
package_name = 'rabbitmq-server'
service_name = 'rabbitmq-server'
package_source = "http://www.rabbitmq.com/releases/rabbitmq-server/v2.8.1/rabbitmq-server-2.8.1-1.noarch.rpm"
package_ensure = '2.8.1-1'
when 'SUSE'
package_name = 'rabbitmq-server'
service_name = 'rabbitmq-server'
package_source = "http://www.rabbitmq.com/releases/rabbitmq-server/v2.8.1/rabbitmq-server-2.8.1-1.noarch.rpm"
package_ensure = '2.8.1-1'
when 'Debian'
package_name = 'rabbitmq-server'
service_name = 'rabbitmq-server'
package_source = ''
package_ensure = '2.8.1'
when 'Archlinux'
package_name = 'rabbitmq'
service_name = 'rabbitmq'
package_source = ''
package_ensure = '2.8.1'
end

context "default class inclusion" do
it 'should run successfully' do
pp = <<-EOS
class { 'rabbitmq':
version => '2.8.1-1',
package_source => '#{package_source}',
package_ensure => '#{package_ensure}',
package_provider => 'rpm',
management_port => '55672',
}
if $::osfamily == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

# clean up previous 3.x install - can't be ungraded cleanly via RPM
shell('service rabbitmq-server stop')
shell('yum -y erase rabbitmq-server')
shell('rm -Rf /var/lib/rabbitmq/mnesia /etc/rabbitmq /var/lib/rabbitmq/rabbitmqadmin')
# Apply twice to ensure no errors the second time.
apply_manifest(pp, :catch_failures => true)
expect(apply_manifest(pp, :catch_changes => true).exit_code).to be_zero
# DEBUG
shell('netstat -lntp')
end

describe command('rabbitmqctl status') do
its(:stdout) { should match /{rabbit,"RabbitMQ","2.8.1"}/ }
end

describe package(package_name) do
it { should be_installed }
end

describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
end

context "disable and stop service" do
it 'should run successfully' do
pp = <<-EOS
class { 'rabbitmq':
version => '2.8.1-1',
package_source => '#{package_source}',
package_ensure => '#{package_ensure}',
package_provider => 'rpm',
management_port => '55672',
service_ensure => 'stopped',
admin_enable => false,
}
if $::osfamily == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

apply_manifest(pp, :catch_failures => true)
end

describe service(service_name) do
it { should_not be_enabled }
it { should_not be_running }
end
end

context "service is unmanaged" do
it 'should run successfully' do
pp_pre = <<-EOS
class { 'rabbitmq':
version => '2.8.1-1',
package_source => '#{package_source}',
package_ensure => '#{package_ensure}',
package_provider => 'rpm',
management_port => '55672',
}
if $::osfamily == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

pp = <<-EOS
class { 'rabbitmq':
service_manage => false,
service_ensure => 'stopped',
}
if $::osfamily == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

apply_manifest(pp_pre, :catch_failures => true)
apply_manifest(pp, :catch_failures => true)
end

describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
end

context 'rabbitmqadmin' do
#confine :to, :platform => 'el-6-x86'

it 'should run successfully' do
pp = <<-EOS
class { 'rabbitmq':
admin_enable => true,
service_manage => true,
version => '2.8.1-1',
package_source => '#{package_source}',
package_ensure => '#{package_ensure}',
package_provider => 'rpm',
management_port => '55672',
}
if $::osfamily == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

shell('rm -f /var/lib/rabbitmq/rabbitmqadmin')
apply_manifest(pp, :catch_failures => true)
end

# since serverspec (used by beaker-rspec) can only tell present/absent for packages
describe file('/var/lib/rabbitmq/rabbitmqadmin') do
it { should be_file }
end

describe command('rabbitmqadmin --help') do
it { should return_exit_status 0 }
end

end

context 'rabbitmqadmin with specified default credentials' do

it 'should run successfully' do
# make sure credential change takes effect before admin_enable
pp = <<-EOS
class { 'rabbitmq':
admin_enable => true,
service_manage => true,
version => '2.8.1-1',
package_source => '#{package_source}',
package_ensure => '#{package_ensure}',
package_provider => 'rpm',
management_port => '55672',
default_user => 'foobar',
default_pass => 'bazblam',
}
if $::osfamily == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

# next 3 lines - see MODULES-1085
shell('service rabbitmq-server stop')
shell('rm -Rf /var/lib/rabbitmq/mnesia /var/lib/rabbitmq/rabbitmqadmin')
apply_manifest(pp, :catch_failures => true)
end

# since serverspec (used by beaker-rspec) can only tell present/absent for packages
describe file('/var/lib/rabbitmq/rabbitmqadmin') do
it { should be_file }
end

describe command('rabbitmqadmin --help') do
it { should return_exit_status 0 }
end

end

end
14 changes: 14 additions & 0 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@
'require' => 'Class[Rabbitmq::Install]',
'notify' => 'Class[Rabbitmq::Service]'
)
should contain_staging__file('rabbitmqadmin').with_source("http://guest:guest@localhost:15672/cli/rabbitmqadmin")
end
end
context 'with service_manage set to true and default user/pass specified' do
let(:params) {{ :admin_enable => true, :default_user => 'foobar', :default_pass => 'hunter2' }}
it 'we use the correct URL to rabbitmqadmin' do
should contain_staging__file('rabbitmqadmin').with_source("http://foobar:hunter2@localhost:15672/cli/rabbitmqadmin")
end
end
context 'with service_manage set to true and management port specified' do
# note that the 2.x management port is 55672 not 15672
let(:params) {{ :admin_enable => true, :management_port => '55672' }}
it 'we use the correct URL to rabbitmqadmin' do
should contain_staging__file('rabbitmqadmin').with_source("http://guest:guest@localhost:55672/cli/rabbitmqadmin")
end
end
context 'with service_manage set to false' do
Expand Down