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

Fix an issue when $node_ip_address is 'UNSET'. #450

Merged
merged 6 commits into from
Apr 19, 2016
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
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