diff options
author | Emil Renner Berthing <esmil@labitat.dk> | 2018-11-22 22:14:39 +0100 |
---|---|---|
committer | Emil Renner Berthing <esmil@labitat.dk> | 2018-11-22 22:14:39 +0100 |
commit | f0231d0d9454467ac0c1fc8e5a79a63204425851 (patch) | |
tree | 161ead8a343b092c5b59aa747d78cd12a903f3d5 | |
parent | 8bc773dd99c20b47a45dda791ea1f8d60df4a733 (diff) | |
download | labitat-ansible-f0231d0d9454467ac0c1fc8e5a79a63204425851.tar.gz labitat-ansible-f0231d0d9454467ac0c1fc8e5a79a63204425851.tar.xz labitat-ansible-f0231d0d9454467ac0c1fc8e5a79a63204425851.zip |
debian: apt: update and manage apt-preferences.d
-rw-r--r-- | roles/debian/defaults/main.yml | 2 | ||||
-rw-r--r-- | roles/debian/tasks/apt.yml | 23 | ||||
-rw-r--r-- | roles/debian/templates/apt-preferences.j2 | 9 |
3 files changed, 30 insertions, 4 deletions
diff --git a/roles/debian/defaults/main.yml b/roles/debian/defaults/main.yml index 4ae8a53..91fe3f1 100644 --- a/roles/debian/defaults/main.yml +++ b/roles/debian/defaults/main.yml @@ -16,6 +16,8 @@ logind_conf: {} resolved_conf: {} timesyncd_conf: {} +apt_preferences: {} + apt_repos: base: uri: 'https://deb.debian.org/debian' diff --git a/roles/debian/tasks/apt.yml b/roles/debian/tasks/apt.yml index ff9a960..c9fb0f9 100644 --- a/roles/debian/tasks/apt.yml +++ b/roles/debian/tasks/apt.yml @@ -17,14 +17,30 @@ - name: Remove packages apt: - name: '{{ item }}' + name: "{{ apt_packages|dictsort(true)|selectattr(1,'equalto','absent')|map(attribute=0)|list }}" state: absent autoremove: yes purge: yes - with_items: "{{ apt_packages|dictsort(true)|selectattr(1,'equalto','absent')|map(attribute=0)|list }}" 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' @@ -59,9 +75,8 @@ - name: Install packages apt: - name: '{{ item }}' + name: "{{ apt_packages|dictsort(true)|selectattr(1,'equalto','present')|map(attribute=0)|list }}" state: present - with_items: "{{ apt_packages|dictsort(true)|selectattr(1,'equalto','present')|map(attribute=0)|list }}" tags: - packages diff --git a/roles/debian/templates/apt-preferences.j2 b/roles/debian/templates/apt-preferences.j2 new file mode 100644 index 0000000..f1f4dba --- /dev/null +++ b/roles/debian/templates/apt-preferences.j2 @@ -0,0 +1,9 @@ +{% if 'package' in item.value %} +Package: {{ item.value.package }} +{% endif %} +{% if 'pin' in item.value %} +Pin: {{ item.value.pin }} +{% endif %} +{% if 'pin-priority' in item.value %} +Pin-Priority: {{ item.value['pin-priority'] }} +{% endif %} |