diff --git a/changelogs/fragments/55526-optional_vnic_type.yml b/changelogs/fragments/55526-optional_vnic_type.yml new file mode 100644 index 00000000000..17dfbf4146c --- /dev/null +++ b/changelogs/fragments/55526-optional_vnic_type.yml @@ -0,0 +1,5 @@ +--- +bugfixes: + - os_port - handle binding:vnic_type as optional + (https://github.com/ansible/ansible/issues/55524, + https://github.com/ansible/ansible/issues/55525) diff --git a/lib/ansible/modules/cloud/openstack/os_port.py b/lib/ansible/modules/cloud/openstack/os_port.py index 5a38fe3063c..5eb3801631c 100644 --- a/lib/ansible/modules/cloud/openstack/os_port.py +++ b/lib/ansible/modules/cloud/openstack/os_port.py @@ -84,7 +84,6 @@ options: description: - The type of the port that should be created choices: [normal, direct, direct-physical, macvtap, baremetal, virtio-forwarder] - default: normal version_added: "2.8" port_security_enabled: description: @@ -327,7 +326,7 @@ def main(): device_owner=dict(default=None), device_id=dict(default=None), state=dict(default='present', choices=['absent', 'present']), - vnic_type=dict(default='normal', + vnic_type=dict(default=None, choices=['normal', 'direct', 'direct-physical', 'macvtap', 'baremetal', 'virtio-forwarder']), port_security_enabled=dict(default=None, type='bool') @@ -355,11 +354,10 @@ def main(): for v in module.params['security_groups'] ] - if module.params['vnic_type']: - # Neutron API accept 'binding:vnic_type' as an argument - # for the port type. - module.params['binding:vnic_type'] = module.params['vnic_type'] - module.params.pop('vnic_type', None) + # Neutron API accept 'binding:vnic_type' as an argument + # for the port type. + module.params['binding:vnic_type'] = module.params['vnic_type'] + module.params.pop('vnic_type', None) port = None network_id = None