From 17f2b5f73efa39601fab2f76766ea420c2beb15e Mon Sep 17 00:00:00 2001 From: James Cassell Date: Thu, 1 Aug 2019 10:11:53 -0400 Subject: [PATCH] os_subnet: allow using non-default subnet pool (#52608) --- changelogs/fragments/os_subnet-subnetpool-id-allowed.yaml | 5 +++++ lib/ansible/modules/cloud/openstack/os_subnet.py | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/os_subnet-subnetpool-id-allowed.yaml diff --git a/changelogs/fragments/os_subnet-subnetpool-id-allowed.yaml b/changelogs/fragments/os_subnet-subnetpool-id-allowed.yaml new file mode 100644 index 00000000000..a282b73e4d7 --- /dev/null +++ b/changelogs/fragments/os_subnet-subnetpool-id-allowed.yaml @@ -0,0 +1,5 @@ +--- +bugfixes: +- > + os_subnet - it is valid to specify an explicit ``subnetpool_id`` rather than + ``use_default_subnetpool`` or ``cidr`` diff --git a/lib/ansible/modules/cloud/openstack/os_subnet.py b/lib/ansible/modules/cloud/openstack/os_subnet.py index 9980d5dd4c6..dcab0ad98d5 100644 --- a/lib/ansible/modules/cloud/openstack/os_subnet.py +++ b/lib/ansible/modules/cloud/openstack/os_subnet.py @@ -272,9 +272,10 @@ def main(): if state == 'present': if not module.params['network_name']: module.fail_json(msg='network_name required with present state') - if not module.params['cidr'] and not use_default_subnetpool: - module.fail_json(msg='cidr or use_default_subnetpool required ' - 'with present state') + if (not module.params['cidr'] and not use_default_subnetpool and + not extra_specs.get('subnetpool_id', False)): + module.fail_json(msg='cidr or use_default_subnetpool or ' + 'subnetpool_id required with present state') if pool_start and pool_end: pool = [dict(start=pool_start, end=pool_end)]