Merge pull request #497 from resmo/for-ansible
cloudstack: various improvements and cleanups
This commit is contained in:
commit
1b750d6540
11 changed files with 144 additions and 81 deletions
|
@ -97,7 +97,6 @@ extends_documentation_fragment: cloudstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
---
|
|
||||||
# create an account in domain 'CUSTOMERS'
|
# create an account in domain 'CUSTOMERS'
|
||||||
local_action:
|
local_action:
|
||||||
module: cs_account
|
module: cs_account
|
||||||
|
@ -366,7 +365,7 @@ def main():
|
||||||
timezone = dict(default=None),
|
timezone = dict(default=None),
|
||||||
poll_async = dict(choices=BOOLEANS, default=True),
|
poll_async = dict(choices=BOOLEANS, default=True),
|
||||||
api_key = dict(default=None),
|
api_key = dict(default=None),
|
||||||
api_secret = dict(default=None),
|
api_secret = dict(default=None, no_log=True),
|
||||||
api_url = dict(default=None),
|
api_url = dict(default=None),
|
||||||
api_http_method = dict(default='get'),
|
api_http_method = dict(default='get'),
|
||||||
),
|
),
|
||||||
|
@ -401,6 +400,9 @@ def main():
|
||||||
except CloudStackException, e:
|
except CloudStackException, e:
|
||||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg='Exception: %s' % str(e))
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
|
@ -47,6 +47,16 @@ options:
|
||||||
required: false
|
required: false
|
||||||
default: 'present'
|
default: 'present'
|
||||||
choices: [ 'present', 'absent' ]
|
choices: [ 'present', 'absent' ]
|
||||||
|
domain:
|
||||||
|
description:
|
||||||
|
- Domain the affinity group is related to.
|
||||||
|
required: false
|
||||||
|
default: null
|
||||||
|
account:
|
||||||
|
description:
|
||||||
|
- Account the affinity group is related to.
|
||||||
|
required: false
|
||||||
|
default: null
|
||||||
poll_async:
|
poll_async:
|
||||||
description:
|
description:
|
||||||
- Poll async jobs until job has finished.
|
- Poll async jobs until job has finished.
|
||||||
|
@ -56,7 +66,6 @@ extends_documentation_fragment: cloudstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
---
|
|
||||||
# Create a affinity group
|
# Create a affinity group
|
||||||
- local_action:
|
- local_action:
|
||||||
module: cs_affinitygroup
|
module: cs_affinitygroup
|
||||||
|
@ -104,20 +113,21 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
AnsibleCloudStack.__init__(self, module)
|
||||||
self.result = {
|
|
||||||
'changed': False,
|
|
||||||
}
|
|
||||||
self.affinity_group = None
|
self.affinity_group = None
|
||||||
|
|
||||||
|
|
||||||
def get_affinity_group(self):
|
def get_affinity_group(self):
|
||||||
if not self.affinity_group:
|
if not self.affinity_group:
|
||||||
affinity_group_name = self.module.params.get('name')
|
affinity_group = self.module.params.get('name')
|
||||||
|
|
||||||
affinity_groups = self.cs.listAffinityGroups()
|
args = {}
|
||||||
|
args['account'] = self.get_account('name')
|
||||||
|
args['domainid'] = self.get_domain('id')
|
||||||
|
|
||||||
|
affinity_groups = self.cs.listAffinityGroups(**args)
|
||||||
if affinity_groups:
|
if affinity_groups:
|
||||||
for a in affinity_groups['affinitygroup']:
|
for a in affinity_groups['affinitygroup']:
|
||||||
if a['name'] == affinity_group_name:
|
if affinity_group in [ a['name'], a['id'] ]:
|
||||||
self.affinity_group = a
|
self.affinity_group = a
|
||||||
break
|
break
|
||||||
return self.affinity_group
|
return self.affinity_group
|
||||||
|
@ -146,6 +156,8 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
||||||
args['name'] = self.module.params.get('name')
|
args['name'] = self.module.params.get('name')
|
||||||
args['type'] = self.get_affinity_type()
|
args['type'] = self.get_affinity_type()
|
||||||
args['description'] = self.module.params.get('description')
|
args['description'] = self.module.params.get('description')
|
||||||
|
args['account'] = self.get_account('name')
|
||||||
|
args['domainid'] = self.get_domain('id')
|
||||||
|
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
res = self.cs.createAffinityGroup(**args)
|
res = self.cs.createAffinityGroup(**args)
|
||||||
|
@ -156,7 +168,6 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
||||||
poll_async = self.module.params.get('poll_async')
|
poll_async = self.module.params.get('poll_async')
|
||||||
if res and poll_async:
|
if res and poll_async:
|
||||||
affinity_group = self._poll_job(res, 'affinitygroup')
|
affinity_group = self._poll_job(res, 'affinitygroup')
|
||||||
|
|
||||||
return affinity_group
|
return affinity_group
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,6 +178,8 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
||||||
|
|
||||||
args = {}
|
args = {}
|
||||||
args['name'] = self.module.params.get('name')
|
args['name'] = self.module.params.get('name')
|
||||||
|
args['account'] = self.get_account('name')
|
||||||
|
args['domainid'] = self.get_domain('id')
|
||||||
|
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
res = self.cs.deleteAffinityGroup(**args)
|
res = self.cs.deleteAffinityGroup(**args)
|
||||||
|
@ -177,7 +190,6 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
||||||
poll_async = self.module.params.get('poll_async')
|
poll_async = self.module.params.get('poll_async')
|
||||||
if res and poll_async:
|
if res and poll_async:
|
||||||
res = self._poll_job(res, 'affinitygroup')
|
res = self._poll_job(res, 'affinitygroup')
|
||||||
|
|
||||||
return affinity_group
|
return affinity_group
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,6 +201,10 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
||||||
self.result['description'] = affinity_group['description']
|
self.result['description'] = affinity_group['description']
|
||||||
if 'type' in affinity_group:
|
if 'type' in affinity_group:
|
||||||
self.result['affinity_type'] = affinity_group['type']
|
self.result['affinity_type'] = affinity_group['type']
|
||||||
|
if 'domain' in affinity_group:
|
||||||
|
self.result['domain'] = affinity_group['domain']
|
||||||
|
if 'account' in affinity_group:
|
||||||
|
self.result['account'] = affinity_group['account']
|
||||||
return self.result
|
return self.result
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,9 +215,11 @@ def main():
|
||||||
affinty_type = dict(default=None),
|
affinty_type = dict(default=None),
|
||||||
description = dict(default=None),
|
description = dict(default=None),
|
||||||
state = dict(choices=['present', 'absent'], default='present'),
|
state = dict(choices=['present', 'absent'], default='present'),
|
||||||
|
domain = dict(default=None),
|
||||||
|
account = dict(default=None),
|
||||||
poll_async = dict(choices=BOOLEANS, default=True),
|
poll_async = dict(choices=BOOLEANS, default=True),
|
||||||
api_key = dict(default=None),
|
api_key = dict(default=None),
|
||||||
api_secret = dict(default=None),
|
api_secret = dict(default=None, no_log=True),
|
||||||
api_url = dict(default=None),
|
api_url = dict(default=None),
|
||||||
api_http_method = dict(default='get'),
|
api_http_method = dict(default='get'),
|
||||||
),
|
),
|
||||||
|
@ -225,6 +243,9 @@ def main():
|
||||||
except CloudStackException, e:
|
except CloudStackException, e:
|
||||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg='Exception: %s' % str(e))
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
|
@ -88,7 +88,6 @@ extends_documentation_fragment: cloudstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
---
|
|
||||||
# Allow inbound port 80/tcp from 1.2.3.4 to 4.3.2.1
|
# Allow inbound port 80/tcp from 1.2.3.4 to 4.3.2.1
|
||||||
- local_action:
|
- local_action:
|
||||||
module: cs_firewall
|
module: cs_firewall
|
||||||
|
@ -171,9 +170,6 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
AnsibleCloudStack.__init__(self, module)
|
||||||
self.result = {
|
|
||||||
'changed': False,
|
|
||||||
}
|
|
||||||
self.firewall_rule = None
|
self.firewall_rule = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -303,7 +299,7 @@ def main():
|
||||||
account = dict(default=None),
|
account = dict(default=None),
|
||||||
project = dict(default=None),
|
project = dict(default=None),
|
||||||
api_key = dict(default=None),
|
api_key = dict(default=None),
|
||||||
api_secret = dict(default=None),
|
api_secret = dict(default=None, no_log=True),
|
||||||
api_url = dict(default=None),
|
api_url = dict(default=None),
|
||||||
api_http_method = dict(default='get'),
|
api_http_method = dict(default='get'),
|
||||||
),
|
),
|
||||||
|
@ -331,6 +327,9 @@ def main():
|
||||||
except CloudStackException, e:
|
except CloudStackException, e:
|
||||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg='Exception: %s' % str(e))
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
|
@ -164,7 +164,6 @@ extends_documentation_fragment: cloudstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
---
|
|
||||||
# Create a instance on CloudStack from an ISO
|
# Create a instance on CloudStack from an ISO
|
||||||
# NOTE: Names of offerings and ISOs depending on the CloudStack configuration.
|
# NOTE: Names of offerings and ISOs depending on the CloudStack configuration.
|
||||||
- local_action:
|
- local_action:
|
||||||
|
@ -537,7 +536,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
||||||
args_instance_update['group'] = self.module.params.get('group')
|
args_instance_update['group'] = self.module.params.get('group')
|
||||||
args_instance_update['displayname'] = self.get_display_name()
|
args_instance_update['displayname'] = self.get_display_name()
|
||||||
args_instance_update['userdata'] = self.get_user_data()
|
args_instance_update['userdata'] = self.get_user_data()
|
||||||
args_instance_update['ostypeid'] = self.get_os_type_id()
|
args_instance_update['ostypeid'] = self.get_os_type('id')
|
||||||
|
|
||||||
args_ssh_key = {}
|
args_ssh_key = {}
|
||||||
args_ssh_key['id'] = instance['id']
|
args_ssh_key['id'] = instance['id']
|
||||||
|
@ -785,7 +784,7 @@ def main():
|
||||||
tags = dict(type='list', aliases=[ 'tag' ], default=None),
|
tags = dict(type='list', aliases=[ 'tag' ], default=None),
|
||||||
poll_async = dict(choices=BOOLEANS, default=True),
|
poll_async = dict(choices=BOOLEANS, default=True),
|
||||||
api_key = dict(default=None),
|
api_key = dict(default=None),
|
||||||
api_secret = dict(default=None),
|
api_secret = dict(default=None, no_log=True),
|
||||||
api_url = dict(default=None),
|
api_url = dict(default=None),
|
||||||
api_http_method = dict(default='get'),
|
api_http_method = dict(default='get'),
|
||||||
),
|
),
|
||||||
|
@ -826,6 +825,9 @@ def main():
|
||||||
except CloudStackException, e:
|
except CloudStackException, e:
|
||||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg='Exception: %s' % str(e))
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
|
@ -56,7 +56,6 @@ extends_documentation_fragment: cloudstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
---
|
|
||||||
# Create an instance group
|
# Create an instance group
|
||||||
- local_action:
|
- local_action:
|
||||||
module: cs_instancegroup
|
module: cs_instancegroup
|
||||||
|
@ -197,7 +196,7 @@ def main():
|
||||||
account = dict(default=None),
|
account = dict(default=None),
|
||||||
project = dict(default=None),
|
project = dict(default=None),
|
||||||
api_key = dict(default=None),
|
api_key = dict(default=None),
|
||||||
api_secret = dict(default=None),
|
api_secret = dict(default=None, no_log=True),
|
||||||
api_url = dict(default=None),
|
api_url = dict(default=None),
|
||||||
api_http_method = dict(default='get'),
|
api_http_method = dict(default='get'),
|
||||||
),
|
),
|
||||||
|
@ -221,6 +220,9 @@ def main():
|
||||||
except CloudStackException, e:
|
except CloudStackException, e:
|
||||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg='Exception: %s' % str(e))
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
|
@ -73,6 +73,16 @@ options:
|
||||||
- Register the ISO to be bootable. Only used if C(state) is present.
|
- Register the ISO to be bootable. Only used if C(state) is present.
|
||||||
required: false
|
required: false
|
||||||
default: true
|
default: true
|
||||||
|
domain:
|
||||||
|
description:
|
||||||
|
- Domain the ISO is related to.
|
||||||
|
required: false
|
||||||
|
default: null
|
||||||
|
account:
|
||||||
|
description:
|
||||||
|
- Account the ISO is related to.
|
||||||
|
required: false
|
||||||
|
default: null
|
||||||
project:
|
project:
|
||||||
description:
|
description:
|
||||||
- Name of the project the ISO to be registered in.
|
- Name of the project the ISO to be registered in.
|
||||||
|
@ -99,7 +109,6 @@ extends_documentation_fragment: cloudstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
---
|
|
||||||
# Register an ISO if ISO name does not already exist.
|
# Register an ISO if ISO name does not already exist.
|
||||||
- local_action:
|
- local_action:
|
||||||
module: cs_iso
|
module: cs_iso
|
||||||
|
@ -169,6 +178,21 @@ created:
|
||||||
returned: success
|
returned: success
|
||||||
type: string
|
type: string
|
||||||
sample: 2015-03-29T14:57:06+0200
|
sample: 2015-03-29T14:57:06+0200
|
||||||
|
domain:
|
||||||
|
description: Domain the ISO is related to.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: example domain
|
||||||
|
account:
|
||||||
|
description: Account the ISO is related to.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: example account
|
||||||
|
project:
|
||||||
|
description: Project the ISO is related to.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: example project
|
||||||
'''
|
'''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -185,27 +209,19 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
AnsibleCloudStack.__init__(self, module)
|
||||||
self.result = {
|
|
||||||
'changed': False,
|
|
||||||
}
|
|
||||||
self.iso = None
|
self.iso = None
|
||||||
|
|
||||||
def register_iso(self):
|
def register_iso(self):
|
||||||
iso = self.get_iso()
|
iso = self.get_iso()
|
||||||
if not iso:
|
if not iso:
|
||||||
|
|
||||||
args = {}
|
args = {}
|
||||||
args['zoneid'] = self.get_zone_id()
|
args['zoneid'] = self.get_zone('id')
|
||||||
args['projectid'] = self.get_project_id()
|
args['domainid'] = self.get_domain('id')
|
||||||
|
args['account'] = self.get_account('name')
|
||||||
|
args['projectid'] = self.get_project('id')
|
||||||
args['bootable'] = self.module.params.get('bootable')
|
args['bootable'] = self.module.params.get('bootable')
|
||||||
args['ostypeid'] = self.get_os_type_id()
|
args['ostypeid'] = self.get_os_type('id')
|
||||||
if args['bootable'] and not args['ostypeid']:
|
|
||||||
self.module.fail_json(msg="OS type 'os_type' is requried if 'bootable=true'.")
|
|
||||||
|
|
||||||
args['url'] = self.module.params.get('url')
|
|
||||||
if not args['url']:
|
|
||||||
self.module.fail_json(msg="URL is requried.")
|
|
||||||
|
|
||||||
args['name'] = self.module.params.get('name')
|
args['name'] = self.module.params.get('name')
|
||||||
args['displaytext'] = self.module.params.get('name')
|
args['displaytext'] = self.module.params.get('name')
|
||||||
args['checksum'] = self.module.params.get('checksum')
|
args['checksum'] = self.module.params.get('checksum')
|
||||||
|
@ -213,6 +229,13 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
||||||
args['isfeatured'] = self.module.params.get('is_featured')
|
args['isfeatured'] = self.module.params.get('is_featured')
|
||||||
args['ispublic'] = self.module.params.get('is_public')
|
args['ispublic'] = self.module.params.get('is_public')
|
||||||
|
|
||||||
|
if args['bootable'] and not args['ostypeid']:
|
||||||
|
self.module.fail_json(msg="OS type 'os_type' is requried if 'bootable=true'.")
|
||||||
|
|
||||||
|
args['url'] = self.module.params.get('url')
|
||||||
|
if not args['url']:
|
||||||
|
self.module.fail_json(msg="URL is requried.")
|
||||||
|
|
||||||
self.result['changed'] = True
|
self.result['changed'] = True
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
res = self.cs.registerIso(**args)
|
res = self.cs.registerIso(**args)
|
||||||
|
@ -222,11 +245,14 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
||||||
|
|
||||||
def get_iso(self):
|
def get_iso(self):
|
||||||
if not self.iso:
|
if not self.iso:
|
||||||
|
|
||||||
args = {}
|
args = {}
|
||||||
args['isready'] = self.module.params.get('is_ready')
|
args['isready'] = self.module.params.get('is_ready')
|
||||||
args['isofilter'] = self.module.params.get('iso_filter')
|
args['isofilter'] = self.module.params.get('iso_filter')
|
||||||
args['projectid'] = self.get_project_id()
|
args['domainid'] = self.get_domain('id')
|
||||||
args['zoneid'] = self.get_zone_id()
|
args['account'] = self.get_account('name')
|
||||||
|
args['projectid'] = self.get_project('id')
|
||||||
|
args['zoneid'] = self.get_zone('id')
|
||||||
|
|
||||||
# if checksum is set, we only look on that.
|
# if checksum is set, we only look on that.
|
||||||
checksum = self.module.params.get('checksum')
|
checksum = self.module.params.get('checksum')
|
||||||
|
@ -249,10 +275,12 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
||||||
iso = self.get_iso()
|
iso = self.get_iso()
|
||||||
if iso:
|
if iso:
|
||||||
self.result['changed'] = True
|
self.result['changed'] = True
|
||||||
|
|
||||||
args = {}
|
args = {}
|
||||||
args['id'] = iso['id']
|
args['id'] = iso['id']
|
||||||
args['projectid'] = self.get_project_id()
|
args['projectid'] = self.get_project('id')
|
||||||
args['zoneid'] = self.get_zone_id()
|
args['zoneid'] = self.get_zone('id')
|
||||||
|
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
res = self.cs.deleteIso(**args)
|
res = self.cs.deleteIso(**args)
|
||||||
return iso
|
return iso
|
||||||
|
@ -274,17 +302,25 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
||||||
self.result['is_ready'] = iso['isready']
|
self.result['is_ready'] = iso['isready']
|
||||||
if 'created' in iso:
|
if 'created' in iso:
|
||||||
self.result['created'] = iso['created']
|
self.result['created'] = iso['created']
|
||||||
|
if 'project' in iso:
|
||||||
|
self.result['project'] = iso['project']
|
||||||
|
if 'domain' in iso:
|
||||||
|
self.result['domain'] = iso['domain']
|
||||||
|
if 'account' in iso:
|
||||||
|
self.result['account'] = iso['account']
|
||||||
return self.result
|
return self.result
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
name = dict(required=True, default=None),
|
name = dict(required=True),
|
||||||
url = dict(default=None),
|
url = dict(default=None),
|
||||||
os_type = dict(default=None),
|
os_type = dict(default=None),
|
||||||
zone = dict(default=None),
|
zone = dict(default=None),
|
||||||
iso_filter = dict(default='self', choices=[ 'featured', 'self', 'selfexecutable','sharedexecutable','executable', 'community' ]),
|
iso_filter = dict(default='self', choices=[ 'featured', 'self', 'selfexecutable','sharedexecutable','executable', 'community' ]),
|
||||||
|
domain = dict(default=None),
|
||||||
|
account = dict(default=None),
|
||||||
project = dict(default=None),
|
project = dict(default=None),
|
||||||
checksum = dict(default=None),
|
checksum = dict(default=None),
|
||||||
is_ready = dict(choices=BOOLEANS, default=False),
|
is_ready = dict(choices=BOOLEANS, default=False),
|
||||||
|
@ -293,7 +329,7 @@ def main():
|
||||||
is_dynamically_scalable = dict(choices=BOOLEANS, default=False),
|
is_dynamically_scalable = dict(choices=BOOLEANS, default=False),
|
||||||
state = dict(choices=['present', 'absent'], default='present'),
|
state = dict(choices=['present', 'absent'], default='present'),
|
||||||
api_key = dict(default=None),
|
api_key = dict(default=None),
|
||||||
api_secret = dict(default=None),
|
api_secret = dict(default=None, no_log=True),
|
||||||
api_url = dict(default=None),
|
api_url = dict(default=None),
|
||||||
api_http_method = dict(default='get'),
|
api_http_method = dict(default='get'),
|
||||||
),
|
),
|
||||||
|
@ -317,6 +353,9 @@ def main():
|
||||||
except CloudStackException, e:
|
except CloudStackException, e:
|
||||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg='Exception: %s' % str(e))
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
|
@ -106,7 +106,6 @@ extends_documentation_fragment: cloudstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
---
|
|
||||||
# 1.2.3.4:80 -> web01:8080
|
# 1.2.3.4:80 -> web01:8080
|
||||||
- local_action:
|
- local_action:
|
||||||
module: cs_portforward
|
module: cs_portforward
|
||||||
|
@ -144,7 +143,6 @@ EXAMPLES = '''
|
||||||
public_port: 22
|
public_port: 22
|
||||||
private_port: 22
|
private_port: 22
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
|
@ -402,7 +400,7 @@ def main():
|
||||||
project = dict(default=None),
|
project = dict(default=None),
|
||||||
poll_async = dict(choices=BOOLEANS, default=True),
|
poll_async = dict(choices=BOOLEANS, default=True),
|
||||||
api_key = dict(default=None),
|
api_key = dict(default=None),
|
||||||
api_secret = dict(default=None),
|
api_secret = dict(default=None, no_log=True),
|
||||||
api_url = dict(default=None),
|
api_url = dict(default=None),
|
||||||
api_http_method = dict(default='get'),
|
api_http_method = dict(default='get'),
|
||||||
),
|
),
|
||||||
|
@ -425,6 +423,9 @@ def main():
|
||||||
except CloudStackException, e:
|
except CloudStackException, e:
|
||||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg='Exception: %s' % str(e))
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
|
@ -51,7 +51,6 @@ extends_documentation_fragment: cloudstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
---
|
|
||||||
# Create a security group
|
# Create a security group
|
||||||
- local_action:
|
- local_action:
|
||||||
module: cs_securitygroup
|
module: cs_securitygroup
|
||||||
|
@ -94,9 +93,6 @@ class AnsibleCloudStackSecurityGroup(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
AnsibleCloudStack.__init__(self, module)
|
||||||
self.result = {
|
|
||||||
'changed': False,
|
|
||||||
}
|
|
||||||
self.security_group = None
|
self.security_group = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,7 +100,7 @@ class AnsibleCloudStackSecurityGroup(AnsibleCloudStack):
|
||||||
if not self.security_group:
|
if not self.security_group:
|
||||||
sg_name = self.module.params.get('name')
|
sg_name = self.module.params.get('name')
|
||||||
args = {}
|
args = {}
|
||||||
args['projectid'] = self.get_project_id()
|
args['projectid'] = self.get_project('id')
|
||||||
sgs = self.cs.listSecurityGroups(**args)
|
sgs = self.cs.listSecurityGroups(**args)
|
||||||
if sgs:
|
if sgs:
|
||||||
for s in sgs['securitygroup']:
|
for s in sgs['securitygroup']:
|
||||||
|
@ -121,7 +117,7 @@ class AnsibleCloudStackSecurityGroup(AnsibleCloudStack):
|
||||||
|
|
||||||
args = {}
|
args = {}
|
||||||
args['name'] = self.module.params.get('name')
|
args['name'] = self.module.params.get('name')
|
||||||
args['projectid'] = self.get_project_id()
|
args['projectid'] = self.get_project('id')
|
||||||
args['description'] = self.module.params.get('description')
|
args['description'] = self.module.params.get('description')
|
||||||
|
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
|
@ -140,7 +136,7 @@ class AnsibleCloudStackSecurityGroup(AnsibleCloudStack):
|
||||||
|
|
||||||
args = {}
|
args = {}
|
||||||
args['name'] = self.module.params.get('name')
|
args['name'] = self.module.params.get('name')
|
||||||
args['projectid'] = self.get_project_id()
|
args['projectid'] = self.get_project('id')
|
||||||
|
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
res = self.cs.deleteSecurityGroup(**args)
|
res = self.cs.deleteSecurityGroup(**args)
|
||||||
|
@ -167,7 +163,7 @@ def main():
|
||||||
state = dict(choices=['present', 'absent'], default='present'),
|
state = dict(choices=['present', 'absent'], default='present'),
|
||||||
project = dict(default=None),
|
project = dict(default=None),
|
||||||
api_key = dict(default=None),
|
api_key = dict(default=None),
|
||||||
api_secret = dict(default=None),
|
api_secret = dict(default=None, no_log=True),
|
||||||
api_url = dict(default=None),
|
api_url = dict(default=None),
|
||||||
api_http_method = dict(default='get'),
|
api_http_method = dict(default='get'),
|
||||||
),
|
),
|
||||||
|
@ -191,6 +187,9 @@ def main():
|
||||||
except CloudStackException, e:
|
except CloudStackException, e:
|
||||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg='Exception: %s' % str(e))
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
|
@ -194,9 +194,6 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
AnsibleCloudStack.__init__(self, module)
|
||||||
self.result = {
|
|
||||||
'changed': False,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def _tcp_udp_match(self, rule, protocol, start_port, end_port):
|
def _tcp_udp_match(self, rule, protocol, start_port, end_port):
|
||||||
|
@ -271,7 +268,7 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
|
||||||
security_group_name = self.module.params.get('security_group')
|
security_group_name = self.module.params.get('security_group')
|
||||||
args = {}
|
args = {}
|
||||||
args['securitygroupname'] = security_group_name
|
args['securitygroupname'] = security_group_name
|
||||||
args['projectid'] = self.get_project_id()
|
args['projectid'] = self.get_project('id')
|
||||||
sgs = self.cs.listSecurityGroups(**args)
|
sgs = self.cs.listSecurityGroups(**args)
|
||||||
if not sgs or 'securitygroup' not in sgs:
|
if not sgs or 'securitygroup' not in sgs:
|
||||||
self.module.fail_json(msg="security group '%s' not found" % security_group_name)
|
self.module.fail_json(msg="security group '%s' not found" % security_group_name)
|
||||||
|
@ -301,7 +298,7 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
|
||||||
args['endport'] = self.get_end_port()
|
args['endport'] = self.get_end_port()
|
||||||
args['icmptype'] = self.module.params.get('icmp_type')
|
args['icmptype'] = self.module.params.get('icmp_type')
|
||||||
args['icmpcode'] = self.module.params.get('icmp_code')
|
args['icmpcode'] = self.module.params.get('icmp_code')
|
||||||
args['projectid'] = self.get_project_id()
|
args['projectid'] = self.get_project('id')
|
||||||
args['securitygroupid'] = security_group['id']
|
args['securitygroupid'] = security_group['id']
|
||||||
|
|
||||||
rule = None
|
rule = None
|
||||||
|
@ -401,7 +398,7 @@ def main():
|
||||||
project = dict(default=None),
|
project = dict(default=None),
|
||||||
poll_async = dict(choices=BOOLEANS, default=True),
|
poll_async = dict(choices=BOOLEANS, default=True),
|
||||||
api_key = dict(default=None),
|
api_key = dict(default=None),
|
||||||
api_secret = dict(default=None),
|
api_secret = dict(default=None, no_log=True),
|
||||||
api_url = dict(default=None),
|
api_url = dict(default=None),
|
||||||
api_http_method = dict(default='get'),
|
api_http_method = dict(default='get'),
|
||||||
),
|
),
|
||||||
|
@ -431,6 +428,9 @@ def main():
|
||||||
except CloudStackException, e:
|
except CloudStackException, e:
|
||||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg='Exception: %s' % str(e))
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
|
@ -63,7 +63,6 @@ extends_documentation_fragment: cloudstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
---
|
|
||||||
# create a new private / public key pair:
|
# create a new private / public key pair:
|
||||||
- local_action: cs_sshkeypair name=linus@example.com
|
- local_action: cs_sshkeypair name=linus@example.com
|
||||||
register: key
|
register: key
|
||||||
|
@ -114,9 +113,6 @@ class AnsibleCloudStackSshKey(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
AnsibleCloudStack.__init__(self, module)
|
||||||
self.result = {
|
|
||||||
'changed': False,
|
|
||||||
}
|
|
||||||
self.ssh_key = None
|
self.ssh_key = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,7 +215,7 @@ def main():
|
||||||
project = dict(default=None),
|
project = dict(default=None),
|
||||||
state = dict(choices=['present', 'absent'], default='present'),
|
state = dict(choices=['present', 'absent'], default='present'),
|
||||||
api_key = dict(default=None),
|
api_key = dict(default=None),
|
||||||
api_secret = dict(default=None),
|
api_secret = dict(default=None, no_log=True),
|
||||||
api_url = dict(default=None),
|
api_url = dict(default=None),
|
||||||
api_http_method = dict(default='get'),
|
api_http_method = dict(default='get'),
|
||||||
),
|
),
|
||||||
|
@ -249,6 +245,9 @@ def main():
|
||||||
except CloudStackException, e:
|
except CloudStackException, e:
|
||||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg='Exception: %s' % str(e))
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
|
@ -81,7 +81,6 @@ extends_documentation_fragment: cloudstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
---
|
|
||||||
# Create a VM snapshot of disk and memory before an upgrade
|
# Create a VM snapshot of disk and memory before an upgrade
|
||||||
- local_action:
|
- local_action:
|
||||||
module: cs_vmsnapshot
|
module: cs_vmsnapshot
|
||||||
|
@ -175,9 +174,6 @@ class AnsibleCloudStackVmSnapshot(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
AnsibleCloudStack.__init__(self, module)
|
||||||
self.result = {
|
|
||||||
'changed': False,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def get_snapshot(self):
|
def get_snapshot(self):
|
||||||
|
@ -292,7 +288,7 @@ def main():
|
||||||
project = dict(default=None),
|
project = dict(default=None),
|
||||||
poll_async = dict(choices=BOOLEANS, default=True),
|
poll_async = dict(choices=BOOLEANS, default=True),
|
||||||
api_key = dict(default=None),
|
api_key = dict(default=None),
|
||||||
api_secret = dict(default=None),
|
api_secret = dict(default=None, no_log=True),
|
||||||
api_url = dict(default=None),
|
api_url = dict(default=None),
|
||||||
api_http_method = dict(default='get'),
|
api_http_method = dict(default='get'),
|
||||||
),
|
),
|
||||||
|
@ -318,6 +314,9 @@ def main():
|
||||||
except CloudStackException, e:
|
except CloudStackException, e:
|
||||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg='Exception: %s' % str(e))
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
Loading…
Reference in a new issue