diff --git a/changelogs/fragments/os_router_enable_snat_fix.yaml b/changelogs/fragments/os_router_enable_snat_fix.yaml new file mode 100644 index 0000000000..bb4aa705b7 --- /dev/null +++ b/changelogs/fragments/os_router_enable_snat_fix.yaml @@ -0,0 +1,5 @@ +--- +bugfixes: + - Fixed an issue where ``os_router`` would attempt to recreate router, + because lack of ``enabled_snat`` parameter was treated as difference, + if default Neutron policy for snat is set. (https://github.com/ansible/ansible/issues/29903) diff --git a/lib/ansible/modules/cloud/openstack/os_router.py b/lib/ansible/modules/cloud/openstack/os_router.py index 643215028b..44ec4462c2 100644 --- a/lib/ansible/modules/cloud/openstack/os_router.py +++ b/lib/ansible/modules/cloud/openstack/os_router.py @@ -227,8 +227,10 @@ def _needs_update(cloud, module, router, network, internal_subnet_ids, internal_ if router['admin_state_up'] != module.params['admin_state_up']: return True if router['external_gateway_info']: - if router['external_gateway_info'].get('enable_snat', True) != module.params['enable_snat']: - return True + # check if enable_snat is set in module params + if module.params['enable_snat'] is not None: + if router['external_gateway_info'].get('enable_snat', True) != module.params['enable_snat']: + return True if network: if not router['external_gateway_info']: return True