---

- name: Copy sources.list for apt
  template:
    src: sources.list
    dest: /etc/apt/sources.list
    owner: root
    group: root
    mode: 644
    backup: yes

---

- name: Copy sources.list for apt
  template:
    src: sources.list
    dest: /etc/apt/sources.list
    owner: root
    group: root
    mode: 644
    backup: yes
  register: result

- name: Update apt cache
  apt:
    update_cache: yes
  when: result|changed

Update cache when sources.list is updated
Update cache when sources.list is updated
