mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
2cc72c2213
* Pacman: Add support for setting install reason
* Improved description
* Fix documentation
* Add changelog fragment
* Use source for installation
* Get all reasons at once
* Removed default for reason
* Added version info to documentation
* Fix NameError
* Moved determination of reason to _build_inventory
* Fix duplication and sanity errors
* adjust tests for changed inventory
* Documentation: remove empty default for reason
* mention packages with changed reason in exit params/info
* Added integration tests for reason and reason_for
Inspired by the integration tests for url packages
* Correct indentation
* Fix indentation
* Also sort changed packages in normal mode
* Also sort result in unit test
* Apply suggestions from code review
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 9f3841703f
)
Co-authored-by: Minei3oat <Minei3oat@users.noreply.github.com>
97 lines
2.9 KiB
YAML
97 lines
2.9 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 as dependency (check mode)
|
|
pacman:
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg_url.stdout}}'
|
|
- '{{file_pkg_path}}'
|
|
reason: dependency
|
|
check_mode: True
|
|
register: install_1
|
|
|
|
- name: Install packages from mixed sources as explicit
|
|
pacman:
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg_url.stdout}}'
|
|
- '{{file_pkg_path}}'
|
|
reason: explicit
|
|
register: install_2
|
|
|
|
- name: Install packages from mixed sources with new packages being installed as dependency - (idempotency)
|
|
pacman:
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg_url.stdout}}'
|
|
- '{{file_pkg_path}}'
|
|
reason: dependency
|
|
register: install_3
|
|
|
|
- name: Install new package with already installed packages from mixed sources as dependency
|
|
pacman:
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg_url.stdout}}'
|
|
- '{{file_pkg_path}}'
|
|
- '{{extra_pkg}}'
|
|
reason: dependency
|
|
register: install_4
|
|
|
|
- name: Set install reason for all packages to dependency
|
|
pacman:
|
|
name:
|
|
- '{{reg_pkg}}'
|
|
- '{{url_pkg_url.stdout}}'
|
|
- '{{file_pkg_path}}'
|
|
- '{{extra_pkg}}'
|
|
reason: dependency
|
|
reason_for: all
|
|
register: install_5
|
|
|
|
- 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_2.packages|sort() == [reg_pkg, url_pkg, file_pkg]|sort()
|
|
- install_3 is not changed
|
|
- install_3.msg == 'package(s) already installed'
|
|
- install_4 is changed
|
|
- install_4.msg == 'Installed 1 package(s)'
|
|
- install_4.packages == [extra_pkg_outfmt]
|
|
- install_5 is changed
|
|
- install_5.msg == 'Installed 3 package(s)'
|
|
- install_5.packages|sort() == [reg_pkg, url_pkg, file_pkg]|sort()
|