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 packagesupgrade: 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,
)
Note
This operation also inherits all global arguments.
apk.update¶
Stateless operation
This operation will always execute commands and is not idempotent.
Updates apk repositories.
apk.update**kwargs, )
Note
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.
apk.upgrade(available: 'bool' = False,
**kwargs,
)
available: force all packages to be upgraded (recommended on whole Alpine version upgrades)
Note
This operation also inherits all global arguments.
pyinfra 3.x