Repository: ansible/ansible-modules-core

Issue:
Executing ec2_group with rules fails with "Invalid rule parameter '['"
##### Issue Type:

<!--- Please pick one and delete the rest: -->
- Bug Report
##### Ansible Version:

```
$: ansible --version
ansible 2.1.0 (devel cd51ba7965) last updated 2016/02/24 18:50:53 (GMT +000)
  lib/ansible/modules/core: (detached HEAD e9454fa44f) last updated 2016/02/24 18:53:41 (GMT +000)
  lib/ansible/modules/extras: (detached HEAD fade5b7936) last updated 2016/02/24 18:53:42 (GMT +000)
  config file = $path_to_cfg/ansible.cfg
  configured module search path = Default w/o overrides
```
##### Ansible Configuration:

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

<!---
```
$: lsb_release  -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.3 LTS
Release:        14.04
Codename:       trusty
```
-->
##### Summary:

When I execute a play that uses the `ec2_group` module, the play fails with `"Invalid rule parameter '['`. That same play will execute just fine on `ansible-2.0`.
##### Steps To Reproduce:
1. Save the play below into a YML.

```

---
- hosts: localhost
  connection: local
  gather_facts: false

  tasks:
    - name: "create ec2 test group"
      ec2_group:
        name: "test"
        description: "test"
        vpc_id: "your-vpc-id"
        region: "your-region"
        rules:
          - proto: all
            group_name: test
```

  This will create a loopback security group to allow all traffic onto itself.
1. Clone the `ansible` git repo and install using `hacking/env-setup` within the `devel` branch.
2. Execute the playbook:

```
ansible-playbook -vvvv  playbooks/test.yml
```
1. Install the latest stable version of Ansible using `apt-get`, `yum` or `${favorite_package_manager_here_cough_cough_HOMEBREW}`.
2. If you're using Bash, clear your binary path cache using: `hash -r`
3. Verify that your `ansible-playbook` is pointing to stable using `which ansible-playbook`
4. Re-run (3).
##### Expected Results:

```
changed: [localhost] => {"changed": true, "group_id": "$new_sec_group_id", "invocation": {"module_args": {"aws_access_key": null, "aws_secret_key": null, "description": "test", "ec2_url": null, "name": "test", "profile": null, "purge_rules": true, "purge_rules_egress": true, "region": "$your_region_here", "rules": [{"from_port": null, "group_name": "test", "proto": -1, "to_port": null}], "rules_egress": null, "security_token": null, "state": "present", "validate_certs": true, "vpc_id": "$your_vpc_here"}, "module_name": "ec2_group"}}

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0
```
##### Actual Results:

<!--- What actually happened? -->

```
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"aws_access_key": nul
l, "aws_secret_key": null, "description": "test", "ec2_url": null, "name": "test", "profile": null, "purge_rules": true, "purge_rules_egress": true, "region": "$tu_region_acqui", "rules": "[...]", "rules_
egress": null, "security_token": null, "state": "present", "validate_certs": true, "vpc_id": "$tu_vpc_numero_de_identificacion_acqui"}, "module_
name": "ec2_group"}, "msg": "Invalid rule parameter '['"}
```



Discussion:
This is likely related to https://github.com/ansible/ansible/commit/62765858825173dd532827fe4c1dfb246eb8db47

Which sets the type of all arguments to string if they do not contain a type explicitly specified.


Resolving patch:
diff --git a/cloud/amazon/ec2_group.py b/cloud/amazon/ec2_group.py
--- a/cloud/amazon/ec2_group.py
+++ b/cloud/amazon/ec2_group.py
@@ -233,12 +233,12 @@ def get_target_from_rule(module, ec2, rule, name, group, groups, vpc_id):
 def main():
     argument_spec = ec2_argument_spec()
     argument_spec.update(dict(
-            name=dict(required=True),
-            description=dict(required=True),
-            vpc_id=dict(),
-            rules=dict(),
-            rules_egress=dict(),
-            state = dict(default='present', choices=['present', 'absent']),
+            name=dict(type='str', required=True),
+            description=dict(type='str', required=True),
+            vpc_id=dict(type='str'),
+            rules=dict(type='list'),
+            rules_egress=dict(type='list'),
+            state = dict(default='present', type='str', choices=['present', 'absent']),
             purge_rules=dict(default=True, required=False, type='bool'),
             purge_rules_egress=dict(default=True, required=False, type='bool'),
 


Test patch: