---

- name: Change basics repositories
  template:
    src: "{{ ansible_distribution_release }}_basics.list.j2"
    dest: /etc/apt/sources.list
    mode: "0644"
    force: yes
  register: apt_basic_list
  tags:
    - apt

- name: Clean GANDI sources.list.d/debian-security.list
  file:
    path: '{{ item }}'
    state: absent
  with_items:
    - /etc/apt/sources.list.d/debian-security.list
    - /etc/apt/sources.list.d/debian-jessie.list
    - /etc/apt/sources.list.d/debian-stretch.list
    - /etc/apt/sources.list.d/debian-buster.list
    - /etc/apt/sources.list.d/debian-update.list
  when: apt_clean_gandi_sourceslist
  tags:
    - apt

- name: Apt update
  apt:
    update_cache: yes
  when: apt_basic_list is changed
  tags:
    - apt
