---
# File: main.yml
# Type: task
# Part: Aptitude

- name: Aptitude | Configure Proxy
  shell: "echo 'Acquire::http { Proxy \"{{ apt_proxy }}\"; };\n{{ apt_proxy_extra | default() }}' > /etc/apt/apt.conf.d/01proxy"
  when: apt_proxy is defined

- name: Aptitude | Deploy sources.list
  template: src=apt_sources.list.j2 dest="/etc/apt/sources.list" owner=root group=root mode=0644
  register: result

- name: Aptitude | Install pyton-apt
  apt: name=python-apt state=present

- name: Aptitude | Force update cache
  apt: update_cache=yes
  when: result|changed

- name: Aptitude | Update cache
  apt: update_cache=yes cache_valid_time=3600

- name: Aptitude | Upgrade all packages to the latest version
  apt: upgrade=dist force=yes

- name: Aptitude | Remove unused packages
  shell: apt-get autoremove -y
