Repository: ansible/ansible-modules-core

Issue:
os_security_group_rule support numbered protocols
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

<!--- Name of the plugin/module/task -->

os_security_group_rule
##### ANSIBLE VERSION

<!--- Paste verbatim output from “ansible --version” between quotes below -->

```
ansible 2.2.0 (devel 57fca2dde2) last updated 2016/08/10 09:50:16 (GMT -400)
  lib/ansible/modules/core: (detached HEAD a216ef210b) last updated 2016/08/10 09:50:43 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD 39153ea154) last updated 2016/08/10 09:50:43 (GMT -400)
  config file = 
  configured module search path = Default w/o overrides
```
##### CONFIGURATION

<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->

None
##### OS / ENVIRONMENT

<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say “N/A” for anything that is not platform-specific.
-->

Ubuntu 14.04
##### SUMMARY

<!--- Explain the problem briefly -->

I am trying to take advantage of the `protocol: 112` functionality of neutron to allow VRRP traffic between two instances that share a vIP. Since VRRP is a numbered protocol and with a legitimate use case, there should be an option to support numbered protocols in this module.

Openstack heats supports this with a simple:
`- protocol: 112`
##### STEPS TO REPRODUCE

<!---
For bugs, show exactly how to reproduce the problem.
For new features, show how the feature would be used.
-->

Create a security group rule such as:

```
- os_security_group_rule:
    security_group: loadbalancer_sg
    protocol: 112
    remote_group: loadbalancer-node_sg
```
##### EXPECTED RESULTS

<!--- What did you expect to happen when running the steps above? -->

The security group rule is created, as this is a feature of openstack.
##### ACTUAL RESULTS

<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

The module failed to add as it can only handle tcp,udp,icmp, or None

<!--- Paste verbatim command output between quotes below -->

```
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "value of protocol must be one of: None,tcp,udp,icmp, got: 112"}
```



Discussion:
<!-- @indispeq: 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 --->


Resolving patch:
diff --git a/cloud/openstack/os_security_group_rule.py b/cloud/openstack/os_security_group_rule.py
--- a/cloud/openstack/os_security_group_rule.py
+++ b/cloud/openstack/os_security_group_rule.py
@@ -39,7 +39,7 @@
    protocol:
       description:
         - IP protocol
-      choices: ['tcp', 'udp', 'icmp', None]
+      choices: ['tcp', 'udp', 'icmp', 112, None]
       default: None
    port_range_min:
       description:
@@ -121,6 +121,12 @@
     security_group: foo
     protocol: tcp
     remote_ip_prefix: 0.0.0.0/0
+
+# Create a rule for VRRP with numbered protocol 112
+- os_security_group_rule:
+    security_group: loadbalancer_sg
+    protocol: 112
+    remote_group: loadbalancer-node_sg
 '''
 
 RETURN = '''
@@ -251,7 +257,7 @@ def main():
         # NOTE(Shrews): None is an acceptable protocol value for
         # Neutron, but Nova will balk at this.
         protocol         = dict(default=None,
-                                choices=[None, 'tcp', 'udp', 'icmp']),
+                                choices=[None, 'tcp', 'udp', 'icmp', 112]),
         port_range_min   = dict(required=False, type='int'),
         port_range_max   = dict(required=False, type='int'),
         remote_ip_prefix = dict(required=False, default=None),


Test patch: