set_fact doesn't work in loop

Hello,

I’m trying to build a list from data in other lists by looping over lists and using set_fact to build a new list.

You can't use {{ }} inside {{ }} since you are already in template mode.
So use this instead

   item_list: '{{ item_list + [ item ] }}'

But you can solve this a lot faster without a loop with the union filter

   - name: "create list"
     set_fact:
       item_list: '{{ item_list | union(location_list.site) }}'

Thank you. I’ll try the update in my actual script and see how it goes.

I can’t do a join since it’s not a simple list I’m really trying to turn into a simple list. This code seemed to demonstrate the crux of my issue though and I’m hoping you provided the solution I needed.

I’m still trying to understand when quotes and brackets should be used.

-Jason