DEBOPS.APT_MARK(5)

NAME
debops.apt_mark - Set desired APT package state using Ansible

SYNOPSIS

debops run service/apt_mark [--limit group,host,...] [--diff] [--check] [--tags tag1,tag2,...] [--skip-tags tag1,tag2,...] [<ansible-playbook options>] ...

DESCRIPTION

The debops.apt_mark Ansible role can be used to set the desired state of APT packages using apt-mark(8) <https://manpages.debian.org/apt-mark(8)> command. It might be useful if a new Debian/Ubuntu install results in many packages which should be installed are marked for autoremoval, or if you want to hold certain APT packages in their current state. The role operates only on packages that are already installed.

GETTING STARTED

  Example inventory

The debops.apt_mark role is included by default in the common.yml DebOps playbook; you don't need to add hosts to any Ansible groups to enable it.

  Example playbook

If you are using this role without DebOps, here's an example Ansible playbook that uses the debops.apt_mark role:

---
- name: Mark APT package state
  collections: [ 'debops.debops', 'debops.roles01',
                 'debops.roles02', 'debops.roles03' ]
  hosts: [ 'debops_all_hosts', 'debops_service_apt_mark' ]
  become: True
  environment: '{{ inventory__environment | d({})
                   | combine(inventory__group_environment | d({}))
                   | combine(inventory__host_environment  | d({})) }}'
  roles:
    - role: apt_mark
      tags: [ 'role::apt_mark', 'skip::apt_mark' ]

  Ansible tags

You can use Ansible --tags or --skip-tags parameters to limit what tasks are performed during Ansible run. This can be used after a host was first configured to speed up playbook execution, when you are sure that most of the configuration is already in the desired state.

Available role tags:

role::apt_mark
    Main role tag, should be used in the playbook to execute all of the role tasks as well as role dependencies.

  Other resources

List of other useful resources related to the debops.apt_mark Ansible role:

•   Manual pages: apt-mark(8) <https://manpages.debian.org/apt-mark(8)>

DEFAULT VARIABLE DETAILS

Some of debops.apt_mark default variables have more extensive configuration than simple strings or lists, here you can find documentation and examples for them.

  apt_mark__packages

The apt_mark__*_packages list variables specify the desired state of the APT packages to set on the hosts. Only already installed APT packages are managed. Each list entry is a YAML dictionary with specific parameters:

name
    Required. Name of an APT package to configure. At the moment the role does not support usage of glob patterns (eg. package-*).

packages
    Optional. A list of APT packages to manage. If specified, the name parameter is ignored. Glob patterns are not supported.

state
    Optional. This parameter defines what state to set for the specified package(s) The available states:
     | auto | manual
    hold | auto-hold | manual-hold
    unhold | auto-unhold | manual-unhold

    If not specified, manual state is set by default, hold state is not changed. You can find out more about these states in the apt-mark(8) <https://manpages.debian.org/apt-mark(8)> manual page.

  Examples

Mark a package as installed manually, so it won't be autoremoved:

apt_mark__packages:
  - name: 'zsh'
  - name: 'bash'
    state: 'manual'

Mark multiple installed packages as installed manually and held in their current state. Only the packages already installed will be affected:

apt_mark__packages:
  - name: 'nginx-packages'
    state: 'manual-hold'
    packages:
      - 'nginx'
      - 'nginx-common'
      - 'nginx-extras'

AUTHOR
Maciej Delmanowski

COPYRIGHT
2014-2024, Maciej Delmanowski, Nick Janetakis, Robin Schneider and others