[backport 2.7] Check if enabled_snat is set in modules arguments (#46754) (#47807)

* 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

(cherry picked from commit c2b7174d31)

* Add changelog entry
This commit is contained in:
Michał Siemek 2018-11-01 18:10:20 +01:00 committed by Toshio Kuratomi
parent 01c0a6d699
commit 951572bec1
2 changed files with 9 additions and 2 deletions

View file

@ -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)

View file

@ -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