aboutsummaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
Diffstat (limited to 'roles')
-rw-r--r--roles/debian/defaults/main.yml2
-rw-r--r--roles/debian/tasks/apt.yml23
-rw-r--r--roles/debian/templates/apt-preferences.j29
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 %}