# set\_fact in with\_dict append loop only keeps last item

**URL:** <https://forum.ansible.com/t/set-fact-in-with-dict-append-loop-only-keeps-last-item/30790>\
**Category:** Ansible Project\
**Created:** [July 16, 2019, 7:58am UTC](https://forum.ansible.com/t/set-fact-in-with-dict-append-loop-only-keeps-last-item/30790 "2019-07-16T07:58:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rakesh\_Parida](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@Rakesh\_Parida](https://forum.ansible.com/u/Rakesh_Parida)\
**Post date:** [July 16, 2019, 7:58am UTC](https://forum.ansible.com/t/set-fact-in-with-dict-append-loop-only-keeps-last-item/30790/1 "2019-07-16T07:58:20Z")

</div>

Hi,

set\_fact in with\_dict append loop only keeps last item . Is there any way to keep the whole list in the set\_fact.

- name: Print records  
set\_fact:  
imp\_records: “/home/ansible/{{ item.key }}/{{ item.value.version.split(‘\_’)[1] }}/{{ item.value.file\_name }}”  
when: item.key == ‘imp’  
with\_dict: “{{ somevalue }}”

append loops only keeps the last item.

Is there any way we can whole list in the set\_fact

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [July 16, 2019, 8:55am UTC](https://forum.ansible.com/t/set-fact-in-with-dict-append-loop-only-keeps-last-item/30790/2 "2019-07-16T08:55:48Z")

</div>

what does 'somevalue' look like?

---

<div class="post-metadata">

**Author:** ![Rakesh\_Parida](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@Rakesh\_Parida](https://forum.ansible.com/u/Rakesh_Parida)\
**Post date:** [July 16, 2019, 9:06am UTC](https://forum.ansible.com/t/set-fact-in-with-dict-append-loop-only-keeps-last-item/30790/3 "2019-07-16T09:06:22Z")

</div>

“somevalue”: [  
{  
“cp”: {  
“file\_name”: “CXP\_902\_8057\_25.1.1\_20190606-091538.tar”,  
“md5”: “20f5dfe8b166cc45e6bd4cd48449d4f5”,  
“product\_name”: “cp”,  
“product\_number”: “CXP 902 8057”,  
“release\_candidate”: “RC25”,  
“version”: “25.1.1”  
}  
},  
{  
“imp1”: {  
“file\_name”: “IMP1\_903\_6746\_25.0.0\_20190612-094816.tar”,  
“md5”: “e464e69a07123de075778aa9b761d2ce”,  
“product\_name”: “device\_authentication”,  
“product\_number”: “CXP 903 6746”,  
“release\_candidate”: “RC25”,  
“version”: “25.0.0”  
}  
},  
{  
“imp2”: {  
“file\_name”: “IMP2\_GP14\_PCP24\_EP01\_A.tar.gz”,  
“md5”: “b117a1de38d99f11f8157a2d26840ef4”,  
“product\_name”: “ece”,  
“product\_number”: “None”,  
“release\_candidate”: “None”,  
“version”: “GP14\_PCP24\_EP01\_A”  
}  
},  
{  
“imp”: {  
“file\_name”: “imp902\_7815\_25.1.0\_20190601-083833.tar”,  
“md5”: “6c6fc29c6738c2d227a1a8fb3017cea5”,  
“product\_name”: “imp”,  
“product\_number”: “CXP 902 7815”,  
“release\_candidate”: “RC25”,  
“version”: “25.1.0”  
}  
},  
{  
“iamaaadapter”: {  
“file\_name”: “CXP\_903\_6488\_25.1.2\_1906190606.tar.gz”,  
“md5”: “1ced0063caced27e0417ba65315b0e85”,  
“product\_name”: “iamaaadapter”,  
“product\_number”: “CXP 903 6488”,  
“release\_candidate”: “RC25”,  
“version”: “25.1.2”  
}  
},  
{  
“iamfedadapter”: {  
“file\_name”: “CXP\_903\_6605\_25.0.0\_1905101559.tar.gz”,  
“md5”: “da713bf0a73f863aa4296e4e2fd9af55”,  
“product\_name”: “iamfedadapter”,  
“product\_number”: “CXP 903 6605”,  
“release\_candidate”: “RC25”,  
“version”: “25.0.0”  
}  
},  
{  
“idp\_proxy”: {  
“file\_name”: “CXP\_903\_5569\_25.0.1\_20190705-084530.tar”,  
“md5”: “cb8295ba32d4e43550ecd9ba409ff8d1”,  
“product\_name”: “idp\_proxy”,  
“product\_number”: “CXP 903 5569”,  
“release\_candidate”: “RC25”,  
“version”: “25.0.1”  
}  
},  
{  
“notification”: {  
“file\_name”: “CXP\_902\_8347\_25.1.2\_20190612-100040.tar”,  
“md5”: “72cc71fdfb826937ed9b417a637b717b”,  
“product\_name”: “notification”,  
“product\_number”: “CXP 902 8347”,  
“release\_candidate”: “RC25”,  
“version”: “25.1.2”  
}  
},  
{  
“pm”: {  
“file\_name”: “CXP\_902\_8056\_25.1.1\_20190606-090412.tar”,  
“md5”: “38eb5777b6161b84be252c942d772b99”,  
“product\_name”: “pm”,  
“product\_number”: “CXP 902 8056”,  
“release\_candidate”: “RC25”,  
“version”: “25.1.1”  
}  
},  
{  
“profileservicetmo”: {  
“file\_name”: “CXP\_903\_7106\_25.0.0\_1905101654.tar.gz”,  
“md5”: “7fad90f7965c99944ae2952a8abb7b77”,  
“product\_name”: “profileservicetmo”,  
“product\_number”: “CXP 903 7106”,  
“release\_candidate”: “RC25”,  
“version”: “25.0.0”  
}

}  
}  
]
