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

Note

This module is part of the community.openwrt collection (version 1.8.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.opkg.

Synopsis

  • The community.openwrt.opkg module manages packages on OpenWrt using the opkg package manager.

  • It can install, remove, and update packages.

Note

This module has a corresponding action plugin.

Parameters

Parameter

Comments

autoremove

boolean

Remove dependencies that are no longer required when removing a package.

Choices:

  • false

  • true

conf_file

string

added in community.openwrt 1.7.0

Path to a custom opkg configuration file, passed to opkg as --conf.

This replaces the default opkg configuration entirely instead of adding to it, so the file must define its own dest and lists_dir entries in addition to any src feed lines it needs.

Useful on devices where the default opkg configuration does not provide the desired feeds (for example, Teltonika firmware).

force

string

Force option to pass to opkg.

Choices:

  • "depends"

  • "maintainer"

  • "reinstall"

  • "overwrite"

  • "downgrade"

  • "space"

  • "postinstall"

  • "remove"

  • "checksum"

  • "removal-of-dependent-packages"

name

aliases: pkg

string / required

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

Multiple packages can be specified as a comma-separated list.

nodeps

boolean

Do not follow dependencies.

Choices:

  • false

  • true

state

string

Whether the package should be installed or removed.

Choices:

  • "absent"

  • "installed"

  • "present" ← (default)

  • "removed"

update_cache

boolean

Update the package cache (opkg update) before performing the operation.

Choices:

  • false

  • 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.opkg:
    name: vim
    state: present

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

- name: Install multiple packages
  community.openwrt.opkg:
    name: vim,curl,wget
    state: present

- name: Update cache and install package
  community.openwrt.opkg:
    name: nginx
    state: present
    update_cache: true

- name: Force reinstall a package
  community.openwrt.opkg:
    name: busybox
    state: present
    force: reinstall

- name: Install a package using a custom opkg configuration file
  community.openwrt.opkg:
    name: python3-base
    state: present
    conf_file: /etc/opkg/openwrt.conf

Authors

  • Markus Weippert (@gekmihesg)