community.general.dpkg_divert module – Override a debian package’s version of a file
Note
This module is part of the community.general collection (version 9.4.0).
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.dpkg_divert
.
New in community.general 0.2.0
Synopsis
A diversion is for
dpkg
the knowledge that only a given package (or the local administrator) is allowed to install a file at a given location. Other packages shipping their own version of this file will be forced todivert
it, that is to install it at another location. It allows one to keep changes in a file provided by a debian package by preventing its overwrite at package upgrade.This module manages diversions of debian packages files using the
dpkg-divert
commandline tool. It can either create or remove a diversion for a given file, but also update an existing diversion to modify itsholder
and/or itsdivert
location.
Requirements
The below requirements are needed on the host that executes this module.
dpkg-divert >= 1.15.0 (Debian family)
Parameters
Parameter |
Comments |
---|---|
The location where the versions of file will be diverted. Default is to add suffix This parameter is ignored when |
|
When This parameter is ignored when Choices:
|
|
The name of the package whose copy of file is not diverted, also known as the diversion holder or the package the diversion belongs to. The actual package does not have to be installed or even to exist for its name to be valid. If not specified, the diversion is hold by ‘LOCAL’, that is reserved by/for dpkg for local diversions. This parameter is ignored when |
|
The original and absolute path of the file to be diverted or undiverted. This path is unique, i.e. it is not possible to get two diversions for the same |
|
Actually move the file aside (when Unless Choices:
|
|
When Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: full |
Will return details on what has changed (or possibly needs changing in |
Examples
- name: Divert /usr/bin/busybox to /usr/bin/busybox.distrib and keep file in place
community.general.dpkg_divert:
path: /usr/bin/busybox
- name: Divert /usr/bin/busybox by package 'branding'
community.general.dpkg_divert:
path: /usr/bin/busybox
holder: branding
- name: Divert and rename busybox to busybox.dpkg-divert
community.general.dpkg_divert:
path: /usr/bin/busybox
divert: /usr/bin/busybox.dpkg-divert
rename: true
- name: Remove the busybox diversion and move the diverted file back
community.general.dpkg_divert:
path: /usr/bin/busybox
state: absent
rename: true
force: true
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The dpkg-divert commands ran internally by the module. Returned: on_success Sample: |
|
The status of the diversion after task execution. Returned: always Sample: |
|
The location of the diverted file. Returned: success |
|
The package holding the diversion. Returned: success |
|
The path of the file to divert/undivert. Returned: success |
|
The state of the diversion. Returned: success |
|
The dpkg-divert relevant messages (stdout or stderr). Returned: on_success Sample: |