home-server/roles/aur.inc/tasks/main.yml

62 lines
2.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 20182023 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.
# mandatory parameters:
# - pkg_names (json-encoded list)
# - aur_user
- name: AUR → read (or create) requested HOME while running AUR tasks
shell: |
case "$aur_requested_home" in
'') printf '%s' "$HOME" ;;
'!mktemp') sudo -u "$aur_user_name" mktemp -d /tmp/AUR-TEMP-HOME-XXXX ;;
*) printf '%s' "$aur_requested_home" ;;
esac
environment:
aur_requested_home: "{{(aur_user is mapping) | ternary(aur_user.home, '')}}"
aur_user_name: "{{(aur_user is mapping) | ternary(aur_user.name, aur_user)}}"
register: requestedHome
changed_when: false
- name: AUR → run AUR tasks
block:
- name: AUR → see effective HOME
debug:
var: requestedHome
changed_when: false
- name: AUR → base-devel needed while building
become: false
command: |
pacman -S --noconfirm --noprogressbar --asdeps --needed base-devel
changed_when: false
- name: AUR → proceed with installation
block:
- name: AUR → installation
include_tasks: install.yml
vars:
aur_name: "{{(aur_user is mapping) | ternary(aur_user.name, aur_user)}}"
aur_home: "{{requestedHome.stdout}}"
pkg_name: "{{(item is mapping) | ternary(item.pkg, item)}}"
pre_cmd: "{{(item is mapping) | ternary(item.pre, '')}}"
with_items: "{{packages}}"
always:
- name: AUR → remove base-devel and dependencies
shell: |
pacman -Rns --noconfirm --noprogressbar base-devel || true
changed_when: false
always:
- name: AUR → remove temporary HOME
file:
path: "{{requestedHome.stdout}}"
state: absent
when:
- (aur_user is mapping)
- (aur_user.home == '!mktemp')
changed_when: false