community.general.apk – Manages apk packages

Note

This plugin is part of the community.general collection (version 2.5.1).

To install it use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.apk.

Synopsis

  • Manages apk packages for Alpine Linux.

Parameters

Parameter Choices/Defaults Comments
available
boolean
    Choices:
  • no ←
  • yes
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.
name
list / elements=string
A package name, like foo, or multiple packages, like foo, bar.
no_cache
boolean
added in 1.0.0 of community.general
    Choices:
  • no ←
  • yes
Do not use any local cache path.
repository
list / elements=string
A package repository or multiple repositories. Unlike with the underlying apk command, this list will override the system repositories rather than supplement them.
state
string
    Choices:
  • present ←
  • absent
  • latest
  • installed
  • removed
Indicates the desired package(s) state.
present ensures the package(s) is/are present. installed can be used as an alias.
absent ensures the package(s) is/are absent. removed can be used as an alias.
latest ensures the package(s) is/are present and the latest version(s).
update_cache
boolean
    Choices:
  • no ←
  • yes
Update repository indexes. Can be run with other steps or on it's own.
upgrade
boolean
    Choices:
  • no ←
  • yes
Upgrade all installed packages to their latest version.

Notes

Note

  • “name” and “upgrade” are mutually exclusive.

  • When used with a loop: each package will be processed individually, it is much more efficient to pass the list directly to the name option.

Examples

- name: Update repositories and install foo package
  community.general.apk:
    name: foo
    update_cache: yes

- name: Update repositories and install foo and bar packages
  community.general.apk:
    name: foo,bar
    update_cache: yes

- name: Remove foo package
  community.general.apk:
    name: foo
    state: absent

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

- name: Install the package foo
  community.general.apk:
    name: foo
    state: present

- name: Install the packages foo and bar
  community.general.apk:
    name: foo,bar
    state: present

- name: Update repositories and update package foo to latest version
  community.general.apk:
    name: foo
    state: latest
    update_cache: yes

- name: Update repositories and update packages foo and bar to latest versions
  community.general.apk:
    name: foo,bar
    state: latest
    update_cache: yes

- name: Update all installed packages to the latest versions
  community.general.apk:
    upgrade: yes

- name: Upgrade / replace / downgrade / uninstall all installed packages to the latest versions available
  community.general.apk:
    available: yes
    upgrade: yes

- name: Update repositories as a separate step
  community.general.apk:
    update_cache: yes

- name: Install package from a specific repository
  community.general.apk:
    name: foo
    state: latest
    update_cache: yes
    repository: http://dl-3.alpinelinux.org/alpine/edge/main

- name: Install package without using cache
  community.general.apk:
    name: foo
    state: latest
    no_cache: yes

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
packages
list / elements=string
when packages have changed
a list of packages that have been changed

Sample:
['package', 'other-package']


Authors

  • Kevin Brebanov (@kbrebanov)