On Wed, Nov 08, 2017 at 08:47:08PM +0100, Marc Haber wrote:
> - roll out the new contents, build a list of files being rolled out
> - build the list of files found on the remote system
> - delete files that are in list 2 but not in list 1.

This is what I did and it works. Here my solution:

- 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-u
  register: presentsourceslistfiles
- name: set up fact list for wanted sources.list.d entries
  set_fact:
    wantedsourceslistfiles:
- name: include repositories
  tags:
          repos
  include_tasks:
          "{{distribution}}/{{distribution_version}}/repos.yml"
- name: delete sources.list files
  file:
    path: "{{ item.path }}"
    state: absent
  with_items: "{{ presentsourceslistfiles.files }}"
  when: item.path not in wantedsourceslistfiles

debian/sid/repos.yml:
- name: create list of sid wantedsourceslistfiles
  set_fact:
    sidwantedsourceslistfiles:
      - /etc/apt/sources.list.d/zda-sid-mc.list
      - /etc/apt/sources.list.d/zda-sid-zg-stable-mc.list
      - /etc/apt/sources.list.d/zda-sid-zg-unstable-mc.list
- name: add sid files to wantedsourceslistfiles
  set_fact:
    wantedsourceslistfiles: "{{ wantedsourceslistfiles }} + {{ 
sidwantedsourceslistfiles }}"
- name: zda-sid-mc.list
  copy:
    dest: /etc/apt/sources.list.d/zda-sid-mc.list
    owner: root
    group: root
    mode: 0644
    content: |
            deb http://debian.debian.zugschlus.de/debian/ sid main contrib
  notify: apt update
- name: zda-sid-zg-stable-mc.list
  copy:
    dest: /etc/apt/sources.list.d/zda-sid-zg-stable-mc.list
    owner: root
    group: root
    mode: 0644
    content: |
            deb http://zg20150.debian.zugschlus.de/zg20150/ sid-zg-stable main 
contrib
  notify: apt update
- name: zda-sid-zg-unstable-mc.list
  copy:
    dest: /etc/apt/sources.list.d/zda-sid-zg-unstable-mc.list
    owner: root
    group: root
    mode: 0644
    content: |
            deb http://zg20150.debian.zugschlus.de/zg20150/ sid-zg-unstable 
main contrib
  notify: apt update


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/20171109151710.bvwrupipgaopls3d%40torres.zugschlus.de.
For more options, visit https://groups.google.com/d/optout.

Reply via email to