Hi Kai,
thanks for the nudge. I was able to solve the issue.
On Tue, Nov 07, 2017 at 07:35:06PM +0100, Kai Stian Olstad wrote:
> On 07. nov. 2017 19:21, Marc Haber wrote:
> > - name: remove extra files that may be on the systems
> > file:
> > path: "{{ item }}"
> > state: absent
> > with_fileglob:
> > - "/etc/apt/sources.list.d/zda-*.list"
> > - "/etc/apt/sources.list.d/exp-mc.list"
> > - "/etc/apt/sources.list.d/sid-mc.list"
> > - "/etc/apt/sources.list.d/sid-zg-stable-mc.list"
> > - "/etc/apt/sources.list.d/sid-zg-unstable-mc.list"
> > - "/etc/apt/sources.list.d/stretch-mc.list"
> > - "/etc/apt/sources.list.d/stretch-security.list"
> > - "/etc/apt/sources.list.d/stretch-zg-stable-mc.list"
> > - "/etc/apt/sources.list.d/stretch-zg-unstable-mc.list"
> > - "/etc/apt/sources.list.d/buster-mc.list"
> > - "/etc/apt/sources.list.d/stretch-zg-stable-mc.list"
> > - "/etc/apt/sources.list.d/stretch-security.list"
> > - "/etc/apt/preferences.d/??-zda-*.pref"
> > - "/etc/apt/preferences.d/10-sid-zg-unstable-mc.pref"
> > - "/etc/apt/preferences.d/20-sid-zg-stable-mc.pref"
> > - "/etc/apt/preferences.d/50-sid-security.pref"
> > - "/etc/apt/preferences.d/70-sid.pref"
> > - "/etc/apt/preferences.d/99-default.pref"
>
> 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
Marc
--
-----------------------------------------------------------------------------
Marc Haber | "I don't trust Computers. They | Mailadresse im Header
Leimen, Germany | lose things." Winona Ryder | Fon: *49 6224 1600402
Nordisch by Nature | How to make an American Quilt | Fax: *49 6224 1600421
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/20171108191524.pfzalrmvegyagpgi%40torres.zugschlus.de.
For more options, visit https://groups.google.com/d/optout.