Specify the default tenant during user create
If the project tenant is given when creating the user account, honor it by assigning that as the _default_ project tenant. This is especially helpful when creating initial service accounts and assigning them to the `service` project).
This commit is contained in:
parent
57e59b64e4
commit
03fbe7b7a3
@ -31,12 +31,14 @@ module OpenstackclientCookbook
|
|||||||
|
|
||||||
action :create do
|
action :create do
|
||||||
user = connection.users.find { |u| u.name == user_name }
|
user = connection.users.find { |u| u.name == user_name }
|
||||||
|
project = connection.projects.find { |p| p.name == project_name }
|
||||||
if user
|
if user
|
||||||
log "User with name: \"#{user_name}\" already exists"
|
log "User with name: \"#{user_name}\" already exists"
|
||||||
else
|
else
|
||||||
connection.users.create(
|
connection.users.create(
|
||||||
name: user_name,
|
name: user_name,
|
||||||
email: email,
|
email: email,
|
||||||
|
default_project_id: project ? project.id : nil,
|
||||||
password: password
|
password: password
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -65,6 +65,7 @@ describe 'openstackclient_test::user' do
|
|||||||
|
|
||||||
let(:found_project) do
|
let(:found_project) do
|
||||||
double :find,
|
double :find,
|
||||||
|
id: 42,
|
||||||
grant_role_to_user: true,
|
grant_role_to_user: true,
|
||||||
revoke_role_from_user: true
|
revoke_role_from_user: true
|
||||||
end
|
end
|
||||||
@ -133,6 +134,7 @@ describe 'openstackclient_test::user' do
|
|||||||
.with(
|
.with(
|
||||||
name: 'myuser',
|
name: 'myuser',
|
||||||
email: 'myemail',
|
email: 'myemail',
|
||||||
|
default_project_id: 42,
|
||||||
password: 'mypassword'
|
password: 'mypassword'
|
||||||
)
|
)
|
||||||
chef_run
|
chef_run
|
||||||
|
Loading…
Reference in New Issue
Block a user