mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
[PR #6713/f6ee2177 backport][stable-6] pacman: support yay as root (#6895)
* pacman: support yay as root (#6713)
* pacman: support yay as root
* make pylint happy
* minor adjustments
* rollback some test actions
* removal of user and pkgs in handlers
* add comment to note
* add changelog frag
* fix doc
* Update tests/integration/targets/pacman/tasks/yay-become.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update tests/integration/targets/pacman/tasks/yay-become.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
* simplify pkg install in int. tests
---------
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit f6ee2177a2
)
* Switch to old markup.
---------
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
1a4ae5e9aa
commit
c92215d339
5 changed files with 116 additions and 12 deletions
23
tests/integration/targets/pacman/handlers/main.yml
Normal file
23
tests/integration/targets/pacman/handlers/main.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: Remove user yaybuilder
|
||||
ansible.builtin.user:
|
||||
name: yaybuilder
|
||||
state: absent
|
||||
|
||||
- name: Remove yay
|
||||
ansible.builtin.package:
|
||||
name: yay
|
||||
state: absent
|
||||
|
||||
- name: Remove packages for yay-become
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- base-devel
|
||||
- yay
|
||||
- git
|
||||
- nmap
|
||||
state: absent
|
|
@ -17,3 +17,4 @@
|
|||
- include_tasks: 'update_cache.yml'
|
||||
- include_tasks: 'locally_installed_package.yml'
|
||||
- include_tasks: 'reason.yml'
|
||||
- include_tasks: 'yay-become.yml'
|
||||
|
|
66
tests/integration/targets/pacman/tasks/yay-become.yml
Normal file
66
tests/integration/targets/pacman/tasks/yay-become.yml
Normal file
|
@ -0,0 +1,66 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# This is more convoluted that one might expect, because:
|
||||
# - yay is not available or installation in ArchLinux (as it is in Manjaro - issue 6184 reports using it)
|
||||
# - to install yay in ArchLinux requires building the package
|
||||
# - makepkg cannot be run as root, but the user running it must have sudo to install the resulting package
|
||||
|
||||
- name: create user
|
||||
ansible.builtin.user:
|
||||
name: yaybuilder
|
||||
state: present
|
||||
notify: Remove user yaybuilder
|
||||
|
||||
- name: grant sudo powers to builder
|
||||
community.general.sudoers:
|
||||
name: yaybuilder
|
||||
user: yaybuilder
|
||||
commands: ALL
|
||||
nopassword: true
|
||||
|
||||
- name: Install base packages
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- base-devel
|
||||
- git
|
||||
- go
|
||||
state: present
|
||||
notify: Remove packages for yay-become
|
||||
|
||||
- name: Hack permssions for the remote_tmp_dir
|
||||
ansible.builtin.file:
|
||||
path: "{{ remote_tmp_dir }}"
|
||||
mode: '0777'
|
||||
|
||||
- name: Create temp directory for builder
|
||||
ansible.builtin.file:
|
||||
path: "{{ remote_tmp_dir }}/builder"
|
||||
owner: yaybuilder
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: clone yay git repo
|
||||
become: true
|
||||
become_user: yaybuilder
|
||||
ansible.builtin.git:
|
||||
repo: https://aur.archlinux.org/yay.git
|
||||
dest: "{{ remote_tmp_dir }}/builder/yay"
|
||||
depth: 1
|
||||
|
||||
- name: make package
|
||||
become: true
|
||||
become_user: yaybuilder
|
||||
ansible.builtin.command:
|
||||
chdir: "{{ remote_tmp_dir }}/builder/yay"
|
||||
cmd: makepkg -si --noconfirm
|
||||
notify: Remove yay
|
||||
|
||||
- name: Install nmap
|
||||
community.general.pacman:
|
||||
name: nmap
|
||||
state: present
|
||||
executable: yay
|
||||
extra_args: --builddir /var/cache/yay
|
Loading…
Add table
Add a link
Reference in a new issue