Trying to feed a list to apt for install

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

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

2 Likes

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