apk Operations¶
Manage apk packages. (Alpine Linux)
Facts used in these operations: apk.ApkPackages.
apk.packages¶
Add/remove/update apk packages.
apk.packages(
packages: 'str | list[str] | None' = None,
present=True,
latest=False,
update=False,
upgrade=False,
**kwargs,
)
- packages: list of packages to ensure
- present: whether the packages should be installed
- latest: whether to upgrade packages without a specified version
- update: run
apk updatebefore installing packages - upgrade: run
apk upgradebefore installing packages
Versions:
Package versions can be pinned like apk: <pkg>=<version>.
Examples:
from pyinfra.operations import apk
# Update package list and install packages
apk.packages(
name="Install Asterisk and Vim",
packages=["asterisk", "vim"],
update=True,
)
# Install the latest versions of packages (always check)
apk.packages(
name="Install latest Vim",
packages=["vim"],
latest=True,
)
Global arguments
This operation also inherits all global arguments.
apk.update¶
Stateless operation
This operation will always execute commands and is not idempotent.
Updates apk repositories.
Global arguments
This operation also inherits all global arguments.
apk.upgrade¶
Stateless operation
This operation will always execute commands and is not idempotent.
Upgrades all apk packages.
- available: force all packages to be upgraded (recommended on whole Alpine version upgrades)
Global arguments
This operation also inherits all global arguments.