---
- name: Install unattended-upgrades
  when: ansible_os_family == "Debian"
  apt:
    name: unattended-upgrades
    state: present
    update_cache: true
  register: apt_result
  retries: 3
  until: apt_result is succeeded

- name: Configure unattended-upgrades
  template:
    src: "apt/{{ item }}.j2"
    dest: "/etc/apt/apt.conf.d/{{ item }}"
    owner: root
    mode: u=rw,g=r,o=r
  loop:
    - 50unattended-upgrades
    - 20auto-upgrades
...