I'm trying to break some commonly-done AWS tasks into roles so that I can use them more nimbly in playbooks and have hit an unexpected roadblock. I can't figure this one out:
This play works just fine directly with 'group' defined as a list directly in the task:
ec2:
image: "{{image}}"
region: "{{region}}"
group: [ "ssh", "outbound" ]
[... other stuff]
But Ansible fails if I instead put the play in a role and define 'groups' in its 'defaults/main.yml' file like this:
groups: ["ssh", "outbound"]
The play now looks like this:
ec2:
image: "{{image}}"
region: "{{region}}"
group: "{{groups}}"
[... other stuff]
Ansible fails with this message, seeming to think my variable is a dict, not a list:
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "argument group is of type <type 'dict'> and we were unable to convert to list"}
I'm either missing something obvious or have run into a limitation of Ansible's variable parsing. Anyone have any insight into this?
groups
is a reserved variable, a magic variable holding all groups of your inventory in a dict, each group item holding all hosts of that group.
Your approach should be working by picking any other variable name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With