mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
391c3aa850
* pacman: re-adding support for URL based pkgs
* Update plugins/modules/packaging/os/pacman.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/modules/packaging/os/pacman.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* cmd=cmd in every call to self.fail()
* pacman: integration test for mixed pkg sources
* Add more tests + fix minor bug with URL packages
Version checking for URL packages is left to pacman, so add a check
after the dry run to see if it would actually install anything.
* remove double templating
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit a9db4742fc
)
Co-authored-by: Jean Raby <jean@raby.sh>
125 lines
3.6 KiB
YAML
125 lines
3.6 KiB
YAML
---
|
|
- vars:
|
|
reg_pkg: ed
|
|
url_pkg: lemon
|
|
file_pkg: hdparm
|
|
file_pkg_path: /tmp/pkg.zst
|
|
extra_pkg: core/sdparm
|
|
extra_pkg_outfmt: sdparm
|
|
block:
|
|
- name: Make sure that test packages are not installed
|
|
pacman:
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg}}'
|
|
- '{{file_pkg}}'
|
|
- '{{extra_pkg}}'
|
|
state: absent
|
|
|
|
- name: Get URL for {{url_pkg}}
|
|
command:
|
|
cmd: pacman --sync --print-format "%l" {{url_pkg}}
|
|
register: url_pkg_url
|
|
|
|
- name: Get URL for {{file_pkg}}
|
|
command:
|
|
cmd: pacman --sync --print-format "%l" {{file_pkg}}
|
|
register: file_pkg_url
|
|
- name: Download {{file_pkg}} pkg
|
|
get_url:
|
|
url: '{{file_pkg_url.stdout}}'
|
|
dest: '{{file_pkg_path}}'
|
|
|
|
- name: Install packages from mixed sources (check mode)
|
|
pacman:
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg_url.stdout}}'
|
|
- '{{file_pkg_path}}'
|
|
check_mode: True
|
|
register: install_1
|
|
|
|
- name: Install packages from mixed sources
|
|
pacman:
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg_url.stdout}}'
|
|
- '{{file_pkg_path}}'
|
|
register: install_2
|
|
|
|
- name: Install packages from mixed sources - (idempotency)
|
|
pacman:
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg_url.stdout}}'
|
|
- '{{file_pkg_path}}'
|
|
register: install_3
|
|
|
|
- name: Install packages with their regular names (idempotency)
|
|
pacman:
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg}}'
|
|
- '{{file_pkg}}'
|
|
register: install_4
|
|
|
|
- name: Install new package with already installed packages from mixed sources
|
|
pacman:
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg_url.stdout}}'
|
|
- '{{file_pkg_path}}'
|
|
- '{{extra_pkg}}'
|
|
register: install_5
|
|
|
|
- name: Uninstall packages - mixed sources (check mode)
|
|
pacman:
|
|
state: absent
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg_url.stdout}}'
|
|
- '{{file_pkg_path}}'
|
|
check_mode: True
|
|
register: uninstall_1
|
|
|
|
- name: Uninstall packages - mixed sources
|
|
pacman:
|
|
state: absent
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg_url.stdout}}'
|
|
- '{{file_pkg_path}}'
|
|
register: uninstall_2
|
|
|
|
- name: Uninstall packages - mixed sources (idempotency)
|
|
pacman:
|
|
state: absent
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg_url.stdout}}'
|
|
- '{{file_pkg_path}}'
|
|
register: uninstall_3
|
|
|
|
- assert:
|
|
that:
|
|
- install_1 is changed
|
|
- install_1.msg == 'Would have installed 3 packages'
|
|
- install_1.packages|sort() == [reg_pkg, url_pkg, file_pkg]|sort()
|
|
- install_2 is changed
|
|
- install_2.msg == 'Installed 3 package(s)'
|
|
- install_1.packages|sort() == [reg_pkg, url_pkg, file_pkg]|sort()
|
|
- install_3 is not changed
|
|
- install_3.msg == 'package(s) already installed'
|
|
- install_4 is not changed
|
|
- install_4.msg == 'package(s) already installed'
|
|
- install_5 is changed
|
|
- install_5.msg == 'Installed 1 package(s)'
|
|
- install_5.packages == [extra_pkg_outfmt]
|
|
- uninstall_1 is changed
|
|
- uninstall_1.msg == 'Would have removed 3 packages'
|
|
- uninstall_1.packages | length() == 3 # pkgs have versions here
|
|
- uninstall_2 is changed
|
|
- uninstall_2.msg == 'Removed 3 package(s)'
|
|
- uninstall_2.packages | length() == 3
|
|
- uninstall_3 is not changed
|
|
- uninstall_3.msg == 'package(s) already absent'
|