2022-03-01 06:34:27 +01:00
|
|
|
---
|
|
|
|
- vars:
|
2022-07-27 07:41:37 +02:00
|
|
|
http_port: 27617
|
2022-03-01 06:34:27 +01:00
|
|
|
reg_pkg: ed
|
|
|
|
url_pkg: lemon
|
2022-07-27 07:41:37 +02:00
|
|
|
url_pkg_filename: url.pkg.zst
|
|
|
|
url_pkg_path: '/tmp/'
|
|
|
|
url_pkg_url: 'http://localhost:{{http_port}}/{{url_pkg_filename}}'
|
2022-03-01 06:34:27 +01:00
|
|
|
file_pkg: hdparm
|
2022-07-27 07:41:37 +02:00
|
|
|
file_pkg_path: /tmp/file.pkg.zst
|
2022-03-01 06:34:27 +01:00
|
|
|
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
|
2022-07-27 07:41:37 +02:00
|
|
|
- name: Make sure that url package is not cached
|
|
|
|
file:
|
|
|
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
|
|
|
state: absent
|
2022-03-01 06:34:27 +01:00
|
|
|
|
|
|
|
- name: Get URL for {{url_pkg}}
|
|
|
|
command:
|
|
|
|
cmd: pacman --sync --print-format "%l" {{url_pkg}}
|
2022-07-27 07:41:37 +02:00
|
|
|
register: url_pkg_stdout
|
|
|
|
- name: Download {{url_pkg}} pkg
|
|
|
|
get_url:
|
|
|
|
url: '{{url_pkg_stdout.stdout}}'
|
|
|
|
dest: '{{url_pkg_path}}/{{url_pkg_filename}}'
|
|
|
|
- name: Download {{url_pkg}} pkg sig
|
|
|
|
get_url:
|
|
|
|
url: '{{url_pkg_stdout.stdout}}.sig'
|
|
|
|
dest: '{{url_pkg_path}}/{{url_pkg_filename}}.sig'
|
|
|
|
- name: Host {{url_pkg}}
|
|
|
|
shell:
|
|
|
|
cmd: 'python -m http.server --directory {{url_pkg_path}} {{http_port}} >/dev/null 2>&1'
|
|
|
|
async: 90
|
|
|
|
poll: 0
|
|
|
|
- name: Wait for http.server to come up online
|
|
|
|
wait_for:
|
|
|
|
host: 'localhost'
|
|
|
|
port: '{{http_port}}'
|
|
|
|
state: started
|
2022-03-01 06:34:27 +01:00
|
|
|
|
|
|
|
- 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}}'
|
2022-07-27 07:41:37 +02:00
|
|
|
- '{{url_pkg_url}}'
|
2022-03-01 06:34:27 +01:00
|
|
|
- '{{file_pkg_path}}'
|
|
|
|
check_mode: True
|
|
|
|
register: install_1
|
|
|
|
|
2022-07-27 07:41:37 +02:00
|
|
|
- name: Install packages from url (check mode, cached)
|
|
|
|
pacman:
|
|
|
|
name:
|
|
|
|
- '{{url_pkg_url}}'
|
|
|
|
check_mode: True
|
|
|
|
register: install_1c
|
|
|
|
- name: Delete cached {{url_pkg}}
|
|
|
|
file:
|
|
|
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
|
|
|
state: absent
|
|
|
|
|
2022-03-01 06:34:27 +01:00
|
|
|
- name: Install packages from mixed sources
|
|
|
|
pacman:
|
|
|
|
name:
|
|
|
|
- '{{reg_pkg}}'
|
2022-07-27 07:41:37 +02:00
|
|
|
- '{{url_pkg_url}}'
|
2022-03-01 06:34:27 +01:00
|
|
|
- '{{file_pkg_path}}'
|
|
|
|
register: install_2
|
2022-07-27 07:41:37 +02:00
|
|
|
- name: Delete cached {{url_pkg}}
|
|
|
|
file:
|
|
|
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
|
|
|
state: absent
|
2022-03-01 06:34:27 +01:00
|
|
|
|
|
|
|
- name: Install packages from mixed sources - (idempotency)
|
|
|
|
pacman:
|
|
|
|
name:
|
|
|
|
- '{{reg_pkg}}'
|
2022-07-27 07:41:37 +02:00
|
|
|
- '{{url_pkg_url}}'
|
2022-03-01 06:34:27 +01:00
|
|
|
- '{{file_pkg_path}}'
|
|
|
|
register: install_3
|
2022-07-27 07:41:37 +02:00
|
|
|
- name: Install packages from url - (idempotency, cached)
|
|
|
|
pacman:
|
|
|
|
name:
|
|
|
|
- '{{url_pkg_url}}'
|
|
|
|
register: install_3c
|
|
|
|
- name: Delete cached {{url_pkg}}
|
|
|
|
file:
|
|
|
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
|
|
|
state: absent
|
2022-03-01 06:34:27 +01:00
|
|
|
|
|
|
|
- name: Install packages with their regular names (idempotency)
|
|
|
|
pacman:
|
|
|
|
name:
|
|
|
|
- '{{reg_pkg}}'
|
|
|
|
- '{{url_pkg}}'
|
|
|
|
- '{{file_pkg}}'
|
|
|
|
register: install_4
|
2022-07-27 07:41:37 +02:00
|
|
|
- name: Delete cached {{url_pkg}}
|
|
|
|
file:
|
|
|
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
|
|
|
state: absent
|
2022-03-01 06:34:27 +01:00
|
|
|
|
|
|
|
- name: Install new package with already installed packages from mixed sources
|
|
|
|
pacman:
|
|
|
|
name:
|
|
|
|
- '{{reg_pkg}}'
|
2022-07-27 07:41:37 +02:00
|
|
|
- '{{url_pkg_url}}'
|
2022-03-01 06:34:27 +01:00
|
|
|
- '{{file_pkg_path}}'
|
|
|
|
- '{{extra_pkg}}'
|
|
|
|
register: install_5
|
2022-07-27 07:41:37 +02:00
|
|
|
- name: Delete cached {{url_pkg}}
|
|
|
|
file:
|
|
|
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
|
|
|
state: absent
|
2022-03-01 06:34:27 +01:00
|
|
|
|
|
|
|
- name: Uninstall packages - mixed sources (check mode)
|
|
|
|
pacman:
|
|
|
|
state: absent
|
|
|
|
name:
|
|
|
|
- '{{reg_pkg}}'
|
2022-07-27 07:41:37 +02:00
|
|
|
- '{{url_pkg_url}}'
|
2022-03-01 06:34:27 +01:00
|
|
|
- '{{file_pkg_path}}'
|
|
|
|
check_mode: True
|
|
|
|
register: uninstall_1
|
2022-07-27 07:41:37 +02:00
|
|
|
- name: Uninstall packages - url (check mode, cached)
|
|
|
|
pacman:
|
|
|
|
state: absent
|
|
|
|
name:
|
|
|
|
- '{{url_pkg_url}}'
|
|
|
|
check_mode: True
|
|
|
|
register: uninstall_1c
|
|
|
|
- name: Delete cached {{url_pkg}}
|
|
|
|
file:
|
|
|
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
|
|
|
state: absent
|
2022-03-01 06:34:27 +01:00
|
|
|
|
|
|
|
- name: Uninstall packages - mixed sources
|
|
|
|
pacman:
|
|
|
|
state: absent
|
|
|
|
name:
|
|
|
|
- '{{reg_pkg}}'
|
2022-07-27 07:41:37 +02:00
|
|
|
- '{{url_pkg_url}}'
|
2022-03-01 06:34:27 +01:00
|
|
|
- '{{file_pkg_path}}'
|
|
|
|
register: uninstall_2
|
2022-07-27 07:41:37 +02:00
|
|
|
- name: Delete cached {{url_pkg}}
|
|
|
|
file:
|
|
|
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
|
|
|
state: absent
|
2022-03-01 06:34:27 +01:00
|
|
|
|
|
|
|
- name: Uninstall packages - mixed sources (idempotency)
|
|
|
|
pacman:
|
|
|
|
state: absent
|
|
|
|
name:
|
|
|
|
- '{{reg_pkg}}'
|
2022-07-27 07:41:37 +02:00
|
|
|
- '{{url_pkg_url}}'
|
2022-03-01 06:34:27 +01:00
|
|
|
- '{{file_pkg_path}}'
|
|
|
|
register: uninstall_3
|
|
|
|
|
2022-07-27 07:41:37 +02:00
|
|
|
- name: Uninstall package - url (idempotency, cached)
|
|
|
|
pacman:
|
|
|
|
state: absent
|
|
|
|
name:
|
|
|
|
- '{{url_pkg_url}}'
|
|
|
|
register: uninstall_3c
|
|
|
|
|
2022-03-01 06:34:27 +01:00
|
|
|
- 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()
|
2022-07-27 07:41:37 +02:00
|
|
|
- install_1c is changed
|
|
|
|
- install_1c.msg == 'Would have installed 1 packages'
|
|
|
|
- install_1c.packages|sort() == [url_pkg]
|
2022-03-01 06:34:27 +01:00
|
|
|
- install_2 is changed
|
|
|
|
- install_2.msg == 'Installed 3 package(s)'
|
2022-07-27 07:41:37 +02:00
|
|
|
- install_2.packages|sort() == [reg_pkg, url_pkg, file_pkg]|sort()
|
2022-03-01 06:34:27 +01:00
|
|
|
- install_3 is not changed
|
|
|
|
- install_3.msg == 'package(s) already installed'
|
2022-07-27 07:41:37 +02:00
|
|
|
- install_3c is not changed
|
|
|
|
- install_3c.msg == 'package(s) already installed'
|
2022-03-01 06:34:27 +01:00
|
|
|
- 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
|
2022-07-27 07:41:37 +02:00
|
|
|
- uninstall_1c is changed
|
|
|
|
- uninstall_1c.msg == 'Would have removed 1 packages'
|
|
|
|
- uninstall_1c.packages | length() == 1 # pkgs have versions here
|
2022-03-01 06:34:27 +01:00
|
|
|
- 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'
|
2022-07-27 07:41:37 +02:00
|
|
|
- uninstall_3c is not changed
|
|
|
|
- uninstall_3c.msg == 'package(s) already absent'
|