From c2b7174d31ba4643606707ce64a0c6d3762a984e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Siemek?= Date: Tue, 30 Oct 2018 13:04:43 +0100 Subject: [PATCH] Check if `enabled_snat` is set in modules arguments (#46754) If `enabled_snat` is not set at all in module arguments but Neutron policy sets it by default in Openstack, then `os_router` will attempt to recreate otherwise perfectly good router. Follow up for https://github.com/ansible/ansible/issues/44432#issuecomment-428531031 --- lib/ansible/modules/cloud/openstack/os_router.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/openstack/os_router.py b/lib/ansible/modules/cloud/openstack/os_router.py index 643215028b3..44ec4462c23 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