Repository: ansible/ansible

Issue:
error when specifying multiple group_names in ec2_group rules
##### ISSUE TYPE
 - Documentation Report

##### COMPONENT NAME
ec2_group module

##### ANSIBLE VERSION
Broken in 2.3.0 but fixed in devel branch

##### SUMMARY

Specifying multiple group_name values gives an error

```yaml
---
- hosts: 127.0.0.1
  connection: local
  tasks:
    - name: test sg
      ec2_group:
        region: us-west-2
        name: test-sg
        description: test
        rules:
          - proto: tcp
            from_port: 80
            to_port: 80
            group_name:
              - sg-1
              - sg-2
```

```
Traceback (most recent call last):
  File "/tmp/ansible_t3AIZS/ansible_module_ec2_group.py", line 487, in <module>
    main()
  File "/tmp/ansible_t3AIZS/ansible_module_ec2_group.py", line 356, in main
    group_id, ip, target_group_created = get_target_from_rule(module, ec2, rule, name, group, groups, vpc_id)
  File "/tmp/ansible_t3AIZS/ansible_module_ec2_group.py", line 225, in get_target_from_rule
    elif group_name in groups and (vpc_id is None or groups[group_name].vpc_id == vpc_id):
TypeError: unhashable type: 'list'
```

The bug is actually fixed in the devel branch, so I think it's more of a documentation issue to mention that multiple group_name values doesn't work until 2.4.0 is released.

error when specifying multiple group_names in ec2_group rules
##### ISSUE TYPE
 - Documentation Report

##### COMPONENT NAME
ec2_group module

##### ANSIBLE VERSION
Broken in 2.3.0 but fixed in devel branch

##### SUMMARY

Specifying multiple group_name values gives an error

```yaml
---
- hosts: 127.0.0.1
  connection: local
  tasks:
    - name: test sg
      ec2_group:
        region: us-west-2
        name: test-sg
        description: test
        rules:
          - proto: tcp
            from_port: 80
            to_port: 80
            group_name:
              - sg-1
              - sg-2
```

```
Traceback (most recent call last):
  File "/tmp/ansible_t3AIZS/ansible_module_ec2_group.py", line 487, in <module>
    main()
  File "/tmp/ansible_t3AIZS/ansible_module_ec2_group.py", line 356, in main
    group_id, ip, target_group_created = get_target_from_rule(module, ec2, rule, name, group, groups, vpc_id)
  File "/tmp/ansible_t3AIZS/ansible_module_ec2_group.py", line 225, in get_target_from_rule
    elif group_name in groups and (vpc_id is None or groups[group_name].vpc_id == vpc_id):
TypeError: unhashable type: 'list'
```

The bug is actually fixed in the devel branch, so I think it's more of a documentation issue to mention that multiple group_name values doesn't work until 2.4.0 is released.



Discussion:

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/ec2_group.py b/lib/ansible/modules/cloud/amazon/ec2_group.py
--- a/lib/ansible/modules/cloud/amazon/ec2_group.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_group.py
@@ -46,11 +46,14 @@
       - List of firewall inbound rules to enforce in this group (see example). If none are supplied,
         no inbound rules will be enabled. Rules list may include its own name in `group_name`.
         This allows idempotent loopback additions (e.g. allow group to acccess itself).
+        Rule sources list support was added in version 2.4. This allows to define multiple sources per
+        source type as well as multiple source types per rule. Prior to 2.4 an individual source is allowed.
     required: false
   rules_egress:
     description:
       - List of firewall outbound rules to enforce in this group (see example). If none are supplied,
         a default all-out rule is assumed. If an empty list is supplied, no outbound rules will be enabled.
+        Rule Egress sources list support was added in version 2.4.
     required: false
     version_added: "1.6"
   state:


Test patch: