Deprecate rabbitmq connection parameters

The rabbitmq connection parameters have been deprecated in favor of the
transport_url setting. Additionally, the configuration has been switched
over to use the oslo::messaging::rabbit resource.

Change-Id: I43500ac7be4296ea534266fa14ca37fc700b0092
Related-Bug: #1625198
This commit is contained in:
Alex Schultz 2016-11-08 16:52:14 -07:00
parent 1800bb1b37
commit 609859b307
4 changed files with 113 additions and 57 deletions

View File

@ -41,35 +41,27 @@
# (optional) Command for designate rootwrap helper.
# Defaults to 'sudo designate-rootwrap /etc/designate/rootwrap.conf'.
#
# [*rabbit_host*]
# (optional) Location of rabbitmq installation.
# Defaults to '127.0.0.1'
# [*rpc_backend*]
# (optional) The messaging driver to use. Currently only rabbit is support
# by this puppet module.
# Defaults to 'rabbit'.
#
# [*rabbit_port*]
# (optional) Port for rabbitmq instance.
# Defaults to '5672'
#
# [*rabbit_hosts*]
# (Optional) Array of host:port (used with HA queues).
# If defined, will remove rabbit_host & rabbit_port parameters from config
# Defaults to undef.
#
# [*rabbit_password*]
# (optional) Password used to connect to rabbitmq.
# Defaults to 'guest'
#
# [*rabbit_userid*]
# (optional) User used to connect to rabbitmq.
# Defaults to 'guest'
#
# [*rabbit_virtual_host*]
# (optional) The RabbitMQ virtual host.
# Defaults to '/'
# [*default_transport_url*]
# (optional) A URL representing the messaging driver to use and its full
# configuration. Transport URLs take the form:
# transport://user:pass@host1:port[,hostN:portN]/virtual_host
# Defaults to $::os_service_default
#
# [*rabbit_use_ssl*]
# (optional) Connect over SSL for RabbitMQ
# Defaults to false
#
# [*rabbit_ha_queues*]
# (optional) Use HA queues in RabbitMQ (x-ha-policy: all). If you change this
# option, you must wipe the RabbitMQ database. (boolean value). Currently,
# this value is set to true when rabbit_hosts is configured. This will change
# during the Pike cycle where we will no longer do this check.
#
# [*kombu_ssl_ca_certs*]
# (optional) SSL certification authority file (valid only if SSL enabled).
# Defaults to $::os_service_default
@ -112,6 +104,31 @@
# (optional) DEPRECATED. Use rabbit_virtual_host
# Defaults to undef.
#
# [*rabbit_host*]
# (optional) Location of rabbitmq installation.
# Defaults to $::os_service_default
#
# [*rabbit_port*]
# (optional) Port for rabbitmq instance.
# Defaults to $::os_service_default
#
# [*rabbit_hosts*]
# (Optional) Array of host:port (used with HA queues).
# If defined, will remove rabbit_host & rabbit_port parameters from config
# Defaults to $::os_service_default
#
# [*rabbit_password*]
# (optional) Password used to connect to rabbitmq.
# Defaults to $::os_service_default
#
# [*rabbit_userid*]
# (optional) User used to connect to rabbitmq.
# Defaults to $::os_service_default
#
# [*rabbit_virtual_host*]
# (optional) The RabbitMQ virtual host.
# Defaults to $::os_service_default
#
class designate(
$package_ensure = present,
$common_package_name = $::designate::params::common_package_name,
@ -121,13 +138,10 @@ class designate(
$use_stderr = undef,
$log_facility = undef,
$root_helper = 'sudo designate-rootwrap /etc/designate/rootwrap.conf',
$rabbit_host = '127.0.0.1',
$rabbit_port = '5672',
$rabbit_hosts = false,
$rabbit_userid = 'guest',
$rabbit_password = '',
$rabbit_virtual_host = '/',
$rpc_backend = 'rabbit',
$default_transport_url = $::os_service_default,
$rabbit_use_ssl = false,
$rabbit_ha_queues = $::os_service_default,
$kombu_ssl_ca_certs = $::os_service_default,
$kombu_ssl_certfile = $::os_service_default,
$kombu_ssl_keyfile = $::os_service_default,
@ -138,6 +152,12 @@ class designate(
$purge_config = false,
#DEPRECATED PARAMETER
$rabbit_virtualhost = undef,
$rabbit_host = $::os_service_default,
$rabbit_port = $::os_service_default,
$rabbit_hosts = $::os_service_default,
$rabbit_userid = $::os_service_default,
$rabbit_password = $::os_service_default,
$rabbit_virtual_host = $::os_service_default,
) inherits designate::params {
if $rabbit_virtualhost {
@ -161,6 +181,31 @@ class designate(
fail('The kombu_ssl_certfile and kombu_ssl_keyfile parameters must be used together')
}
if !is_service_default($rabbit_host) or
!is_service_default($rabbit_hosts) or
!is_service_default($rabbit_password) or
!is_service_default($rabbit_port) or
!is_service_default($rabbit_userid) or
!is_service_default($rabbit_virtual_host) {
warning("designate::rabbit_host, designate::rabbit_hosts, designate::rabbit_password, \
designate::rabbit_port, designate::rabbit_userid and designate::rabbit_virtual_host are \
deprecated. Please use designate::default_transport_url instead.")
}
if is_service_default($rabbit_ha_queues) {
warning("designate::rabbit_ha_queues will be changed to use the service default \
durring the Pike cycle. Currently it is automatically configured based on the setting of \
designate::rabbit_hosts which has been deprecated. Please consider defining this variable \
to your desired configuration.")
if !is_service_default($rabbit_hosts) {
$rabbit_ha_queues_real = true
} else {
$rabbit_ha_queues_real = false
}
} else {
$rabbit_ha_queues_real = $rabbit_ha_queues
}
include ::designate::logging
exec { 'post-designate_config':
@ -180,28 +225,25 @@ class designate(
purge => $purge_config,
}
designate_config {
'oslo_messaging_rabbit/rabbit_userid' : value => $rabbit_userid;
'oslo_messaging_rabbit/rabbit_password' : value => $rabbit_password, secret => true;
'oslo_messaging_rabbit/rabbit_virtual_host' : value => $rabbit_virtual_host_real;
'oslo_messaging_rabbit/rabbit_use_ssl' : value => $rabbit_use_ssl;
'oslo_messaging_rabbit/kombu_ssl_ca_certs' : value => $kombu_ssl_ca_certs;
'oslo_messaging_rabbit/kombu_ssl_certfile' : value => $kombu_ssl_certfile;
'oslo_messaging_rabbit/kombu_ssl_keyfile' : value => $kombu_ssl_keyfile;
'oslo_messaging_rabbit/kombu_ssl_version' : value => $kombu_ssl_version;
'oslo_messaging_rabbit/kombu_reconnect_delay' : value => $kombu_reconnect_delay;
if $rpc_backend == 'rabbit' {
oslo::messaging::rabbit { 'designate_config':
kombu_ssl_version => $kombu_ssl_version,
kombu_ssl_keyfile => $kombu_ssl_keyfile,
kombu_ssl_certfile => $kombu_ssl_certfile,
kombu_ssl_ca_certs => $kombu_ssl_ca_certs,
kombu_reconnect_delay => $kombu_reconnect_delay,
rabbit_host => $rabbit_host,
rabbit_port => $rabbit_port,
rabbit_hosts => $rabbit_hosts,
rabbit_use_ssl => $rabbit_use_ssl,
rabbit_userid => $rabbit_userid,
rabbit_password => $rabbit_password,
rabbit_virtual_host => $rabbit_virtual_host,
rabbit_ha_queues => $rabbit_ha_queues_real,
}
}
if $rabbit_hosts {
designate_config { 'oslo_messaging_rabbit/rabbit_hosts': value => join($rabbit_hosts, ',') }
designate_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => true }
designate_config { 'oslo_messaging_rabbit/rabbit_host': ensure => absent }
designate_config { 'oslo_messaging_rabbit/rabbit_port': ensure => absent }
} else {
designate_config { 'oslo_messaging_rabbit/rabbit_host': value => $rabbit_host }
designate_config { 'oslo_messaging_rabbit/rabbit_port': value => $rabbit_port }
designate_config { 'oslo_messaging_rabbit/rabbit_hosts': value => "${rabbit_host}:${rabbit_port}" }
designate_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => false }
oslo::messaging::default { 'designate_config':
transport_url => $default_transport_url,
}
# default setting

View File

@ -0,0 +1,16 @@
---
upgrade:
- designate::rabbit_ha_queues has been exposed and will need to be configured
based on the desired use of ha queues. Previously, the value for this was
being configured using the designate::rabbit_hosts parameter. This automatic
configuration will be dropped during the Pike cycle.
- The designate module will now use the oslo::messaging::rabbit resource to
configure the rabbit configuration settings.
deprecations:
- designate::rabbit_host, designate::rabbit_hosts, designate::rabbit_password,
designate::rabbit_port, designate::rabbit_userid and
designate::rabbit_virtual_host are deprecated.
designate::default_transport_url should be used instead.
- rabbit_ha_queues will no longer be configured to be True when rabbit_hosts
is configured and will need to be specified. This automatic configuration
will be dropped in the Pike cycle.

View File

@ -35,10 +35,8 @@ describe 'basic designate' do
password => 'a_big_secret',
}
class { '::designate':
rabbit_userid => 'designate',
rabbit_password => 'an_even_bigger_secret',
rabbit_host => '127.0.0.1',
debug => true,
default_transport_url => 'rabbit://designate:an_even_bigger_secret@127.0.0.1:5672/',
debug => true,
}
class { '::designate::keystone::authtoken':
password => 'a_big_secret',

View File

@ -164,7 +164,7 @@ describe 'designate' do
end
it { is_expected.to contain_designate_config('oslo_messaging_rabbit/rabbit_host').with_value( params[:rabbit_host] ) }
it { is_expected.to contain_designate_config('oslo_messaging_rabbit/rabbit_hosts').with_value( "#{params[:rabbit_host]}:#{params[:rabbit_port]}" ) }
it { is_expected.to contain_designate_config('oslo_messaging_rabbit/rabbit_hosts').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_designate_config('oslo_messaging_rabbit/rabbit_port').with_value( params[:rabbit_port] ) }
it { is_expected.to contain_designate_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value( 'false' ) }
@ -180,9 +180,9 @@ describe 'designate' do
is_expected.to contain_designate_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] )
end
it { is_expected.to contain_designate_config('oslo_messaging_rabbit/rabbit_host').with_ensure( 'absent' ) }
it { is_expected.to contain_designate_config('oslo_messaging_rabbit/rabbit_host').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_designate_config('oslo_messaging_rabbit/rabbit_hosts').with_value( '10.0.0.1:5672,10.0.0.2:5672,10.0.0.3:5672' ) }
it { is_expected.to contain_designate_config('oslo_messaging_rabbit/rabbit_port').with_ensure( 'absent' ) }
it { is_expected.to contain_designate_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_designate_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value( 'true' ) }
end