The argument group is of type "dict", and we could not convert it to a list

I am trying to break down some of the frequently performed AWS tasks into roles so that I can use them more nimble in slot machines and get into an unexpected roadblock. I can not figure it out:

This game works perfectly directly with the "group" defined as a list directly in the task:

ec2: image: "{{image}}" region: "{{region}}" group: [ "ssh", "outbound" ] [... other stuff] 

But Ansible fails if instead I put the game into roles and define the "groups" in the file "defaults / main.yml" as follows:

 groups: ["ssh", "outbound"] 

Now the game is as follows:

 ec2: image: "{{image}}" region: "{{region}}" group: "{{groups}}" [... other stuff] 

Anseible fails with this post, it looks like 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 either missed something obvious, or ran into an Ansible parsing limitation. Does anyone know this?

+5
source share
1 answer

groups - a reserved variable, a magic variable containing all the groups of your inventory in a dict file, and each element of the group contains all the hosts of this group.

Your approach should work by choosing any other variable name.

+4
source

Source: https://habr.com/ru/post/1242157/


All Articles