diff --git a/lib/ansible/modules/cloud/cloudstack/cs_firewall.py b/lib/ansible/modules/cloud/cloudstack/cs_firewall.py index 61c1acdd00d..721ae327930 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_firewall.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_firewall.py @@ -115,6 +115,14 @@ options: - Poll async jobs until job has finished. required: false default: true + tags: + description: + - List of tags. Tags are a list of dictionaries having keys C(key) and C(value). + - "To delete all tags, set a empty list e.g. C(tags: [])." + required: false + default: null + aliases: [ 'tag' ] + version_added: "2.4" extends_documentation_fragment: cloudstack ''' @@ -345,6 +353,11 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack): poll_async = self.module.params.get('poll_async') if poll_async: firewall_rule = self.poll_job(res, 'firewallrule') + + if firewall_rule: + firewall_rule = self.ensure_tags(resource=firewall_rule, resource_type='Firewallrule') + self.firewall_rule = firewall_rule + return firewall_rule def remove_firewall_rule(self): @@ -398,6 +411,7 @@ def main(): account=dict(), project=dict(), poll_async=dict(type='bool', default=True), + tags=dict(type='list', aliases=['tag'], default=None), )) required_together = cs_required_together() diff --git a/lib/ansible/modules/cloud/cloudstack/cs_iso.py b/lib/ansible/modules/cloud/cloudstack/cs_iso.py index 1b88491e20a..3f730fe0e5e 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_iso.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_iso.py @@ -117,6 +117,14 @@ options: required: false default: true version_added: "2.3" + tags: + description: + - List of tags. Tags are a list of dictionaries having keys C(key) and C(value). + - "To delete all tags, set a empty list e.g. C(tags: [])." + required: false + default: null + aliases: [ 'tag' ] + version_added: "2.4" extends_documentation_fragment: cloudstack ''' @@ -255,6 +263,11 @@ class AnsibleCloudStackIso(AnsibleCloudStack): if 'errortext' in res: self.module.fail_json(msg="Failed: '%s'" % res['errortext']) iso = res['iso'][0] + + if iso: + iso = self.ensure_tags(resource=iso, resource_type='ISO') + self.iso=iso + return iso @@ -325,6 +338,7 @@ def main(): is_dynamically_scalable = dict(type='bool', default=False), state = dict(choices=['present', 'absent'], default='present'), poll_async = dict(type='bool', default=True), + tags=dict(type='list', aliases=['tag'], default=None), )) module = AnsibleModule( diff --git a/lib/ansible/modules/cloud/cloudstack/cs_portforward.py b/lib/ansible/modules/cloud/cloudstack/cs_portforward.py index 5354194bcc9..8685498ebbd 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_portforward.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_portforward.py @@ -123,6 +123,14 @@ options: - Poll async jobs until job has finished. required: false default: true + tags: + description: + - List of tags. Tags are a list of dictionaries having keys C(key) and C(value). + - "To delete all tags, set a empty list e.g. C(tags: [])." + required: false + default: null + aliases: [ 'tag' ] + version_added: "2.4" extends_documentation_fragment: cloudstack ''' @@ -288,6 +296,11 @@ class AnsibleCloudStackPortforwarding(AnsibleCloudStack): portforwarding_rule = self.update_portforwarding_rule(portforwarding_rule) else: portforwarding_rule = self.create_portforwarding_rule() + + if portforwarding_rule: + portforwarding_rule = self.ensure_tags(resource=portforwarding_rule, resource_type='PortForwardingRule') + self.portforwarding_rule=portforwarding_rule + return portforwarding_rule @@ -395,6 +408,7 @@ def main(): account = dict(default=None), project = dict(default=None), poll_async = dict(type='bool', default=True), + tags=dict(type='list', aliases=['tag'], default=None), )) module = AnsibleModule( diff --git a/lib/ansible/modules/cloud/cloudstack/cs_template.py b/lib/ansible/modules/cloud/cloudstack/cs_template.py index 98fc0abc97d..cfe7c61b27f 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_template.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_template.py @@ -203,6 +203,14 @@ options: - Poll async jobs until job has finished. required: false default: true + tags: + description: + - List of tags. Tags are a list of dictionaries having keys C(key) and C(value). + - "To delete all tags, set a empty list e.g. C(tags: [])." + required: false + default: null + aliases: [ 'tag' ] + version_added: "2.4" extends_documentation_fragment: cloudstack ''' @@ -482,6 +490,9 @@ class AnsibleCloudStackTemplate(AnsibleCloudStack): poll_async = self.module.params.get('poll_async') if poll_async: template = self.poll_job(template, 'template') + if template: + template = self.ensure_tags(resource=template, resource_type='Template') + return template @@ -630,6 +641,7 @@ def main(): account = dict(default=None), project = dict(default=None), poll_async = dict(type='bool', default=True), + tags=dict(type='list', aliases=['tag'], default=None), )) module = AnsibleModule( diff --git a/lib/ansible/modules/cloud/cloudstack/cs_vmsnapshot.py b/lib/ansible/modules/cloud/cloudstack/cs_vmsnapshot.py index 2bcc5f69402..d2893d70d5c 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_vmsnapshot.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_vmsnapshot.py @@ -82,6 +82,14 @@ options: - Poll async jobs until job has finished. required: false default: true + tags: + description: + - List of tags. Tags are a list of dictionaries having keys C(key) and C(value). + - "To delete all tags, set a empty list e.g. C(tags: [])." + required: false + default: null + aliases: [ 'tag' ] + version_added: "2.4" extends_documentation_fragment: cloudstack ''' @@ -216,6 +224,9 @@ class AnsibleCloudStackVmSnapshot(AnsibleCloudStack): if res and poll_async: snapshot = self.poll_job(res, 'vmsnapshot') + if snapshot: + snapshot = self.ensure_tags(resource=snapshot, resource_type='Snapshot') + return snapshot @@ -268,6 +279,7 @@ def main(): account = dict(default=None), project = dict(default=None), poll_async = dict(type='bool', default=True), + tags=dict(type='list', aliases=['tag'], default=None), )) required_together = cs_required_together() diff --git a/lib/ansible/modules/cloud/cloudstack/cs_volume.py b/lib/ansible/modules/cloud/cloudstack/cs_volume.py index fa781c299c8..15de0e7b70f 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_volume.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_volume.py @@ -127,6 +127,14 @@ options: - Poll async jobs until job has finished. required: false default: true + tags: + description: + - List of tags. Tags are a list of dictionaries having keys C(key) and C(value). + - "To delete all tags, set a empty list e.g. C(tags: [])." + required: false + default: null + aliases: [ 'tag' ] + version_added: "2.4" extends_documentation_fragment: cloudstack ''' @@ -338,6 +346,10 @@ class AnsibleCloudStackVolume(AnsibleCloudStack): poll_async = self.module.params.get('poll_async') if poll_async: volume = self.poll_job(res, 'volume') + if volume: + volume = self.ensure_tags(resource=volume, resource_type='Volume') + self.volume=volume + return volume @@ -458,6 +470,7 @@ def main(): account = dict(default=None), project = dict(default=None), poll_async = dict(type='bool', default=True), + tags=dict(type='list', aliases=['tag'], default=None), )) module = AnsibleModule(