community.general.apt_rpm module – APT-RPM package manager

Note

This module is part of the community.general collection (version 9.5.1).

You might already have this collection installed if you are using the ansible package. 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.apt_rpm.

Synopsis

  • Manages packages with apt-rpm. Both low-level (rpm) and high-level (apt-get) package manager binaries required.

Requirements

The below requirements are needed on the host that executes this module.

  • rpm python package (rpm bindings), optional. Required if package option includes local files.

Parameters

Parameter

Comments

clean

boolean

added in community.general 6.5.0

Run the equivalent of apt-get clean to clear out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.

Can be run as part of the package installation (clean runs before install) or as a separate step.

Choices:

  • false ← (default)

  • true

dist_upgrade

boolean

added in community.general 6.5.0

If true performs an apt-get dist-upgrade to upgrade system.

Choices:

  • false ← (default)

  • true

package

aliases: name, pkg

list / elements=string

List of packages to install, upgrade, or remove.

Since community.general 8.0.0, may include paths to local .rpm files if state=installed or state=present, requires rpm python module.

state

string

Indicates the desired package state.

Please note that present and installed are equivalent to latest right now. This will change in the future. To simply ensure that a package is installed, without upgrading it, use the present_not_latest state.

The states latest and present_not_latest have been added in community.general 8.6.0.

Choices:

  • "absent"

  • "present" ← (default)

  • "present_not_latest"

  • "installed"

  • "removed"

  • "latest"

update_cache

boolean

Run the equivalent of apt-get update before the operation. Can be run as part of the package installation or as a separate step.

Default is not to update the cache.

Choices:

  • false ← (default)

  • true

update_kernel

boolean

added in community.general 6.5.0

If true performs an update-kernel to upgrade kernel packages.

Choices:

  • false ← (default)

  • true

Attributes

Attribute

Support

Description

check_mode

Support: none

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

- name: Install package foo
  community.general.apt_rpm:
    pkg: foo
    state: present

- name: Install packages foo and bar
  community.general.apt_rpm:
    pkg:
      - foo
      - bar
    state: present

- name: Remove package foo
  community.general.apt_rpm:
    pkg: foo
    state: absent

- name: Remove packages foo and bar
  community.general.apt_rpm:
    pkg: foo,bar
    state: absent

# bar will be the updated if a newer version exists
- name: Update the package database and install bar
  community.general.apt_rpm:
    name: bar
    state: present
    update_cache: true

- name: Run the equivalent of "apt-get clean" as a separate step
  community.general.apt_rpm:
    clean: true

- name: Perform cache update and complete system upgrade (includes kernel)
  community.general.apt_rpm:
    update_cache: true
    dist_upgrade: true
    update_kernel: true

Authors

  • Evgenii Terechkov (@evgkrsk)