diff --git a/ci/roles/subnet/tasks/main.yml b/ci/roles/subnet/tasks/main.yml index 0ce0cf5f..5c48f32b 100644 --- a/ci/roles/subnet/tasks/main.yml +++ b/ci/roles/subnet/tasks/main.yml @@ -142,6 +142,41 @@ assert: that: subnet is not changed +- name: Create subnet {{ subnet_name }} on network {{ network_name }} without gateway IP + openstack.cloud.subnet: + cloud: "{{ cloud }}" + network_name: "{{ network_name }}" + name: "{{ subnet_name }}" + state: present + cidr: 192.168.0.0/24 + disable_gateway_ip: true + register: subnet + +- name: Assert changed + assert: + that: subnet is changed + +- name: Create subnet {{ subnet_name }} on network {{ network_name }} without gateway IP + openstack.cloud.subnet: + cloud: "{{ cloud }}" + network_name: "{{ network_name }}" + name: "{{ subnet_name }}" + state: present + cidr: 192.168.0.0/24 + disable_gateway_ip: true + register: subnet + +- name: Assert not changed + assert: + that: subnet is not changed + +- name: Delete subnet {{ subnet_name }} again + openstack.cloud.subnet: + cloud: "{{ cloud }}" + name: "{{ subnet_name }}" + state: absent + register: subnet + - name: Delete network {{ network_name }} openstack.cloud.network: cloud: "{{ cloud }}" diff --git a/plugins/modules/subnet.py b/plugins/modules/subnet.py index d0b8e7a6..7c50aee3 100644 --- a/plugins/modules/subnet.py +++ b/plugins/modules/subnet.py @@ -382,6 +382,8 @@ class SubnetModule(OpenStackModule): params['allocation_pools'] = self.params['allocation_pools'] params = self._add_extra_attrs(params) params = {k: v for k, v in params.items() if v is not None} + if self.params['disable_gateway_ip']: + params['gateway_ip'] = None return params def _build_updates(self, subnet, params):