Support setting instance_user to an empty string

This deals with the case where you don't want heat setting instance_user
for you. See
http://lists.openstack.org/pipermail/openstack-dev/2015-June/068333.html
for details.

Closes-Bug: #1472053

Change-Id: I9e8be0dd50709d271fc81683770c78380724e405
(cherry picked from commit c06b8cbc34)
This commit is contained in:
Matt Fischer 2015-06-30 09:50:49 -06:00 committed by Gael Chamoulaud
parent 0d6f6cdb98
commit a8e1ab6c19
2 changed files with 20 additions and 3 deletions

View File

@ -158,7 +158,9 @@
# [*instance_user*]
# (Optional) The default user for new instances. Although heat claims that
# this feature is deprecated, it still sets the users to ec2-user if
# you leave this unset. This will likely be deprecated in K or L.
# you leave this unset. If you want heat to not set instance_user to
# ec2-user, you need to set this to an empty string. This feature has been
# deprecated for some time and will likely be removed in L or M.
#
# [*enable_stack_adopt*]
# (Optional) Enable the stack-adopt feature.
@ -558,7 +560,10 @@ class heat(
}
# instance_user
if $instance_user {
# special case for empty string since it's a valid value
if $instance_user == '' {
heat_config { 'DEFAULT/instance_user': value => ''; }
} elsif $instance_user {
heat_config { 'DEFAULT/instance_user': value => $instance_user; }
} else {
heat_config { 'DEFAULT/instance_user': ensure => absent; }

View File

@ -459,7 +459,7 @@ describe 'heat' do
end
end
shared_examples_for 'with instance_user set' do
shared_examples_for 'with instance_user set to a string' do
before do
params.merge!(
:instance_user => "fred",
@ -471,6 +471,18 @@ describe 'heat' do
end
end
shared_examples_for 'with instance_user set to an empty string' do
before do
params.merge!(
:instance_user => "",
)
end
it 'has instance_user set to an empty string when specified' do
is_expected.to contain_heat_config('DEFAULT/instance_user').with_value('')
end
end
shared_examples_for 'without instance_user set' do
it 'doesnt have instance_user set by default' do
is_expected.to contain_heat_config('DEFAULT/instance_user').with_enure('absent')