mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-07-25 09:14:31 +00:00
Add ability to set tags in network modules
This adds the `tags` parameter to the network, subnet, and router modules. Change-Id: I704b40c44c733a3d4ec93a95d8efcb7ecf6e2a32 Signed-off-by: Austin Jamias <ajamias@redhat.com>
This commit is contained in:
@@ -83,6 +83,11 @@ options:
|
||||
Network will use Openstack defaults if this option is
|
||||
not provided.
|
||||
type: str
|
||||
tags:
|
||||
description:
|
||||
- A list of tags to set on the network
|
||||
type: list
|
||||
elements: str
|
||||
extends_documentation_fragment:
|
||||
- openstack.cloud.openstack
|
||||
'''
|
||||
@@ -208,7 +213,8 @@ class NetworkModule(OpenStackModule):
|
||||
project=dict(),
|
||||
port_security_enabled=dict(type='bool'),
|
||||
mtu=dict(type='int', aliases=['mtu_size']),
|
||||
dns_domain=dict()
|
||||
dns_domain=dict(),
|
||||
tags=dict(type='list', elements='str'),
|
||||
)
|
||||
|
||||
def run(self):
|
||||
@@ -224,6 +230,7 @@ class NetworkModule(OpenStackModule):
|
||||
provider_network_type = self.params['provider_network_type']
|
||||
provider_segmentation_id = self.params['provider_segmentation_id']
|
||||
project = self.params['project']
|
||||
tags = self.params['tags']
|
||||
|
||||
kwargs = {}
|
||||
for arg in ('port_security_enabled', 'mtu', 'dns_domain'):
|
||||
@@ -304,6 +311,12 @@ class NetworkModule(OpenStackModule):
|
||||
)
|
||||
changed = True
|
||||
|
||||
if tags is not None:
|
||||
old_tags = self.conn.network.get_tags(net)
|
||||
if set(old_tags) != set(tags):
|
||||
self.conn.network.set_tags(net, tags)
|
||||
changed = True
|
||||
|
||||
net = net.to_dict(computed=False)
|
||||
self.exit(changed=changed, network=net, id=net['id'])
|
||||
elif state == 'absent':
|
||||
|
||||
Reference in New Issue
Block a user