# Trying to feed a list to apt for install

**URL:** <https://forum.ansible.com/t/trying-to-feed-a-list-to-apt-for-install/45306>\
**Category:** Get Help\
**Created:** [February 9, 2026, 4:41pm UTC](https://forum.ansible.com/t/trying-to-feed-a-list-to-apt-for-install/45306 "2026-02-09T16:41:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![merrittr](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@merrittr](https://forum.ansible.com/u/merrittr)\
**Post date:** [February 9, 2026, 4:41pm UTC](https://forum.ansible.com/t/trying-to-feed-a-list-to-apt-for-install/45306/1 "2026-02-09T16:41:04Z")

</div>

hey i get this warning since I have 2 name:

[WARNING]: While constructing a mapping from /ICTadmin/bin/ubuntupatchingEMAIL.yml, line 22, column 7, found a duplicate dict key (name). Using last defined value only.

> ```
> - name: Update
> ansible.builtin.apt:
> name: "{{ _security_pkg_list.stdout_lines }}"
> 
> ```

is there a correct way to address this list

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [February 9, 2026, 5:42pm UTC](https://forum.ansible.com/t/trying-to-feed-a-list-to-apt-for-install/45306/2 "2026-02-09T17:42:13Z")

</div>

indent the 2nd `name`, its at task level, not at action level

---

<div class="post-metadata">

**Author:** ![merrittr](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@merrittr](https://forum.ansible.com/u/merrittr)\
**Post date:** [February 9, 2026, 7:32pm UTC](https://forum.ansible.com/t/trying-to-feed-a-list-to-apt-for-install/45306/3 "2026-02-09T19:32:31Z")

</div>

ah yeah sorry I updated it to this , still with not luck

> ```
> - name: Update
> ansible.builtin.apt:
> name: "{{ _security_pkg_list.stdout_lines }}"
> state: present
> update_cache: yes
> 
> ```

here is what that list looks like

> root@buntupatchtest:/home/serveradmin# cat /root/UbuntuPatchTest.txt  
> [“linux-generic”, “linux-headers-generic”, “linux-image-generic”, “linux-libc-dev”, “linux-tools-common”]root@buntupatchtest:/home/serveradmin#

generated via

```
- name: Use copy module to write the stdout_lines
  ansible.builtin.copy:
    content: "{{ _security_pkg_list.stdout_lines }}"
    dest: "/root/{{ inventory_hostname }}.txt"
    owner: root
    group: root

```

could this be the issue  
[“linux-generic”, “linux-headers-generic”, “linux-image-generic”, “linux-libc-dev”, “linux-tools-common”]

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 11, 2026, 7:33pm UTC](https://forum.ansible.com/t/trying-to-feed-a-list-to-apt-for-install/45306/4 "2026-03-11T19:33:12Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
