mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fa865a19a5
Fix pacman tests in CI (#8102)
Fix pacman tests.
(cherry picked from commit 23fbc5e241
)
Co-authored-by: Felix Fontein <felix@fontein.de>
86 lines
2.1 KiB
YAML
86 lines
2.1 KiB
YAML
---
|
|
# 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
|
|
|
|
- vars:
|
|
package_name: ansible-test-foo
|
|
username: ansible-regular-user
|
|
block:
|
|
- name: Install dependencies
|
|
pacman:
|
|
state: present
|
|
name:
|
|
- fakeroot
|
|
- debugedit
|
|
|
|
- name: Create user
|
|
user:
|
|
name: '{{ username }}'
|
|
home: '/home/{{ username }}'
|
|
create_home: true
|
|
|
|
- name: Create directory
|
|
file:
|
|
path: '/home/{{ username }}/{{ package_name }}'
|
|
state: directory
|
|
owner: '{{ username }}'
|
|
|
|
- name: Create PKGBUILD
|
|
copy:
|
|
dest: '/home/{{ username }}/{{ package_name }}/PKGBUILD'
|
|
content: |
|
|
pkgname=('{{ package_name }}')
|
|
pkgver=1.0.0
|
|
pkgrel=1
|
|
pkgdesc="Test removing a local package not in the repositories"
|
|
arch=('any')
|
|
license=('GPL v3+')
|
|
owner: '{{ username }}'
|
|
|
|
- name: Build package
|
|
command:
|
|
cmd: su {{ username }} -c "makepkg -srf"
|
|
chdir: '/home/{{ username }}/{{ package_name }}'
|
|
|
|
- name: Install package
|
|
pacman:
|
|
state: present
|
|
name:
|
|
- '/home/{{ username }}/{{ package_name }}/{{ package_name }}-1.0.0-1-any.pkg.tar.zst'
|
|
|
|
- name: Remove package (check mode)
|
|
pacman:
|
|
state: absent
|
|
name:
|
|
- '{{ package_name }}'
|
|
check_mode: true
|
|
register: remove_1
|
|
|
|
- name: Remove package
|
|
pacman:
|
|
state: absent
|
|
name:
|
|
- '{{ package_name }}'
|
|
register: remove_2
|
|
|
|
- name: Remove package (idempotent)
|
|
pacman:
|
|
state: absent
|
|
name:
|
|
- '{{ package_name }}'
|
|
register: remove_3
|
|
|
|
- name: Check conditions
|
|
assert:
|
|
that:
|
|
- remove_1 is changed
|
|
- remove_2 is changed
|
|
- remove_3 is not changed
|
|
|
|
always:
|
|
- name: Remove directory
|
|
file:
|
|
path: '{{ remote_tmp_dir }}/{{ package_name }}'
|
|
state: absent
|
|
become: true
|