From 12d0684ee22457fb89c746e9c35bbd529f0cea2b Mon Sep 17 00:00:00 2001 From: Guilherme Steinmuller Date: Wed, 5 Sep 2018 15:06:06 -0300 Subject: [PATCH] Fix enable_snat parameter (#44418) (#44451) * Fix enable_snat parameter (#44418) Fixes the issue #44285 (cherry picked from commit b7139782cfa7d631a204c38021e4ed59e9e5d956) * Fix enable_snat parameter (#44418) Fixes the issue #44285 (cherry picked from commit b7139782cfa7d631a204c38021e4ed59e9e5d956) * Fix enable_snat parameter (#44418) Fixes the issue #44285 (cherry picked from commit b7139782cfa7d631a204c38021e4ed59e9e5d956) --- changelogs/fragments/fix-os_router.yaml | 3 +++ lib/ansible/modules/cloud/openstack/os_router.py | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/fix-os_router.yaml diff --git a/changelogs/fragments/fix-os_router.yaml b/changelogs/fragments/fix-os_router.yaml new file mode 100644 index 0000000000..c982f746f0 --- /dev/null +++ b/changelogs/fragments/fix-os_router.yaml @@ -0,0 +1,3 @@ +bugfixes: + - fix the enable_snat parameter that is only supposed to be used by an user + with the right policies. https://github.com/ansible/ansible/pull/44418 diff --git a/lib/ansible/modules/cloud/openstack/os_router.py b/lib/ansible/modules/cloud/openstack/os_router.py index fe5a6cb0d5..42c11c6d48 100644 --- a/lib/ansible/modules/cloud/openstack/os_router.py +++ b/lib/ansible/modules/cloud/openstack/os_router.py @@ -42,7 +42,7 @@ options: description: - Enable Source NAT (SNAT) attribute. required: false - default: true + type: bool network: description: - Unique name or ID of the external gateway network. @@ -317,7 +317,8 @@ def _build_kwargs(cloud, module, router, network): if network: kwargs['ext_gateway_net_id'] = network['id'] # can't send enable_snat unless we have a network - kwargs['enable_snat'] = module.params['enable_snat'] + if module.params['enable_snat']: + kwargs['enable_snat'] = module.params['enable_snat'] if module.params['external_fixed_ips']: kwargs['ext_fixed_ips'] = [] @@ -381,7 +382,7 @@ def main(): state=dict(default='present', choices=['absent', 'present']), name=dict(required=True), admin_state_up=dict(type='bool', default=True), - enable_snat=dict(type='bool', default=True), + enable_snat=dict(type='bool'), network=dict(default=None), interfaces=dict(type='list', default=None), external_fixed_ips=dict(type='list', default=None),