Ansible APK Module
This material is work-in-progress ...
Do not follow instructions here until this notice is removed.
Alpine Linux uses APK for all package management. As of Ansible 2.0, there is an apk.py module included in Ansible that provides support for package management on Alpine Linux hosts. This document provides some playbook samples and explanations for using this Ansible module.
Details on Module Options
The 'name' option can contain a single package or list of packages to install.
The 'state' option specifies what you want to do with the listed package(s) - present (installed but not upgraded), latest (installed or upgraded), absent (removed). The option defaults to 'present', so this command will not upgrade a package that is already installed if 'state' is not specified as 'latest'.
It is always a good idea to include the 'update_cache' option, because the command might fail otherwise if the repository contains a newer version of the package than listed in the local package index. The name 'update_cache' is slightly misleading, because it actually refers to the package index, not the local package cache.
The 'upgrade' option is a system-wide upgrade of all packages. If you want to upgrade specific packages, use 'state' = 'latest'.
repository (Ansible 2.4)
If the 'repository' option is not specified, 'apk' will use the system repository specified in /etc/apk/repositories. More specifically, it will always use the local package index, and that package index will be updated from the system repository specified in /etc/apk/repositories if 'update_cache' is set. If you specify a 'repository', 'apk' will use both the system repository and those specified in the command. ??? NEED TO VERIFY ??? Note that 'apk' will install the newest package if multiple versions of the same package are available in the package index(es).
available (Ansible 2.4)
The 'available' option only applies to the 'upgrade' option. According to the documentation: "During upgrade, reset versioned world dependencies and change logic to prefer replacing or downgrading packages (instead of holding them) if the currently installed package is no longer available from any repository."
Basic Package Installation
# Update repositories and install "foo" package - apk: name: foo update_cache: yes
tagged repos restarting services check doesn't do actual update system upgrade / downgrade