mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-03-26 21:43:02 +00:00
Allow networks to be updated
Neutron will allow you to update certain properties of the network after creation. This change modifies the ansible code to perform an update call if it detects that any updatable properties have been changed. If you attempt to change a property that cannot be updated, the module will fail. This gives you confidence that the ansible configuration matches the state of the network in OpenStack. If we did not fail in this way, you might think you have updated the network, but in reality those changes would be silently ignored. Prior to this change, the only way to update properties of a network was to delete it and then recreate. Story: 2010024 Task: 45262 Change-Id: I4af2b50f207f349b58c63e0a4e92816ada0847fd
This commit is contained in:
@@ -105,3 +105,66 @@
|
||||
assert:
|
||||
that:
|
||||
- result_nonet.networks == []
|
||||
|
||||
- name: Create network - updates
|
||||
openstack.cloud.network:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ network_name_updates }}"
|
||||
state: present
|
||||
shared: "{{ network_shared }}"
|
||||
external: "{{ network_external }}"
|
||||
mtu: "{{ mtu }}"
|
||||
port_security_enabled: "{{ port_security_enabled }}"
|
||||
register: result_create_nw_for_updates
|
||||
|
||||
- name: Update network - update failure
|
||||
openstack.cloud.network:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ network_name_updates }}"
|
||||
state: present
|
||||
shared: "{{ network_shared }}"
|
||||
external: "{{ network_external }}"
|
||||
mtu: "{{ mtu }}"
|
||||
port_security_enabled: "{{ port_security_enabled }}"
|
||||
# You cannot update this property.
|
||||
provider_physical_network: cannot_be_updated
|
||||
ignore_errors: true
|
||||
register: result_nw_update_failure
|
||||
|
||||
- name: Verify networks info - update fail
|
||||
assert:
|
||||
that:
|
||||
- result_nw_update_failure is failed
|
||||
|
||||
- name: Update network - update success
|
||||
openstack.cloud.network:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ network_name_updates }}"
|
||||
state: present
|
||||
shared: "{{ network_shared }}"
|
||||
external: "{{ network_external }}"
|
||||
# NOTE: This property should be updated
|
||||
mtu: "{{ mtu - 50 }}"
|
||||
# NOTE: This property should be updated
|
||||
port_security_enabled: "{{ not port_security_enabled }}"
|
||||
register: result_nw_update_success
|
||||
|
||||
- name: Gather networks info - updates
|
||||
openstack.cloud.networks_info:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ network_name_updates }}"
|
||||
register: result_network_updates_info
|
||||
|
||||
- name: Verify networks info - update success
|
||||
assert:
|
||||
that:
|
||||
- result_nw_update_success is changed
|
||||
- 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)
|
||||
|
||||
- name: Delete network - updates
|
||||
openstack.cloud.network:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ network_name_updates }}"
|
||||
state: absent
|
||||
|
||||
Reference in New Issue
Block a user