I keep getting msg”: “‘dict object’ has no attribute ‘item'”
i want to check if files is existing using with_items
and when those file exist, I want to modify some part of the file using lineinfile module
what is the best way to do this?
below is the code i tried but I keep getting an error msg”: “‘dict object’ has no attribute ‘item'”
- name: check for existing files
stat:
path: "path/{{item}}"
with_items:
- file1
- file2
- file3
- file4
- file5
register: file
- name: Update file
lineinfile:
path: "path/{{item}}"
regexp: "^PASSWORD="
line: "PASSWORD=password}"
backrefs: yes
with_items: "{{file.item}}"
when: "{{file.stat == exist}}"
New contributor
miro03 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.