Hi,
I am trying to remove a bunch of files wiht the following code:
$ cat site.yml
---
- name: apply common configuration
hosts: all
remote_user: root
become: "yes"
roles:
- common
$ cat roles/common/tasks/repos.yml
---
- 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"
- name: include repositories
tags:
repos
include_tasks:
"{{distribution}}/{{distribution_version}}/repos.yml"
$
My target system contains the following files:
-rw-r--r-- 1 root root 0 Nov 7 19:06 zda-foo.list
-rw-r--r-- 1 root root 63 Nov 7 19:03 zda-sid-mc.list
-rw-r--r-- 1 root root 75 Nov 7 19:03 zda-sid-zg-stable-mc.list
-rw-r--r-- 1 root root 77 Nov 7 19:03 zda-sid-zg-unstable-mc.list
Running the playbook tries to remove two files that are not there but
leaves the files in place:
$ ansible-playbook --inventory=hosts.yml --limit=emptysid86 site.yml
PLAY [apply common configuration]
TASK [Gathering Facts]
ok: [emptysid86]
TASK [common : remove extra files that may be on the systems]
ok: [emptysid86] => (item=/etc/apt/sources.list.d/sid-zg-stable-mc.list)
ok: [emptysid86] => (item=/etc/apt/sources.list.d/sid-zg-unstable-mc.list)
When I replace with_fileglob with with_items in the tasks file, it
removes the files that are explicitly given, but of course doesn't glob,
so the /etc/apt/sources.lists.d/zda-*.list doesn't work.
What am I doing wrong?
Greetings
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/20171107182148.qokzeko4gndtgzth%40torres.zugschlus.de.
For more options, visit https://groups.google.com/d/optout.