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

62 lines
2.0 KiB
YAML
Raw Normal View History

2018-09-03 20:06:05 +02:00
---
# The home-server project produces a multi-purpose setup using Ansible.
2023-07-30 19:31:56 +02:00
# Copyright © 20182023 Y. Gablin, under the GPL-3.0-or-later license.
2018-09-03 20:06:05 +02:00
# 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
2023-07-30 19:31:56 +02:00
- 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
2018-09-03 20:06:05 +02:00
changed_when: false
2023-07-30 19:31:56 +02:00
- name: AUR → run AUR tasks
2018-09-03 20:06:05 +02:00
block:
2023-07-30 19:31:56 +02:00
- 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
2018-09-03 20:06:05 +02:00
always:
2023-07-30 19:31:56 +02:00
- name: AUR → remove temporary HOME
file:
path: "{{requestedHome.stdout}}"
state: absent
when:
- (aur_user is mapping)
- (aur_user.home == '!mktemp')
2018-09-03 20:06:05 +02:00
changed_when: false