Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Argument group is of type 'dict' and we were unable to convert to list

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?

like image 733
rumdrums Avatar asked Feb 03 '16 06:02

rumdrums


1 Answers

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.

like image 52
udondan Avatar answered Sep 23 '22 05:09

udondan