Repository: ansible/ansible

Issue:
os_network provider_network_type should allow 'local'
_From @Logan2211 on November 12, 2016 22:49_

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
os_network

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.2.0.0
  config file =
  configured module search path = ['/etc/ansible/roles/plugins/library']
```

##### OS / ENVIRONMENT
Ubuntu 16.04

##### SUMMARY
'local' should be a valid provider_network_type in https://github.com/ansible/ansible-modules-core/blob/devel/cloud/openstack/os_network.py#L172

##### STEPS TO REPRODUCE
Create a network with os_network using provider_network_type: local

Use a neutron network plugin like networking_calico which expects to receive 'local' networks: https://github.com/openstack/networking-calico/blob/master/networking_calico/plugins/ml2/drivers/calico/mech_calico.py#L540-L541

##### EXPECTED RESULTS
I expected it to create the network in Neutron with the type I specified.

Maybe this field should not have prescribed types and should simply rely on the Neutron API to filter valid/invalid types as needed?

##### ACTUAL RESULTS
```
fatal: [aio1_utility_container-2d7be198]: FAILED! => {"changed": false, "failed": true, "msg": "value of provider_network_type must be one of: flat,vlan,vxlan,gre, got: local"}
```


_Copied from original issue: ansible/ansible-modules-core#5589_


Discussion:
_From @ansibot on November 12, 2016 22:54_

<!-- @Logan2211: Thanks for filing this bug report! -->

@emonty, @shrews, @juliakreger, @j2sol, @rcarrillocruz, ping. This issue is waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_bug_new --->

_From @ansibot on November 28, 2016 9:34_

@emonty, @shrews, @juliakreger, @j2sol, @rcarrillocruz, @thingee, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: issue_renotify_maintainer --->
_From @ansibot on December 7, 2016 20:4_

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the <a href="http://docs.ansible.com/ansible/dev_guide/repomerge.html#move-issues-and-prs-to-new-repo">repomerge</a> page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

<!-- boilerplate: repomerge -->
I think removing the choices is probably the best thing to do here. It looks like shade will accept any value passed through, so no change should be needed there. Would be happy to accept a PR for this.

needs_contributor

Resolving patch:
diff --git a/lib/ansible/modules/cloud/openstack/os_network.py b/lib/ansible/modules/cloud/openstack/os_network.py
--- a/lib/ansible/modules/cloud/openstack/os_network.py
+++ b/lib/ansible/modules/cloud/openstack/os_network.py
@@ -73,7 +73,6 @@
    provider_network_type:
      description:
         - The type of physical network that maps to this network resource.
-     choices: ['flat', 'vlan', 'vxlan', 'gre', 'uplink']
      required: false
      default: None
      version_added: "2.1"
@@ -172,8 +171,7 @@ def main():
         admin_state_up=dict(default=True, type='bool'),
         external=dict(default=False, type='bool'),
         provider_physical_network=dict(required=False),
-        provider_network_type=dict(required=False, default=None,
-                                   choices=['flat', 'vlan', 'vxlan', 'gre', 'uplink']),
+        provider_network_type=dict(required=False),
         provider_segmentation_id=dict(required=False),
         state=dict(default='present', choices=['absent', 'present']),
         project=dict(default=None)


Test patch: