Hi Kai,
thanks for the nudge. I was able to solve the issue.
> with_fileglob is a lookup plugin, and lookup plugin runs on the Ansible controller and not the remote host.
Ouch. That was not clear to me at all, but of course it explains
eveything. So you use with_fileglob mainly when you transport files from
the controller to the remote.
> To do what what you want to do, you must use the find module to find the files and register the output in a variable.
> Then you can delete them with the file module and with_items.
This is my code:
---
- name: search for sources.list files
find:
paths: "/etc/apt/sources.list.d"
patterns: "zda-*.list,exp-mc.list,sid-mc.list,sid-zg-stable-mc.list,sid-zg-unstable-mc.list,stretch-mc.list,stretch-security.list,stretch-zg-stable-mc.list,stretch-zg-unstable-mc.list,buster-mc.list,stretch-zg-stable-mc.list,stretch-security.list"
register: sourceslistfiles
- name: delete sources.list files
file:
path: "{{ item.path }}"
state: absent
with_items: "{{ sourceslistfiles.files }}"
Thanks for helping.
Of course, this triggers immediately the next issue, such is when one
begins with new technology. Will post a new question soon.
Grüße