community.general.apk (8.5.0) — module

Manages apk packages

Authors: Kevin Brebanov (@kbrebanov)

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

Manages C(apk) packages for Alpine Linux.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update repositories and install foo package
  community.general.apk:
    name: foo
    update_cache: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update repositories and install foo and bar packages
  community.general.apk:
    name: foo,bar
    update_cache: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove foo package
  community.general.apk:
    name: foo
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove foo and bar packages
  community.general.apk:
    name: foo,bar
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install the package foo
  community.general.apk:
    name: foo
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install the packages foo and bar
  community.general.apk:
    name: foo,bar
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update repositories and update package foo to latest version
  community.general.apk:
    name: foo
    state: latest
    update_cache: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update repositories and update packages foo and bar to latest versions
  community.general.apk:
    name: foo,bar
    state: latest
    update_cache: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update all installed packages to the latest versions
  community.general.apk:
    upgrade: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Upgrade / replace / downgrade / uninstall all installed packages to the latest versions available
  community.general.apk:
    available: true
    upgrade: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update repositories as a separate step
  community.general.apk:
    update_cache: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install package from a specific repository
  community.general.apk:
    name: foo
    state: latest
    update_cache: true
    repository: http://dl-3.alpinelinux.org/alpine/edge/main
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install package without using cache
  community.general.apk:
    name: foo
    state: latest
    no_cache: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install package checking a custom world
  community.general.apk:
    name: foo
    state: latest
    world: /etc/apk/world.custom

Inputs

    
name:
    description:
    - A package name, like V(foo), or multiple packages, like V(foo,bar).
    - Do not include additional whitespace when specifying multiple packages as a string.
      Prefer YAML lists over comma-separating multiple package names.
    elements: str
    type: list

state:
    choices:
    - present
    - absent
    - latest
    - installed
    - removed
    default: present
    description:
    - Indicates the desired package(s) state.
    - V(present) ensures the package(s) is/are present. V(installed) can be used as an
      alias.
    - V(absent) ensures the package(s) is/are absent. V(removed) can be used as an alias.
    - V(latest) ensures the package(s) is/are present and the latest version(s).
    type: str

world:
    default: /etc/apk/world
    description:
    - Use a custom world file when checking for explicitly installed packages.
    type: str
    version_added: 5.4.0
    version_added_collection: community.general

upgrade:
    default: false
    description:
    - Upgrade all installed packages to their latest version.
    type: bool

no_cache:
    default: false
    description:
    - Do not use any local cache path.
    type: bool
    version_added: 1.0.0
    version_added_collection: community.general

available:
    default: false
    description:
    - During upgrade, reset versioned world dependencies and change logic to prefer replacing
      or downgrading packages (instead of holding them) if the currently installed package
      is no longer available from any repository.
    type: bool

repository:
    description:
    - A package repository or multiple repositories. Unlike with the underlying apk command,
      this list will override the system repositories rather than supplement them.
    elements: str
    type: list

update_cache:
    default: false
    description:
    - Update repository indexes. Can be run with other steps or on its own.
    type: bool

Outputs

packages:
  description: a list of packages that have been changed
  returned: when packages have changed
  sample:
  - package
  - other-package
  type: list