set_fact to a list but template does not see that list

Hello Team,

I am trying to do something like this

test-site.yml hosts X

If I add it in the hosts file, things work properly. Somthing like this in the hosts file and remove the set_fact lines

test1-web-au CLUSTERS=“[‘test1-web-au.vm’, ‘test2-web-au.vm’]”

So something wrong about set_fact and templating - might be the order of execution?

Yeah, set_fact doesnt parse its parameters when you use it like that. Try this:

  • set_fact:
    CLUSTERS: [‘test1-web-au.vm’, ‘test2-web-au.vm’]

Doing that you can structure your args using YAML.

Yeah, set_fact doesnt parse its parameters when you use it like that. Try this:

Not explaining why the debug line prints it as a list though, just template does not see it as list.

If I do not use quotes then I can not use some fancier thing like list append. Can not do like that.

set_fact:
CLUSTERS: [‘test1-web-au.vm’, ‘test2-web-au.vm’] + [ ‘stevek.test.au’ ]

You can still use templates wrapped in double braces and they will keep their type. Maybe some dev can chime in with why the args parsing differ between these two notations.