Enable use of empty manageiq arguments (#31774)

* anable use of empty manageiq arguments

* make default verify_ssl true
This commit is contained in:
Yaacov Zamir 2017-10-23 14:33:57 +03:00 committed by René Moser
parent 6693cc3f5a
commit 2765ee4b9a
4 changed files with 34 additions and 25 deletions

View file

@ -37,7 +37,7 @@ except ImportError:
def manageiq_argument_spec(): def manageiq_argument_spec():
return dict( options = dict(
url=dict(default=os.environ.get('MIQ_URL', None)), url=dict(default=os.environ.get('MIQ_URL', None)),
username=dict(default=os.environ.get('MIQ_USERNAME', None)), username=dict(default=os.environ.get('MIQ_USERNAME', None)),
password=dict(default=os.environ.get('MIQ_PASSWORD', None), no_log=True), password=dict(default=os.environ.get('MIQ_PASSWORD', None), no_log=True),
@ -46,6 +46,12 @@ def manageiq_argument_spec():
ca_bundle_path=dict(required=False, default=None), ca_bundle_path=dict(required=False, default=None),
) )
return dict(
manageiq_connection=dict(type='dict',
default=dict(verify_ssl=True),
options=options),
)
def check_client(module): def check_client(module):
if not HAS_CLIENT: if not HAS_CLIENT:

View file

@ -548,14 +548,14 @@ def main():
zone_id = None zone_id = None
endpoints = [] endpoints = []
argument_spec = dict( argument_spec = dict(
manageiq_connection=dict(required=True, type='dict',
options=manageiq_argument_spec()),
state=dict(choices=['absent', 'present'], default='present'), state=dict(choices=['absent', 'present'], default='present'),
name=dict(required=True), name=dict(required=True),
zone=dict(default='default'), zone=dict(default='default'),
provider_region=dict(), provider_region=dict(),
type=dict(choices=supported_providers().keys()), type=dict(choices=supported_providers().keys()),
) )
# add the manageiq connection arguments to the arguments
argument_spec.update(manageiq_argument_spec())
# add the endpoint arguments to the arguments # add the endpoint arguments to the arguments
argument_spec.update(endpoint_list_spec()) argument_spec.update(endpoint_list_spec())

View file

@ -246,18 +246,19 @@ class ManageIQTags(object):
def main(): def main():
actions = {'present': 'assign', 'absent': 'unassign', 'list': 'list'} actions = {'present': 'assign', 'absent': 'unassign', 'list': 'list'}
argument_spec = dict(
tags=dict(type='list'),
resource_name=dict(required=True, type='str'),
resource_type=dict(required=True, type='str',
choices=manageiq_entities().keys()),
state=dict(required=False, type='str',
choices=['present', 'absent', 'list'], default='present'),
)
# add the manageiq connection arguments to the arguments
argument_spec.update(manageiq_argument_spec())
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=argument_spec,
manageiq_connection=dict(required=True, type='dict',
options=manageiq_argument_spec()),
tags=dict(type='list'),
resource_name=dict(required=True, type='str'),
resource_type=dict(required=True, type='str',
choices=manageiq_entities().keys()),
state=dict(required=False, type='str',
choices=['present', 'absent', 'list'], default='present'),
),
required_if=[ required_if=[
('state', 'present', ['tags']), ('state', 'present', ['tags']),
('state', 'absent', ['tags']) ('state', 'absent', ['tags'])

View file

@ -283,19 +283,21 @@ class ManageIQUser(object):
def main(): def main():
argument_spec = dict(
userid=dict(required=True, type='str'),
name=dict(),
password=dict(no_log=True),
group=dict(),
email=dict(),
state=dict(choices=['absent', 'present'], default='present'),
update_password=dict(choices=['always', 'on_create'],
default='always'),
)
# add the manageiq connection arguments to the arguments
argument_spec.update(manageiq_argument_spec())
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=argument_spec,
manageiq_connection=dict(required=True, type='dict',
options=manageiq_argument_spec()),
userid=dict(required=True, type='str'),
name=dict(),
password=dict(no_log=True),
group=dict(),
email=dict(),
state=dict(choices=['absent', 'present'], default='present'),
update_password=dict(choices=['always', 'on_create'],
default='always'),
),
) )
userid = module.params['userid'] userid = module.params['userid']