community.general.pacman – Manage packages with pacman
Note
This plugin is part of the community.general collection (version 3.8.3).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.pacman
.
Synopsis
Manage packages with the pacman package manager, which is used by Arch Linux and its variants.
Parameters
Parameter |
Comments |
---|---|
Name of binary to use. This can either be Beware that AUR helpers might behave unexpectedly and are therefore not recommended. Default: “pacman” |
|
Additional option to pass to pacman when enforcing |
|
When removing package, force remove package, without any checks. Same as extra_args=”–nodeps –nodeps”. When update_cache, force redownload repo databases. Same as update_cache_extra_args=”–refresh –refresh”. Choices:
|
|
Name or list of names of the package(s) or file(s) to install, upgrade, or remove. Can’t be used in combination with |
|
Whether to install (
Choices:
|
|
Whether or not to refresh the master package lists. This can be run as part of a package installation or as a separate step. Alias Choices:
|
|
Additional option to pass to pacman when enforcing |
|
Whether or not to upgrade the whole system. Can’t be used in combination with Choices:
|
|
Additional option to pass to pacman when enforcing |
Notes
Note
When used with a
loop:
each package will be processed individually, it is much more efficient to pass the list directly to the name option.To use an AUR helper (executable option), a few extra setup steps might be required beforehand. For example, a dedicated build user with permissions to install packages could be necessary.
Examples
- 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
community.general.pacman:
name: foo
state: latest
update_cache: yes
- 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: yes
- name: Run the equivalent of "pacman -Su" as a separate step
community.general.pacman:
upgrade: yes
- name: Run the equivalent of "pacman -Syu" as a separate step
community.general.pacman:
update_cache: yes
upgrade: yes
- name: Run the equivalent of "pacman -Rdd", force remove package baz
community.general.pacman:
name: baz
state: absent
force: yes
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
a list of packages that have been changed Returned: when upgrade is set to yes Sample: [“package”, “other-package”] |
Authors
Indrajit Raychaudhuri (@indrajitr)
Aaron Bull Schaefer (@elasticdog) <aaron@elasticdog.com>
Maxime de Roucy (@tchernomax)