---

- name: Configuring APT
  template:
    src: "{{ item }}.j2"
    dest: "/{{ item }}"
    owner: "root"
    group: "root"
    mode: "0644"
  with_items:
    - "etc/apt/apt.conf.d/10general"
    - "etc/apt/apt.conf.d/10periodic"

- name: Configuring APT
  template:
    src: "{{ item }}.j2"
    dest: "/{{ item }}"
    owner: "root"
    group: "root"
    mode: "0644"
  when: apt_unattended_upgrades | bool
  with_items:
    - "etc/apt/apt.conf.d/50unattended-upgrades"

- name: Configuring APT Download timer
  include_tasks: unattended_upgrades_download_timer.yml
  when: apt_unattended_upgrades_download_timer_override is not none

- name: Configuring APT Upgrade timer
  include_tasks: unattended_upgrades_upgrade_timer.yml
  when: apt_unattended_upgrades_upgrade_timer_override is not none

- name: Configuring remount filesystems
  template:
    src: "etc/apt/apt.conf.d/10remount_{{ item }}.j2"
    dest: "/etc/apt/apt.conf.d/10remount_{{ item }}"
    owner: "root"
    group: "root"
    mode: "0644"
  when: apt_remount_filesystems | bool
  with_items:
    - "{{ apt_remount_filesystems }}"

- name: Configuring APT proxy behavior
  template:
    src: "{{ item }}.j2"
    dest: "/{{ item }}"
    owner: "root"
    group: "root"
    mode: "0644"
  when: apt_http_proxy_address is defined or apt_https_proxy_address is defined
  with_items:
    - "etc/apt/apt.conf.d/00proxy"

- name: Alter Aptitude solution costs
  template:
    src: "{{ item }}.j2"
    dest: "/{{ item }}"
    owner: "root"
    group: "root"
    mode: "0644"
  when: apt_aptitude_solution_cost | bool
  with_items:
    - "etc/apt/apt.conf.d/20alter-aptitude-solution-cost"

