community.openwrt.apk module – Manage packages with apk on OpenWrt

Note

This module is part of the community.openwrt collection (version 0.5.0).

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.openwrt.

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

New in community.openwrt 0.4.0

Synopsis

  • The community.openwrt.apk module manages packages on OpenWrt using the apk package manager (available in OpenWrt 25.12+).

  • It can install and remove packages.

Note

This module has a corresponding action plugin.

Parameters

Parameter

Comments

force_broken_world

boolean

Continue even if package dependencies are broken.

Choices:

  • false ← (default)

  • true

name

aliases: pkg

string / required

Name of the package(s) to install or remove.

Multiple packages can be specified as a comma-separated list with no spaces, for example curl,wget.

no_cache

boolean

Do not use a local cache files, fetch from index directly. Mutually exclusive with (update_cache).

Choices:

  • false ← (default)

  • true

state

string

Whether the package should be installed or removed.

Choices:

  • "absent"

  • "installed"

  • "present" ← (default)

  • "removed"

update_cache

boolean

Update the package cache (apk update) before performing the operation. Mutually exclusive with (no_cache).

Choices:

  • false ← (default)

  • true

Attributes

Attribute

Support

Description

check_mode

Support: full

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

diff_mode

Support: none

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

platform

Platform: OpenWrt

Target platform for this module.

Examples

- name: Install a package
  community.openwrt.apk:
    name: vim
    state: present

- name: Remove a package
  community.openwrt.apk:
    name: vim
    state: absent

- name: Update cache and install multiple packages
  community.openwrt.apk:
    name: curl,wget
    state: present
    update_cache: true

- name: Install package without using local cache
  community.openwrt.apk:
    name: tcpdump
    state: present
    no_cache: true

Authors

  • Krzysztof Bialek (@kbialek)