community / community.general / 6.6.8 / module / pacman Manage packages with I(pacman) Authors: Indrajit Raychaudhuri (@indrajitr), Aaron Bull Schaefer (@elasticdog) <aaron@elasticdog.com>, Maxime de Roucy (@tchernomax), Jean Raby (@jraby)community.general.pacman (6.6.8) — module
Install with ansible-galaxy collection install community.general:==6.6.8
collections: - name: community.general version: 6.6.8
Manage packages with the I(pacman) package manager, which is used by Arch Linux and its variants.
- name: Install package foo from repo community.general.pacman: name: foo state: present
- name: Install package bar from file community.general.pacman: name: ~/bar-1.0-1-any.pkg.tar.xz state: present
- name: Install package foo from repo and bar from file community.general.pacman: name: - foo - ~/bar-1.0-1-any.pkg.tar.xz state: present
- name: Install package from AUR using a Pacman compatible AUR helper community.general.pacman: name: foo state: present executable: yay extra_args: --builddir /var/cache/yay
- name: Upgrade package foo # The 'changed' state of this call will indicate whether the cache was # updated *or* whether foo was installed/upgraded. community.general.pacman: name: foo state: latest update_cache: true
- name: Remove packages foo and bar community.general.pacman: name: - foo - bar state: absent
- name: Recursively remove package baz community.general.pacman: name: baz state: absent extra_args: --recursive
- name: Run the equivalent of "pacman -Sy" as a separate step community.general.pacman: update_cache: true
- name: Run the equivalent of "pacman -Su" as a separate step community.general.pacman: upgrade: true
- name: Run the equivalent of "pacman -Syu" as a separate step # Since community.general 5.0.0 the 'changed' state of this call # will be 'true' in case the cache was updated, or when a package # was updated. # # The previous behavior was to only indicate whether something was # upgraded. To keep the old behavior, add the following to the task: # # register: result # changed_when: result.packages | length > 0 community.general.pacman: update_cache: true upgrade: true
- name: Run the equivalent of "pacman -Rdd", force remove package baz community.general.pacman: name: baz state: absent force: true
- name: Install foo as dependency and leave reason untouched if already installed community.general.pacman: name: foo state: present reason: dependency reason_for: new
- name: Run the equivalent of "pacman -S --asexplicit", mark foo as explicit and install it if not present community.general.pacman: name: foo state: present reason: explicit reason_for: all
name: aliases: - package - pkg description: - Name or list of names of the package(s) or file(s) to install, upgrade, or remove. Can't be used in combination with C(upgrade). elements: str type: list force: default: false description: - When removing packages, forcefully remove them, without any checks. Same as I(extra_args="--nodeps --nodeps"). When combined with I(update_cache), force a refresh of all package databases. Same as I(update_cache_extra_args="--refresh --refresh"). type: bool state: choices: - absent - installed - latest - present - removed default: present description: - Whether to install (C(present) or C(installed), C(latest)), or remove (C(absent) or C(removed)) a package. - C(present) and C(installed) will simply ensure that a desired package is installed. - C(latest) will update the specified package if it is not of the latest available version. - C(absent) and C(removed) will remove the specified package. type: str reason: choices: - dependency - explicit description: - The install reason to set for the packages. type: str version_added: 5.4.0 version_added_collection: community.general upgrade: description: - Whether or not to upgrade the whole system. Can't be used in combination with C(name). - If not specified, it defaults to C(false). type: bool executable: default: pacman description: - Path of the binary to use. This can either be C(pacman) or a pacman compatible AUR helper. - Pacman compatibility is unfortunately ill defined, in particular, this modules makes extensive use of the C(--print-format) directive which is known not to be implemented by some AUR helpers (notably, C(yay)). - Beware that AUR helpers might behave unexpectedly and are therefore not recommended. type: str version_added: 3.1.0 version_added_collection: community.general extra_args: default: '' description: - Additional option to pass to pacman when enforcing C(state). type: str reason_for: choices: - all - new default: new description: - Set the install reason for C(all) packages or only for C(new) packages. - In case of I(state=latest) already installed packages which will be updated to a newer version are not counted as C(new). type: str version_added: 5.4.0 version_added_collection: community.general update_cache: description: - Whether or not to refresh the master package lists. - This can be run as part of a package installation or as a separate step. - If not specified, it defaults to C(false). - Please note that this option only had an influence on the module's C(changed) state if I(name) and I(upgrade) are not specified before community.general 5.0.0. See the examples for how to keep the old behavior. type: bool remove_nosave: default: false description: - When removing packages, do not save modified configuration files as C(.pacsave) files. (passes C(--nosave) to pacman) type: bool version_added: 4.6.0 version_added_collection: community.general upgrade_extra_args: default: '' description: - Additional option to pass to pacman when enforcing C(upgrade). type: str update_cache_extra_args: default: '' description: - Additional option to pass to pacman when enforcing C(update_cache). type: str
cache_updated: description: - The changed status of C(pacman -Sy). - Useful when I(name) or I(upgrade=true) are specified next to I(update_cache=true). returned: success, when I(update_cache=true) sample: false type: bool version_added: 4.6.0 version_added_collection: community.general packages: description: - A list of packages that have been changed. - Before community.general 4.5.0 this was only returned when I(upgrade=true). In community.general 4.5.0, it was sometimes omitted when the package list is empty, but since community.general 4.6.0 it is always returned when I(name) is specified or I(upgrade=true). elements: str returned: success and I(name) is specified or I(upgrade=true) sample: - package - other-package type: list stderr: description: - Error output from pacman. returned: success, when needed sample: 'warning: libtool: local (2.4.6+44+gb9b44533-14) is newer than core (2.4.6+42+gb88cebd5-15) warning ...' type: str version_added: 4.1.0 version_added_collection: community.general stdout: description: - Output from pacman. returned: success, when needed sample: ':: Synchronizing package databases... core is up to date :: Starting full system upgrade...' type: str version_added: 4.1.0 version_added_collection: community.general