diff --git a/manifests/api.pp b/manifests/api.pp index bc1bcc7cd..72844a7c2 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -49,8 +49,10 @@ # Defaults to $::os_workers # # [*instance_name_template*] -# (optional) Template string to be used to generate instance names -# Defaults to $::os_service_default +# (optional) Template string to be used to generate instance names. Using +# this parameter might cause incomplete settings in case nova services are +# distributed among multiple nodes. +# Defaults to undef # # [*sync_db*] # (optional) Run nova-manage db sync on api nodes after installing the package. @@ -191,7 +193,7 @@ class nova::api( $sync_db = true, $sync_db_api = true, $db_online_data_migrations = false, - $instance_name_template = $::os_service_default, + $instance_name_template = undef, $service_name = $::nova::params::api_service_name, $metadata_service_name = $::nova::params::api_metadata_service_name, $enable_proxy_headers_parsing = $::os_service_default, @@ -238,8 +240,20 @@ class nova::api( warning('The use_forwarded_for parameter has been deprecated.') } - nova_config { - 'DEFAULT/instance_name_template': value => $instance_name_template; + if $instance_name_template != undef { + warning("The nova::api::instance_name_template parameter may result \ +in incomplete settings in case nova services are distributed among multiple \ +nodes. Use the nova::instance_name_template parameter instead.") + nova_config { + 'DEFAULT/instance_name_template': value => $instance_name_template; + } + } else { + # Try best to clean up the parameter + if defined(Class['nova']) and $::nova::instance_name_template == undef { + nova_config { + 'DEFAULT/instance_name_template': value => $::os_service_default; + } + } } # enable metadata in eventlet if we do not run metadata via wsgi (nova::metadata) diff --git a/manifests/init.pp b/manifests/init.pp index 8c0185b65..72dd6e0b9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -356,6 +356,10 @@ # (optional) domain to use for building the hostnames # Defaults to $::os_service_default # +# [*instance_name_template*] +# (optional) Template string to be used to generate instance names +# Defaults to undef +# # DEPRECATED PARAMETERS # # [*auth_strategy*] @@ -459,6 +463,7 @@ class nova( $purge_config = false, $my_ip = $::os_service_default, $dhcp_domain = $::os_service_default, + $instance_name_template = undef, # DEPRECATED PARAMETERS $auth_strategy = undef, $os_region_name = undef, @@ -594,6 +599,14 @@ but should be one of: ssh-rsa, ssh-dsa, ssh-ecdsa.") 'DEFAULT/dhcp_domain': value => $dhcp_domain; } + # TODO(tkajinam): Change the default value to $::os_service_default when we + # remove nova::api::instance_name_template after Antelope. + if $instance_name_template != undef { + nova_config { + 'DEFAULT/instance_name_template': value => $instance_name_template; + } + } + oslo::messaging::rabbit {'nova_config': rabbit_use_ssl => $rabbit_use_ssl, heartbeat_timeout_threshold => $rabbit_heartbeat_timeout_threshold, diff --git a/releasenotes/notes/move-instance_name_template-to-base-52516c9df907a8c6.yaml b/releasenotes/notes/move-instance_name_template-to-base-52516c9df907a8c6.yaml new file mode 100644 index 000000000..4c9801171 --- /dev/null +++ b/releasenotes/notes/move-instance_name_template-to-base-52516c9df907a8c6.yaml @@ -0,0 +1,9 @@ +--- +features: + - | + The new ``nova::instance_name_template`` parameter has been added so that + the ``[DEFAULT] instance_name_template`` option can be configured for + not only nova-api but also the other nova services. + The ``nova::api::instance_name_template`` parameter is still supported but + is no loger recomemnded because it can cause incomplete configurations in + case nova services are deployed in different nodes. diff --git a/spec/classes/nova_init_spec.rb b/spec/classes/nova_init_spec.rb index 5b6e7438d..25630757a 100644 --- a/spec/classes/nova_init_spec.rb +++ b/spec/classes/nova_init_spec.rb @@ -96,6 +96,9 @@ describe 'nova' do is_expected.to contain_nova_config('console/ssl_ciphers').with_value('') is_expected.to contain_nova_config('console/ssl_minimum_version').with_value('') is_expected.to contain_nova_config('DEFAULT/dhcp_domain').with_value('') + # TODO(tkajinam): Uncomment this when we change default value of + # nova::instance_name_template + # is_expected.to contain_nova_config('DEFAULT/instance_name_template').with_value('') end end @@ -155,7 +158,7 @@ describe 'nova' do :console_ssl_ciphers => 'kEECDH+aECDSA+AES:kEECDH+AES+aRSA:kEDH+aRSA+AES', :console_ssl_minimum_version => 'tlsv1_2', :dhcp_domain => 'foo', - + :instance_name_template => 'instance-%08x', } end @@ -248,6 +251,7 @@ describe 'nova' do is_expected.to contain_nova_config('console/ssl_ciphers').with_value('kEECDH+aECDSA+AES:kEECDH+AES+aRSA:kEDH+aRSA+AES') is_expected.to contain_nova_config('console/ssl_minimum_version').with_value('tlsv1_2') is_expected.to contain_nova_config('DEFAULT/dhcp_domain').with_value('foo') + is_expected.to contain_nova_config('DEFAULT/instance_name_template').with_value('instance-%08x'); end context 'with multiple notification_driver' do