community.general.dnf_versionlock (8.5.0) — module

Locks package versions in C(dnf) based systems

| "added in version" 4.0.0 of community.general"

Authors: Roberto Moreda (@moreda) <moreda@allenta.com>

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Locks package versions using the C(versionlock) plugin in C(dnf) based systems. This plugin takes a set of name and versions for packages and excludes all other versions of those packages. This allows you to for example protect packages from being updated by newer versions. The state of the plugin that reflects locking of packages is the C(locklist).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Prevent installed nginx from being updated
  community.general.dnf_versionlock:
    name: nginx
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Prevent multiple packages from being updated
  community.general.dnf_versionlock:
    name:
      - nginx
      - haproxy
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove lock from nginx to be updated again
  community.general.dnf_versionlock:
    package: nginx
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Exclude bind 32:9.11 from installs or updates
  community.general.dnf_versionlock:
    package: bind-32:9.11*
    state: excluded
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Keep bash package in major version 4
  community.general.dnf_versionlock:
    name: bash-0:4.*
    raw: true
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete all entries in the locklist of versionlock
  community.general.dnf_versionlock:
    state: clean

Inputs

    
raw:
    default: false
    description:
    - Do not resolve package name specs to NEVRAs to find specific version to lock to.
      Instead the package name specs are used as they are. This enables locking to not
      yet available versions of the package.
    type: bool

name:
    default: []
    description:
    - Package name spec to add or exclude to or delete from the C(locklist) using the
      format expected by the C(dnf repoquery) command.
    - This parameter is mutually exclusive with O(state=clean).
    elements: str
    required: false
    type: list

state:
    choices:
    - absent
    - clean
    - excluded
    - present
    default: present
    description:
    - Whether to add (V(present) or V(excluded)) to or remove (V(absent) or V(clean))
      from the C(locklist).
    - V(present) will add a package name spec to the C(locklist). If there is a installed
      package that matches, then only that version will be added. Otherwise, all available
      package versions will be added.
    - V(excluded) will add a package name spec as excluded to the C(locklist). It means
      that packages represented by the package name spec will be excluded from transaction
      operations. All available package versions will be added.
    - V(absent) will delete entries in the C(locklist) that match the package name spec.
    - V(clean) will delete all entries in the C(locklist). This option is mutually exclusive
      with O(name).
    type: str

Outputs

locklist_post:
  description: Locklist after module execution.
  elements: str
  returned: success and (not check mode or state is clean)
  sample:
  - bash-0:4.4.20-1.el8_4.*
  type: list
locklist_pre:
  description: Locklist before module execution.
  elements: str
  returned: success
  sample:
  - bash-0:4.4.20-1.el8_4.*
  - '!bind-32:9.11.26-4.el8_4.*'
  type: list
specs_toadd:
  description: Package name specs meant to be added by versionlock.
  elements: str
  returned: success
  sample:
  - bash
  type: list
specs_todelete:
  description: Package name specs meant to be deleted by versionlock.
  elements: str
  returned: success
  sample:
  - bind
  type: list