diff --git a/CHANGELOG.md b/CHANGELOG.md index eceafa3..4e8b474 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,3 +5,4 @@ * Remove the default `/etc/apt/sources.list` file. * Manage Stretch repositories. * Update Apt if any repositories modifications. +* Manage default preferences file. diff --git a/README.md b/README.md index 7e100c3..7986e98 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ 2. [Role Variables](#role-variables) 3. [Example Playbook](#example-playbook) 4. [Configuration](#configuration) + * [Sources List](#sources-list) + * [Preferences](#preferences) 5. [Development](#development) 6. [License](#license) 7. [Author Information](#author-information) @@ -17,6 +19,8 @@ Manage APT repos, preferences and configuration for IPR's servers. * **apt_src_list_manage** : If apt sources list files should be managed [default : `true`]. * **apt_purge_src_list_file** : If the default sources.file must be absent [default : `true`]. * **apt_stretch_manage** : If Stretch configuration should be managed [default : `true`]. +* **apt_default_pref_path** : Path to set the default preferences file for all repositories [default : `'/etc/apt/preferences.d/default.pref'`]. +* **apt_default_pref_tpl** : Template used to generate the previous config file [default : `'etc/apt/preferences.d/default.pref.j2'`]. ## Example Playbook @@ -37,6 +41,12 @@ Manage Debian's sources.list : * Add Stretch repositories. * Update Apt if any repositories modifications. +### Preferences + +* Set the preferences for all repositories, default to : + - Stretch - 310. + - Stretch Backports - 300. + ## Development This source code comes from our [Gogs instance][apt source] and the [Github repo][apt github] exist just to be able to send the role to Ansible Galaxy… diff --git a/defaults/main.yml b/defaults/main.yml index 8b7b58a..95b42ae 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,3 +5,6 @@ apt_src_list_manage: true apt_purge_src_list_file: true apt_stretch_manage: true + +apt_default_pref_path: '/etc/apt/preferences.d/default.pref' +apt_default_pref_tpl: 'etc/apt/preferences.d/default.pref.j2' diff --git a/tasks/main.yml b/tasks/main.yml index ce059ae..d0f2efa 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,6 +1,12 @@ --- # tasks file for apt +# Default preferences file +- name: CONFIG default preferences + template: + src: '{{ apt_default_pref_tpl }}' + dest: '{{ apt_default_pref_path }}' + # Sources list ## Purge sources.list file - name: CONFIG remove sources.list file diff --git a/templates/etc/apt/preferences.d/default.pref.j2 b/templates/etc/apt/preferences.d/default.pref.j2 new file mode 100644 index 0000000..f12a449 --- /dev/null +++ b/templates/etc/apt/preferences.d/default.pref.j2 @@ -0,0 +1,13 @@ +# {{ ansible_managed }} + +{% if apt_stretch_manage %} +Explanation: Packages from Stretch (Stable) +Package: * +Pin: release o=Debian,a=stable,n=stretch,l=Debian +Pin-Priority: 310 + +Explanation: Packages from Stretch (Stable) +Package: * +Pin: release o=Debian Backports,a=stretch-backports,n=stretch-backports,l=Debian Backports +Pin-Priority: 300 +{% endif %}