Apk Operations¶
Manage apk packages.
Facts used in these operations: apk.ApkPackages.
apk.packages¶
Add/remove/update apk packages.
apk.packages(packages=None, present=True, latest=False, update=False, upgrade=False)
- 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:
# 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,
)
apk.update¶
Stateless operation
This operation will always execute commands and is not idempotent.
Updates apk repositories.
apk.update()
apk.upgrade¶
Stateless operation
This operation will always execute commands and is not idempotent.
Upgrades all apk packages.
apk.upgrade(available=False)
- available: force all packages to be upgraded (recommended on whole Alpine version upgrades)
pyinfra 2.x