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:
Austin Jamias
2025-11-07 19:06:37 -05:00
parent a178493281
commit dbc6f7d44a
6 changed files with 125 additions and 1 deletions

View File

@@ -69,6 +69,9 @@
external: false
mtu: "{{ mtu }}"
port_security_enabled: "{{ port_security_enabled }}"
tags:
- foo
- bar
register: result_create_nw_with_new_params
ignore_errors: true
@@ -85,6 +88,8 @@
- result_newparams.networks.0.mtu == mtu
- "'is_port_security_enabled' in result_newparams.networks.0"
- result_newparams.networks.0['is_port_security_enabled'] == port_security_enabled
- "'foo' in result_newparams.networks.0.tags"
- "'bar' in result_newparams.networks.0.tags"
- name: Delete network - generic and with new SDK params
openstack.cloud.network:
@@ -115,6 +120,9 @@
external: false
mtu: "{{ mtu }}"
port_security_enabled: "{{ port_security_enabled }}"
tags:
- foo
- bar
register: result_create_nw_for_updates
- name: Update network - update failure
@@ -147,6 +155,11 @@
mtu: "{{ mtu - 50 }}"
# NOTE: This property should be updated
port_security_enabled: "{{ not port_security_enabled }}"
# NOTE: This property should be updated
tags:
- foo
- bar
- baz
register: result_nw_update_success
- name: Gather networks info - updates
@@ -162,6 +175,29 @@
- result_network_updates_info.networks.0.name == network_name_updates
- result_network_updates_info.networks.0.mtu == mtu - 50
- result_network_updates_info.networks.0['is_port_security_enabled'] == (not port_security_enabled)
- "'foo' in result_network_updates_info.networks.0.tags"
- "'bar' in result_network_updates_info.networks.0.tags"
- "'baz' in result_network_updates_info.networks.0.tags"
- name: Update network - no change
openstack.cloud.network:
cloud: "{{ cloud }}"
name: "{{ network_name_updates }}"
state: present
shared: "{{ network_shared }}"
external: false
mtu: "{{ mtu - 50 }}"
port_security_enabled: "{{ not port_security_enabled }}"
tags:
- foo
- bar
- baz
register: result_nw_update_no_change
- name: Verify networks info - no change
assert:
that:
- result_nw_update_no_change is not changed
- name: Delete network - updates
openstack.cloud.network:

View File

@@ -325,6 +325,43 @@
- ports.ports|rejectattr('device_owner', 'equalto', 'network:router_gateway')|sum(attribute='fixed_ips', start=[])|map(attribute='ip_address')|sort|list ==
['10.7.7.1']
- name: Update router (add tags)
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: "{{ router_name }}"
tags:
- foo
- bar
- name: Gather routers info
openstack.cloud.routers_info:
cloud: "{{ cloud }}"
name: "{{ router_name }}"
register: info
- name: Verify tags
assert:
that:
- info.routers.0.name == router_name
- info.routers.0.id == router.router.id
- "'foo' in info.routers.0.tags"
- "'bar' in info.routers.0.tags"
- name: Update router (add tags) again
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: "{{ router_name }}"
tags:
- foo
- bar
register: router
- name: Assert idempotent module
assert:
that: router is not changed
# Admin operation
- name: Create external network
openstack.cloud.network:

View File

@@ -31,6 +31,9 @@
gateway_ip: 192.168.0.1
allocation_pool_start: 192.168.0.2
allocation_pool_end: 192.168.0.254
tags:
- foo
- bar
register: subnet
- name: Assert changed
@@ -56,6 +59,9 @@
gateway_ip: 192.168.0.1
allocation_pool_start: 192.168.0.2
allocation_pool_end: 192.168.0.254
tags:
- foo
- bar
register: subnet
- name: Assert not changed
@@ -80,6 +86,8 @@
enable_dhcp: "{{ enable_subnet_dhcp }}"
gateway_ip: 192.168.0.1
cidr: 192.168.0.0/24
tags:
- bar
register: subnet
- name: Verify Subnet info result
@@ -114,6 +122,10 @@
dns_nameservers:
- 8.8.8.7
cidr: 192.168.0.0/24
tags:
- foo
- bar
- baz
register: subnet
- name: Assert changed