aboutsummaryrefslogblamecommitdiffstats
path: root/roles/debian/tasks/apt.yml
blob: b3d08513486c718b64c716970480c8b9f01499ca (plain) (tree)


















                                              
                                                                                                    


                   


            
















                                                 























                                                                   

                        
                                                                                                     
                  



                        
---
- name: Don't install recommended packages
  copy:
    dest: '/etc/apt/apt.conf.d/06norecommends'
    src: 06norecommends
    owner: root
    group: root
    mode: 0644

- name: Don't start services by default
  copy:
    dest: '/usr/sbin/policy-rc.d'
    content: "exit 101\n"
    owner: root
    group: root
    mode: 0755

- name: Remove packages
  apt:
    name: "{{ apt_packages|dictsort(true)|selectattr(1,'equalto','absent')|map(attribute=0)|list }}"
    state: absent
    autoremove: yes
    purge: yes
  tags:
  - packages

- name: Create /etc/apt/preferences.d
  template:
    dest: '/etc/apt/preferences.d/{{ item.key }}'
    src: apt-preferences.j2
    owner: root
    group: root
    mode: 0644
  with_dict: '{{ apt_preferences }}'
  when: item.value

- name: Remove /etc/apt/preferences.d
  file:
    path: '/etc/apt/preferences.d/{{ item.key }}'
    state: absent
  with_dict: '{{ apt_preferences }}'
  when: not item.value

- name: Configure /etc/apt/sources.list
  template:
    dest: '/etc/apt/sources.list'
    src: sources.list.j2
    owner: root
    group: root
    mode: 0644
  when: apt_sources is defined

- name: Download repository keys
  apt_key:
    url: "{{ apt_repos[item.key]['key_url'] }}"
    id: "{{ apt_repos[item.key]['key_id'] }}"
    state: present
  with_dict: '{{ apt_sources }}'
  when: apt_sources is defined and 'key_url' in apt_repos[item.key]

- name: Update apt cache
  apt:
    update_cache: yes
  tags:
  - update
  - packages

- name: Install packages
  apt:
    name: "{{ apt_packages|dictsort(true)|selectattr(1,'equalto','present')|map(attribute=0)|list }}"
    state: present
  tags:
  - packages

# vim: set ts=2 sw=2 et: