ansible/ansible — pull request #5906 by sivel (2014-02-07 19:15:26+00:00)
Title: Support for -a to accept a file with test-module

If the CLI value for -a starts with an @, treat it like a file, and dump the contents into complex_args

This supports yaml or json.

Tests:

args.json
```json
{
"filter": "ansible_hostname"
}
```

args.yaml
```yaml
---
filter: ansible_hostname
```

```
$ ./test-module -m ../library/system/setup -a filter=ansible_hostname
* including generated source, if any, saving to: /path/to/.ansible_module_generated
* this may offset any line numbers in tracebacks/debuggers!
***********************************
RAW OUTPUT
{"verbose_override": true, "changed": false, "ansible_facts": {"ansible_hostname": "foobar"}}

***********************************
PARSED OUTPUT
{
"ansible_facts": {
"ansible_hostname": "foobar"
},
"changed": false,
"verbose_override": true
}
```

```
$ ./test-module -m ../library/system/setup -a @args.yaml
* including generated source, if any, saving to: /path/to/.ansible_module_generated
* this may offset any line numbers in tracebacks/debuggers!
***********************************
RAW OUTPUT
{"verbose_override": true, "changed": false, "ansible_facts": {"ansible_hostname": "foobar"}}

***********************************
PARSED OUTPUT
{
"ansible_facts": {
"ansible_hostname": "foobar"
},
"changed": false,
"verbose_override": true
}
```

```
$ ./test-module -m ../library/system/setup -a @args.json
* including generated source, if any, saving to: /path/to/.ansible_module_generated
* this may offset any line numbers in tracebacks/debuggers!
***********************************
RAW OUTPUT
{"verbose_override": true, "changed": false, "ansible_facts": {"ansible_hostname": "foobar"}}

***********************************
PARSED OUTPUT
{
"ansible_facts": {
"ansible_hostname": "foobar"
},
"changed": false,
"verbose_override": true
}
```