luizgavalda.aur
Ansible AUR Helper
This Ansible module helps you manage packages from the Arch User Repository (AUR) using different helpers and makepkg.
Supported Helpers
The following package helpers are automatically used if they are available, in this order:
If no helper is found, or you specify it, makepkg will be used:
Options
Parameter | Choices/Default | Description |
---|---|---|
name | Name(s) of the package(s) to install or update. | |
state | present, latest | Desired status of the package; 'present' means skip if already installed. |
upgrade | yes, no | Choose to upgrade the entire system or not. |
use | auto, yay, paru, pacaur, trizen, pikaur, aurman, makepkg | Select which tool to use; 'auto' chooses the first available helper. |
extra_args | null | Additional arguments for the tool; cannot be used in 'auto' mode. |
aur_only | yes, no | Limit operations to the AUR only. |
local_pkgbuild | Local directory with PKGBUILD, null | Only for use with makepkg or pikaur. Build from local files instead of downloading from AUR. |
skip_pgp_check | yes, no | Only for use with makepkg. Skip PGP check of source files; useful if GnuPG isn't set up properly. |
ignore_arch | yes, no | Only for makepkg. Ignore missing architecture info in PKGBUILD. |
Important Notes
- You need to specify either name or upgrade, not both.
- In use=auto mode, makepkg will be the backup if no helpers are found.
Installation
AUR Package
You can find the ansible-aur-git package in the AUR.
The module gets installed in /usr/share/ansible/plugins/modules
, one of the default module paths.
Manual Installation
Clone the ansible-aur repository into your custom module directory:
git clone https://github.com/luizgavalda/ansible-aur.git ~/.ansible/plugins/modules/aur
Ansible Galaxy
ansible-aur is also available on Galaxy, a hub for Ansible content. To install it, run:
ansible-galaxy install luizgavalda.aur
If installed from Galaxy, you'll need to include it in your playbook:
# playbook.yml
- hosts: localhost
roles:
- luizgavalda.aur
tasks:
- aur: name=package_name
Or in your role's metadata:
# meta/main.yml
dependencies:
- luizgavalda.aur
# tasks/main.yml
- aur: name=package_name
Usage
Notes
- This module is meant for installing and updating AUR packages; use the official pacman module for package removal or updates from repositories.
- The helper's --needed parameter is used, meaning if a package is up-to-date, it won't be rebuilt.
Create an "aur_builder" User
While Ansible may SSH as root, makepkg and AUR helpers cannot run as root, resulting in an error. Thus, create a non-root user (like aur_builder) that can use pacman without a password.
You can create this user in an Ansible task:
- user:
name: aur_builder
create_home: no
group: wheel
- lineinfile:
path: /etc/sudoers.d/11-install-aur_builder
line: 'aur_builder ALL=(ALL) NOPASSWD: /usr/bin/pacman'
create: yes
validate: 'visudo -cf %s'
Examples
Here are a few examples of how to use the module in tasks:
# Install trizen using makepkg, skip if already installed
- aur: name=trizen use=makepkg state=present
become: yes
become_user: aur_builder
# Install package_name using the first known helper
- aur: name=package_name
become: yes
become_user: aur_builder
# Install multiple packages using yay
- aur:
use: yay
name:
- package_name_1
- package_name_2
# Upgrade the system with yay, focusing on AUR packages
- aur: upgrade=yes use=yay aur_only=yes
# Install a package using pikaur and a local PKGBUILD
- aur:
name: gnome-shell-extension-caffeine-git
use: pikaur
local_pkgbuild: {{ role_path }}/files/gnome-shell-extension-caffeine-git
state: present
become: yes
become_user: aur_builder
Ansible module to use some Arch User Repository (AUR) helpers as well as makepkg.
ansible-galaxy install luizgavalda.aur