Add ability to control the state of apt pins.

The default state is 'present', keeping the existing behaviour of
the role. If 'apt_package_pinning_state' is set to 'absent' then
the specified pin file will be removed.

This functionality may be needed when removing an upstream
repository configuration and associated pins in order to change
back to using distro provided packages.

Change-Id: I1f1adbef8f9d8cf787d00b6ef26b1acba2beb83e
This commit is contained in:
Jonathan Rosser 2024-09-04 09:25:18 +01:00
parent 599e5575d2
commit 3d52ce41d6
2 changed files with 9 additions and 0 deletions

View File

@ -15,3 +15,4 @@
apt_package_pinning_priority: 900 apt_package_pinning_priority: 900
apt_package_pinning_file_name: "openstack_pinned_packages.pref" apt_package_pinning_file_name: "openstack_pinned_packages.pref"
apt_package_pinning_state: "present"

View File

@ -21,6 +21,14 @@
when: when:
- ansible_facts['pkg_mgr'] == 'apt' - ansible_facts['pkg_mgr'] == 'apt'
- apt_pinned_packages is defined - apt_pinned_packages is defined
- apt_package_pinning_state == 'present'
tags: tags:
- apt-package-pinning - apt-package-pinning
- apt-install - apt-install
- name: Remove apt pin preferences
file:
path: "/etc/apt/preferences.d/{{ apt_package_pinning_file_name }}"
state: absent
when:
- apt_package_pinning_state == 'absent'