Skip to content

Commit

Permalink
Merge pull request voxpupuli#450 from wyardley/master
Browse files Browse the repository at this point in the history
Fix an issue when $node_ip_address is 'UNSET'.
  • Loading branch information
EmilienM committed Apr 19, 2016
2 parents 7b9eac1 + 73295c8 commit b9112e2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
15 changes: 9 additions & 6 deletions manifests/install/rabbitmqadmin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
if($rabbitmq::ssl and $rabbitmq::management_ssl) {
$management_port = $rabbitmq::ssl_management_port
$protocol = 'https'
}
else {
} else {
$management_port = $rabbitmq::management_port
$protocol = 'http'
}
Expand All @@ -14,18 +13,22 @@
$default_pass = $rabbitmq::default_pass
$node_ip_address = $rabbitmq::node_ip_address

if is_ipv6_address($node_ip_address) {
$curl_prefix = '-g -6'
if $rabbitmq::node_ip_address == 'UNSET' {
# Pull from localhost if we don't have an explicit bind address
$curl_prefix = ''
$sanitized_ip = '127.0.0.1'
} elsif is_ipv6_address($node_ip_address) {
$curl_prefix = "--noproxy ${node_ip_address} -g -6"
$sanitized_ip = join(enclose_ipv6(any2array($node_ip_address)), ',')
} else {
$curl_prefix = ''
$curl_prefix = "--noproxy ${node_ip_address}"
$sanitized_ip = $node_ip_address
}

staging::file { 'rabbitmqadmin':
target => "${rabbitmq::rabbitmq_home}/rabbitmqadmin",
source => "${protocol}://${default_user}:${default_pass}@${sanitized_ip}:${management_port}/cli/rabbitmqadmin",
curl_option => "-k --noproxy ${node_ip_address} ${curl_prefix} --retry 30 --retry-delay 6",
curl_option => "-k ${curl_prefix} --retry 30 --retry-delay 6",
timeout => '180',
wget_option => '--no-proxy',
require => [
Expand Down
24 changes: 22 additions & 2 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,32 @@
should contain_staging__file('rabbitmqadmin').with_source("http://guest:[email protected]:15672/cli/rabbitmqadmin")
end
end
context 'with default $node_ip_address="UNSET" and service_manage set to true' do
let(:params) {{ :admin_enable => true, :node_ip_address => 'UNSET' }}
it 'we enable the admin interface by default' do
should contain_class('rabbitmq::install::rabbitmqadmin')
should contain_rabbitmq_plugin('rabbitmq_management').with(
'require' => 'Class[Rabbitmq::Install]',
'notify' => 'Class[Rabbitmq::Service]'
)
should contain_staging__file('rabbitmqadmin').with_source("http://guest:[email protected]:15672/cli/rabbitmqadmin")
end
end
context 'with service_manage set to true, node_ip_address = "UNSET", and default user/pass specified' do
let(:params) {{ :admin_enable => true, :default_user => 'foobar', :default_pass => 'hunter2', :node_ip_address => 'UNSET' }}
it 'we use the correct URL to rabbitmqadmin' do
should contain_staging__file('rabbitmqadmin').with(
:source => 'http://foobar:[email protected]:15672/cli/rabbitmqadmin',
:curl_option => '-k --retry 30 --retry-delay 6',
)
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', :node_ip_address => '1.1.1.1' }}
it 'we use the correct URL to rabbitmqadmin' do
should contain_staging__file('rabbitmqadmin').with(
:source => 'http://foobar:[email protected]:15672/cli/rabbitmqadmin',
:curl_option => '-k --noproxy 1.1.1.1 --retry 30 --retry-delay 6',
:curl_option => '-k --noproxy 1.1.1.1 --retry 30 --retry-delay 6',
)
end
end
Expand All @@ -447,7 +467,7 @@
it 'we use the correct URL to rabbitmqadmin' do
should contain_staging__file('rabbitmqadmin').with(
:source => 'http://guest:[email protected]:55672/cli/rabbitmqadmin',
:curl_option => '-k --noproxy 1.1.1.1 --retry 30 --retry-delay 6',
:curl_option => '-k --noproxy 1.1.1.1 --retry 30 --retry-delay 6',
)
end
end
Expand Down

0 comments on commit b9112e2

Please sign in to comment.