|
|
@ -42,6 +42,16 @@ options:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
default: 'present'
|
|
|
|
default: 'present'
|
|
|
|
choices: [ 'present', 'absent' ]
|
|
|
|
choices: [ 'present', 'absent' ]
|
|
|
|
|
|
|
|
domain:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Domain the security group is related to.
|
|
|
|
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
|
|
|
|
account:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Account the security group is related to.
|
|
|
|
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
project:
|
|
|
|
project:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Name of the project the security group to be created in.
|
|
|
|
- Name of the project the security group to be created in.
|
|
|
@ -81,6 +91,26 @@ description:
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: string
|
|
|
|
type: string
|
|
|
|
sample: application security group
|
|
|
|
sample: application security group
|
|
|
|
|
|
|
|
tags:
|
|
|
|
|
|
|
|
description: List of resource tags associated with the security group.
|
|
|
|
|
|
|
|
returned: success
|
|
|
|
|
|
|
|
type: dict
|
|
|
|
|
|
|
|
sample: '[ { "key": "foo", "value": "bar" } ]'
|
|
|
|
|
|
|
|
project:
|
|
|
|
|
|
|
|
description: Name of project the security group is related to.
|
|
|
|
|
|
|
|
returned: success
|
|
|
|
|
|
|
|
type: string
|
|
|
|
|
|
|
|
sample: Production
|
|
|
|
|
|
|
|
domain:
|
|
|
|
|
|
|
|
description: Domain the security group is related to.
|
|
|
|
|
|
|
|
returned: success
|
|
|
|
|
|
|
|
type: string
|
|
|
|
|
|
|
|
sample: example domain
|
|
|
|
|
|
|
|
account:
|
|
|
|
|
|
|
|
description: Account the security group is related to.
|
|
|
|
|
|
|
|
returned: success
|
|
|
|
|
|
|
|
type: string
|
|
|
|
|
|
|
|
sample: example account
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -102,15 +132,16 @@ class AnsibleCloudStackSecurityGroup(AnsibleCloudStack):
|
|
|
|
|
|
|
|
|
|
|
|
def get_security_group(self):
|
|
|
|
def get_security_group(self):
|
|
|
|
if not self.security_group:
|
|
|
|
if not self.security_group:
|
|
|
|
sg_name = self.module.params.get('name')
|
|
|
|
|
|
|
|
args = {}
|
|
|
|
args = {}
|
|
|
|
args['projectid'] = self.get_project('id')
|
|
|
|
args['projectid'] = self.get_project(key='id')
|
|
|
|
|
|
|
|
args['account'] = self.get_account(key='name')
|
|
|
|
|
|
|
|
args['domainid'] = self.get_domain(key='id')
|
|
|
|
|
|
|
|
args['securitygroupname'] = self.module.params.get('name')
|
|
|
|
|
|
|
|
|
|
|
|
sgs = self.cs.listSecurityGroups(**args)
|
|
|
|
sgs = self.cs.listSecurityGroups(**args)
|
|
|
|
if sgs:
|
|
|
|
if sgs:
|
|
|
|
for s in sgs['securitygroup']:
|
|
|
|
self.security_group = sgs['securitygroup'][0]
|
|
|
|
if s['name'] == sg_name:
|
|
|
|
|
|
|
|
self.security_group = s
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
return self.security_group
|
|
|
|
return self.security_group
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -121,7 +152,9 @@ 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(key='id')
|
|
|
|
|
|
|
|
args['account'] = self.get_account(key='name')
|
|
|
|
|
|
|
|
args['domainid'] = self.get_domain(key='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 +173,9 @@ 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(key='id')
|
|
|
|
|
|
|
|
args['account'] = self.get_account(key='name')
|
|
|
|
|
|
|
|
args['domainid'] = self.get_domain(key='id')
|
|
|
|
|
|
|
|
|
|
|
|
if not self.module.check_mode:
|
|
|
|
if not self.module.check_mode:
|
|
|
|
res = self.cs.deleteSecurityGroup(**args)
|
|
|
|
res = self.cs.deleteSecurityGroup(**args)
|
|
|
@ -158,6 +193,8 @@ def main():
|
|
|
|
description = dict(default=None),
|
|
|
|
description = dict(default=None),
|
|
|
|
state = dict(choices=['present', 'absent'], default='present'),
|
|
|
|
state = dict(choices=['present', 'absent'], default='present'),
|
|
|
|
project = dict(default=None),
|
|
|
|
project = dict(default=None),
|
|
|
|
|
|
|
|
account = dict(default=None),
|
|
|
|
|
|
|
|
domain = dict(default=None),
|
|
|
|
))
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
module = AnsibleModule(
|
|
|
|
module = AnsibleModule(
|
|
|
|