# set\_fact to a list but template does not see that list

**URL:** <https://forum.ansible.com/t/set-fact-to-a-list-but-template-does-not-see-that-list/19312>\
**Category:** Ansible Developer\
**Created:** [September 21, 2015, 3:34am UTC](https://forum.ansible.com/t/set-fact-to-a-list-but-template-does-not-see-that-list/19312 "2015-09-21T03:34:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Kieu](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steve\_Kieu](https://forum.ansible.com/u/Steve_Kieu)\
**Post date:** [September 21, 2015, 3:34am UTC](https://forum.ansible.com/t/set-fact-to-a-list-but-template-does-not-see-that-list/19312/1 "2015-09-21T03:34:18Z")

</div>

Hello Team,

I am trying to do something like this

test-site.yml hosts X

---

<div class="post-metadata">

**Author:** ![Steve\_Kieu](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steve\_Kieu](https://forum.ansible.com/u/Steve_Kieu)\
**Post date:** [September 21, 2015, 3:58am UTC](https://forum.ansible.com/t/set-fact-to-a-list-but-template-does-not-see-that-list/19312/2 "2015-09-21T03:58:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Hagai\_Kariti](https://avatars.discourse-cdn.com/v4/letter/h/4491bb/32.png) [@Hagai\_Kariti](https://forum.ansible.com/u/Hagai_Kariti)\
**Post date:** [September 21, 2015, 5:53am UTC](https://forum.ansible.com/t/set-fact-to-a-list-but-template-does-not-see-that-list/19312/3 "2015-09-21T05:53:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Steve\_Kieu](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steve\_Kieu](https://forum.ansible.com/u/Steve_Kieu)\
**Post date:** [September 21, 2015, 6:15am UTC](https://forum.ansible.com/t/set-fact-to-a-list-but-template-does-not-see-that-list/19312/4 "2015-09-21T06:15:48Z")

</div>

> 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’]

---

<div class="post-metadata">

**Author:** ![Hagai\_Kariti](https://avatars.discourse-cdn.com/v4/letter/h/4491bb/32.png) [@Hagai\_Kariti](https://forum.ansible.com/u/Hagai_Kariti)\
**Post date:** [September 21, 2015, 6:49am UTC](https://forum.ansible.com/t/set-fact-to-a-list-but-template-does-not-see-that-list/19312/5 "2015-09-21T06:49:12Z")

</div>

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.
