mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Only check default_project on resource creation
The default_project is checked at the beginning of the module. This raises an exception if the project passed does not exist. This logic only makes sense on resource creation, if a user puts state=absent the module fails, even though the default project is not relevant
This commit is contained in:
parent
834bc225c9
commit
1b5288b703
1 changed files with 7 additions and 7 deletions
|
@ -169,13 +169,6 @@ def main():
|
||||||
cloud = shade.openstack_cloud(**module.params)
|
cloud = shade.openstack_cloud(**module.params)
|
||||||
user = cloud.get_user(name)
|
user = cloud.get_user(name)
|
||||||
|
|
||||||
project_id = None
|
|
||||||
if default_project:
|
|
||||||
project = cloud.get_project(default_project)
|
|
||||||
if not project:
|
|
||||||
module.fail_json(msg='Default project %s is not valid' % default_project)
|
|
||||||
project_id = project['id']
|
|
||||||
|
|
||||||
if domain:
|
if domain:
|
||||||
opcloud = shade.operator_cloud(**module.params)
|
opcloud = shade.operator_cloud(**module.params)
|
||||||
try:
|
try:
|
||||||
|
@ -193,6 +186,13 @@ def main():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
|
project_id = None
|
||||||
|
if default_project:
|
||||||
|
project = cloud.get_project(default_project)
|
||||||
|
if not project:
|
||||||
|
module.fail_json(msg='Default project %s is not valid' % default_project)
|
||||||
|
project_id = project['id']
|
||||||
|
|
||||||
if user is None:
|
if user is None:
|
||||||
user = cloud.create_user(
|
user = cloud.create_user(
|
||||||
name=name, password=password, email=email,
|
name=name, password=password, email=email,
|
||||||
|
|
Loading…
Add table
Reference in a new issue