diff --git a/manifests/db.pp b/manifests/db.pp index d7184fd06..b403075b9 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -43,8 +43,6 @@ class neutron::db ( $database_max_overflow = $::os_service_default, ) { - include ::neutron::params - # NOTE(spredzy): In order to keep backward compatibility we rely on the pick function # to use neutron:: if neutron::db:: isn't specified. $database_connection_real = pick($::neutron::server::database_connection, $database_connection) @@ -59,44 +57,15 @@ class neutron::db ( '^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?') if $database_connection_real { - case $database_connection_real { - /^mysql(\+pymysql)?:\/\//: { - require 'mysql::bindings' - require 'mysql::bindings::python' - if $database_connection_real =~ /^mysql\+pymysql/ { - $backend_package = $::neutron::params::pymysql_package_name - } else { - $backend_package = false - } - } - /^postgresql:\/\//: { - $backend_package = false - require 'postgresql::lib::python' - } - /^sqlite:\/\//: { - $backend_package = $::neutron::params::sqlite_package_name - } - default: { - fail('Unsupported backend configured') - } - } - if $backend_package and !defined(Package[$backend_package]) { - package {'neutron-backend-package': - ensure => present, - name => $backend_package, - tag => 'openstack', - } - } - - neutron_config { - 'database/connection': value => $database_connection_real, secret => true; - 'database/idle_timeout': value => $database_idle_timeout_real; - 'database/min_pool_size': value => $database_min_pool_size_real; - 'database/max_retries': value => $database_max_retries_real; - 'database/retry_interval': value => $database_retry_interval_real; - 'database/max_pool_size': value => $database_max_pool_size_real; - 'database/max_overflow': value => $database_max_overflow_real; + oslo::db { 'neutron_config': + connection => $database_connection_real, + idle_timeout => $database_idle_timeout_real, + min_pool_size => $database_min_pool_size_real, + max_retries => $database_max_retries_real, + retry_interval => $database_retry_interval_real, + max_pool_size => $database_max_pool_size_real, + max_overflow => $database_max_overflow_real, } } diff --git a/manifests/init.pp b/manifests/init.pp index 800195126..20ac77bca 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -127,7 +127,7 @@ # [*rpc_backend*] # (optional) what rpc/queuing service to use -# Defaults to rabbit (rabbitmq) +# Defaults to $::os_service_default # # [*rpc_response_timeout*] # (optional) Seconds to wait for a response from a call @@ -138,6 +138,7 @@ # [*rabbit_port*] # [*rabbit_user*] # (optional) Various rabbitmq settings +# Defaults to $::os_service_default # # [*rabbit_virtual_host*] # (optional) virtualhost to use. @@ -147,11 +148,11 @@ # (optional) array of rabbitmq servers for HA. # A single IP address, such as a VIP, can be used for load-balancing # multiple RabbitMQ Brokers. -# Defaults to false +# Defaults to $::os_service_default # # [*rabbit_ha_queues*] # (Optional) Use HA queues in RabbitMQ. -# Defaults to undef +# Defaults to $::os_service_default # # [*rabbit_heartbeat_timeout_threshold*] # (optional) Number of seconds after which the RabbitMQ broker is considered @@ -159,14 +160,14 @@ # Heartbeating helps to ensure the TCP connection to RabbitMQ isn't silently # closed, resulting in missed or lost messages from the queue. # (Requires kombu >= 3.0.7 and amqp >= 1.4.0) -# Defaults to 0 +# Defaults to $::os_service_default # # [*rabbit_heartbeat_rate*] # (optional) How often during the rabbit_heartbeat_timeout_threshold period to # check the heartbeat on RabbitMQ connection. (i.e. rabbit_heartbeat_rate=2 # when rabbit_heartbeat_timeout_threshold=60, the heartbeat will be checked # every 30 seconds. -# Defaults to 2 +# Defaults to $::os_service_default # # [*rabbit_use_ssl*] # (optional) Connect over SSL for RabbitMQ @@ -192,7 +193,7 @@ # (optional) SSL version to use (valid only if SSL enabled). # Valid values are TLSv1, SSLv23 and SSLv3. SSLv2 may be # available on some distributions. -# Defaults to 'TLSv1' +# Defaults to $::os_service_default # # [*kombu_reconnect_delay*] # (optional) The amount of time to wait before attempting to reconnect @@ -231,7 +232,7 @@ # # [*log_file*] # (optional) Where to log -# Defaults to false +# Defaults to $::os_service_default # # [*log_dir*] # (optional) Directory where logs should be stored @@ -284,23 +285,23 @@ class neutron ( $report_interval = $::os_service_default, $memcache_servers = false, $control_exchange = 'neutron', - $rpc_backend = 'rabbit', + $rpc_backend = $::os_service_default, $rpc_response_timeout = $::os_service_default, - $rabbit_password = false, - $rabbit_host = 'localhost', - $rabbit_hosts = false, - $rabbit_port = 5672, - $rabbit_ha_queues = undef, - $rabbit_user = 'guest', + $rabbit_password = $::os_service_default, + $rabbit_host = $::os_service_default, + $rabbit_hosts = $::os_service_default, + $rabbit_port = $::os_service_default, + $rabbit_ha_queues = $::os_service_default, + $rabbit_user = $::os_service_default, $rabbit_virtual_host = $::os_service_default, - $rabbit_heartbeat_timeout_threshold = 0, - $rabbit_heartbeat_rate = 2, + $rabbit_heartbeat_timeout_threshold = $::os_service_default, + $rabbit_heartbeat_rate = $::os_service_default, $rabbit_use_ssl = $::os_service_default, $amqp_durable_queues = $::os_service_default, $kombu_ssl_ca_certs = $::os_service_default, $kombu_ssl_certfile = $::os_service_default, $kombu_ssl_keyfile = $::os_service_default, - $kombu_ssl_version = 'TLSv1', + $kombu_ssl_version = $::os_service_default, $kombu_reconnect_delay = $::os_service_default, $use_ssl = $::os_service_default, $cert_file = $::os_service_default, @@ -309,7 +310,7 @@ class neutron ( $use_syslog = $::os_service_default, $use_stderr = $::os_service_default, $log_facility = $::os_service_default, - $log_file = false, + $log_file = $::os_service_default, $log_dir = '/var/log/neutron', $state_path = $::os_service_default, $lock_path = '$state_path/lock', @@ -368,11 +369,6 @@ class neutron ( } neutron_config { - 'DEFAULT/verbose': value => $verbose; - 'DEFAULT/debug': value => $debug; - 'DEFAULT/use_stderr': value => $use_stderr; - 'DEFAULT/use_syslog': value => $use_syslog; - 'DEFAULT/syslog_log_facility': value => $log_facility; 'DEFAULT/bind_host': value => $bind_host; 'DEFAULT/bind_port': value => $bind_port; 'DEFAULT/auth_strategy': value => $auth_strategy; @@ -389,35 +385,26 @@ class neutron ( 'DEFAULT/allow_sorting': value => $allow_sorting; 'DEFAULT/allow_overlapping_ips': value => $allow_overlapping_ips; 'DEFAULT/control_exchange': value => $control_exchange; - 'DEFAULT/rpc_backend': value => $rpc_backend; 'DEFAULT/api_extensions_path': value => $api_extensions_path; 'DEFAULT/state_path': value => $state_path; 'DEFAULT/rpc_response_timeout': value => $rpc_response_timeout; 'DEFAULT/global_physnet_mtu': value => pick($network_device_mtu, $global_physnet_mtu); - 'oslo_concurrency/lock_path': value => $lock_path; 'agent/root_helper': value => $root_helper; 'agent/report_interval': value => $report_interval; } - if $log_file { - neutron_config { - 'DEFAULT/log_file': value => $log_file; - 'DEFAULT/log_dir': value => $log_dir; - } - } else { - if $log_dir { - neutron_config { - 'DEFAULT/log_dir': value => $log_dir; - 'DEFAULT/log_file': ensure => absent; - } - } else { - neutron_config { - 'DEFAULT/log_dir': ensure => absent; - 'DEFAULT/log_file': ensure => absent; - } - } + oslo::log { 'neutron_config': + verbose => $verbose, + debug => $debug, + use_stderr => $use_stderr, + use_syslog => $use_syslog, + syslog_log_facility => $log_facility, + log_file => $log_file, + log_dir => $log_dir, } + oslo::concurrency { 'neutron_config': lock_path => $lock_path } + if ! is_service_default ($service_plugins) and ($service_plugins) { if is_array($service_plugins) { neutron_config { 'DEFAULT/service_plugins': value => join($service_plugins, ',') } @@ -437,56 +424,33 @@ class neutron ( } - if $rpc_backend == 'rabbit' or $rpc_backend == 'neutron.openstack.common.rpc.impl_kombu' { - if ! $rabbit_password { + if $rpc_backend in [$::os_service_default, 'neutron.openstack.common.rpc.impl_kombu', 'rabbit'] { + if is_service_default($rabbit_password) { fail('When rpc_backend is rabbitmq, you must set rabbit password') } - if $rabbit_hosts { - neutron_config { 'oslo_messaging_rabbit/rabbit_hosts': value => join($rabbit_hosts, ',') } - } else { - neutron_config { 'oslo_messaging_rabbit/rabbit_host': value => $rabbit_host } - neutron_config { 'oslo_messaging_rabbit/rabbit_port': value => $rabbit_port } - neutron_config { 'oslo_messaging_rabbit/rabbit_hosts': value => "${rabbit_host}:${rabbit_port}" } - } - if $rabbit_ha_queues == undef { - if $rabbit_hosts { - neutron_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => true } - } else { - neutron_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => false } - } - } else { - neutron_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => $rabbit_ha_queues } + oslo::messaging::rabbit {'neutron_config': + rabbit_userid => $rabbit_user, + rabbit_password => $rabbit_password, + rabbit_virtual_host => $rabbit_virtual_host, + heartbeat_timeout_threshold => $rabbit_heartbeat_timeout_threshold, + heartbeat_rate => $rabbit_heartbeat_rate, + rabbit_use_ssl => $rabbit_use_ssl, + kombu_reconnect_delay => $kombu_reconnect_delay, + kombu_ssl_ca_certs => $kombu_ssl_ca_certs, + kombu_ssl_certfile => $kombu_ssl_certfile, + kombu_ssl_keyfile => $kombu_ssl_keyfile, + amqp_durable_queues => $amqp_durable_queues, + rabbit_hosts => $rabbit_hosts, + rabbit_ha_queues => $rabbit_ha_queues, + rabbit_host => $rabbit_host, + rabbit_port => $rabbit_port, + kombu_ssl_version => $kombu_ssl_version, } - + } else { neutron_config { - 'oslo_messaging_rabbit/rabbit_userid': value => $rabbit_user; - 'oslo_messaging_rabbit/rabbit_password': value => $rabbit_password, secret => true; - 'oslo_messaging_rabbit/rabbit_virtual_host': value => $rabbit_virtual_host; - 'oslo_messaging_rabbit/heartbeat_timeout_threshold': value => $rabbit_heartbeat_timeout_threshold; - 'oslo_messaging_rabbit/heartbeat_rate': value => $rabbit_heartbeat_rate; - 'oslo_messaging_rabbit/rabbit_use_ssl': value => $rabbit_use_ssl; - 'oslo_messaging_rabbit/kombu_reconnect_delay': value => $kombu_reconnect_delay; - '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/amqp_durable_queues': value => $amqp_durable_queues; + 'DEFAULT/rpc_backend': value => $rpc_backend; } - - if ! is_service_default($rabbit_use_ssl) and ($rabbit_use_ssl) { - - if $kombu_ssl_version { - neutron_config { 'oslo_messaging_rabbit/kombu_ssl_version': value => $kombu_ssl_version; } - } else { - neutron_config { 'oslo_messaging_rabbit/kombu_ssl_version': ensure => absent; } - } - - } else { - neutron_config { - 'oslo_messaging_rabbit/kombu_ssl_version': ensure => absent; - } - } - } if $network_device_mtu { diff --git a/manifests/params.pp b/manifests/params.pp index 6b8774df3..2a745b798 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -89,9 +89,6 @@ class neutron::params { $kernel_headers = "linux-headers-${::kernelrelease}" - $sqlite_package_name = undef - $pymysql_package_name = undef - } elsif($::osfamily == 'Debian') { $nobody_user_group = 'nogroup' @@ -178,9 +175,6 @@ class neutron::params { $cliff_package = 'python-cliff' $kernel_headers = "linux-headers-${::kernelrelease}" - - $sqlite_package_name = 'python-pysqlite2' - $pymysql_package_name = 'python-pymysql' } else { fail("Unsupported osfamily ${::osfamily}") diff --git a/manifests/policy.pp b/manifests/policy.pp index 54a89989b..ffdaede64 100644 --- a/manifests/policy.pp +++ b/manifests/policy.pp @@ -36,4 +36,6 @@ class neutron::policy ( create_resources('openstacklib::policy::base', $policies) + oslo::policy { 'neutron_config': policy_file => $policy_path } + } diff --git a/metadata.json b/metadata.json index 71adc153e..c2e780518 100644 --- a/metadata.json +++ b/metadata.json @@ -37,6 +37,7 @@ { "name": "puppetlabs/stdlib", "version_requirement": ">=4.0.0 <5.0.0" }, { "name": "openstack/vswitch", "version_requirement": ">=4.0.0 <5.0.0" }, { "name": "duritong/sysctl", "version_requirement": ">=0.0.1 <1.0.0" }, - { "name": "openstack/openstacklib", "version_requirement": ">=8.0.0 <9.0.0" } + { "name": "openstack/openstacklib", "version_requirement": ">=8.0.0 <9.0.0" }, + { "name": "openstack/oslo", "version_requirement": "<9.0.0" } ] } diff --git a/releasenotes/notes/use_puppet_oslo-868298e248a64ab8.yaml b/releasenotes/notes/use_puppet_oslo-868298e248a64ab8.yaml new file mode 100644 index 000000000..a3a852623 --- /dev/null +++ b/releasenotes/notes/use_puppet_oslo-868298e248a64ab8.yaml @@ -0,0 +1,5 @@ +--- +features: + - Configure oslo related options (database, logging, messaging, policy) + using puppet-oslo module. + oslo.messaging related default values were changed to $::os_service_default diff --git a/spec/classes/neutron_db_spec.rb b/spec/classes/neutron_db_spec.rb index 2c5a14c0a..f99429a15 100644 --- a/spec/classes/neutron_db_spec.rb +++ b/spec/classes/neutron_db_spec.rb @@ -84,7 +84,7 @@ describe 'neutron::db' do { :database_connection => 'mysql+pymysql://neutron:neutron@localhost/neutron' } end - it { is_expected.to contain_package('neutron-backend-package').with({ :ensure => 'present', :name => 'python-pymysql' }) } + it { is_expected.to contain_package('db_backend_package').with({ :ensure => 'present', :name => 'python-pymysql' }) } end end @@ -104,7 +104,7 @@ describe 'neutron::db' do { :database_connection => 'mysql+pymysql://neutron:neutron@localhost/neutron' } end - it { is_expected.not_to contain_package('neutron-backend-package') } + it { is_expected.not_to contain_package('db_backend_package') } end end diff --git a/spec/classes/neutron_init_spec.rb b/spec/classes/neutron_init_spec.rb index 5752bdd81..c6ff8e629 100644 --- a/spec/classes/neutron_init_spec.rb +++ b/spec/classes/neutron_init_spec.rb @@ -6,10 +6,6 @@ describe 'neutron' do { :package_ensure => 'present', :core_plugin => 'linuxbridge', :auth_strategy => 'keystone', - :rabbit_hosts => false, - :rabbit_host => '127.0.0.1', - :rabbit_port => 5672, - :rabbit_user => 'guest', :rabbit_password => 'guest', :log_dir => '/var/log/neutron', :purge_config => false, @@ -29,10 +25,6 @@ describe 'neutron' do end context 'and if rabbit_hosts parameter is provided' do - before do - params.delete(:rabbit_host) - params.delete(:rabbit_port) - end context 'with one server' do before { params.merge!( :rabbit_hosts => ['127.0.0.1:5672'] ) } @@ -53,7 +45,7 @@ describe 'neutron' do end it 'configures logging' do - is_expected.to contain_neutron_config('DEFAULT/log_file').with_ensure('absent') + is_expected.to contain_neutron_config('DEFAULT/log_file').with_value('') is_expected.to contain_neutron_config('DEFAULT/log_dir').with_value(params[:log_dir]) is_expected.to contain_neutron_config('DEFAULT/use_stderr').with_value('') end @@ -82,7 +74,6 @@ describe 'neutron' do it_configures 'with syslog enabled' it_configures 'with syslog enabled and custom settings' it_configures 'with log_file specified' - it_configures 'with logging disabled' it_configures 'without service_plugins' it_configures 'with service_plugins' it_configures 'without memcache_servers' @@ -109,12 +100,12 @@ describe 'neutron' do end it 'configures credentials for rabbit' do - is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_userid').with_value( params[:rabbit_user] ) + is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_userid').with_value( '' ) is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_password').with_value( params[:rabbit_password] ) is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_password').with_secret( true ) is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value( '' ) - is_expected.to contain_neutron_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('0') - is_expected.to contain_neutron_config('oslo_messaging_rabbit/heartbeat_rate').with_value('2') + is_expected.to contain_neutron_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('') + is_expected.to contain_neutron_config('oslo_messaging_rabbit/heartbeat_rate').with_value('') is_expected.to contain_neutron_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value( '' ) end @@ -148,17 +139,17 @@ describe 'neutron' do shared_examples_for 'rabbit HA with a single virtual host' do it 'in neutron.conf' do - is_expected.not_to contain_neutron_config('oslo_messaging_rabbit/rabbit_host') - is_expected.not_to contain_neutron_config('oslo_messaging_rabbit/rabbit_port') + is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_host').with_value('') + is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_port').with_value('') is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_hosts').with_value( params[:rabbit_hosts] ) - is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value(true) + is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('') end end shared_examples_for 'rabbit HA with multiple hosts' do it 'in neutron.conf' do - is_expected.not_to contain_neutron_config('oslo_messaging_rabbit/rabbit_host') - is_expected.not_to contain_neutron_config('oslo_messaging_rabbit/rabbit_port') + is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_host').with_value('') + is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_port').with_value('') is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value(true) end @@ -286,23 +277,18 @@ describe 'neutron' do is_expected.to contain_neutron_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('') is_expected.to contain_neutron_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('') is_expected.to contain_neutron_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('') - is_expected.to contain_neutron_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('TLSv1') + is_expected.to contain_neutron_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('') end end shared_examples_for 'with SSL disabled' do - before do - params.merge!( - :kombu_ssl_version => 'TLSv1' - ) - end it do is_expected.to contain_neutron_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('') is_expected.to contain_neutron_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('') is_expected.to contain_neutron_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('') is_expected.to contain_neutron_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('') - is_expected.to contain_neutron_config('oslo_messaging_rabbit/kombu_ssl_version').with_ensure('absent') + is_expected.to contain_neutron_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('') end end @@ -392,17 +378,6 @@ describe 'neutron' do end end - shared_examples_for 'with logging disabled' do - before { params.merge!( - :log_file => false, - :log_dir => false - )} - it { - is_expected.to contain_neutron_config('DEFAULT/log_file').with_ensure('absent') - is_expected.to contain_neutron_config('DEFAULT/log_dir').with_ensure('absent') - } - end - shared_examples_for 'with state and lock paths set' do before { params.merge!( :state_path => 'state_path', diff --git a/spec/classes/neutron_policy_spec.rb b/spec/classes/neutron_policy_spec.rb index 1e3e734e2..8d9c3ebc5 100644 --- a/spec/classes/neutron_policy_spec.rb +++ b/spec/classes/neutron_policy_spec.rb @@ -27,6 +27,10 @@ describe 'neutron::policy' do :value => 'foo:bar' }) end + + it 'set policy_file in neutron.conf' do + is_expected.to contain_neutron_config('oslo_policy/policy_file').with_value(params[:policy_path]) + end end context 'on Debian platforms' do