1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/dnf/tasks/repo.yml
Martin Krizek 826b99d4bd dnf: fix wildcard matching for state: absent (#56013)
* dnf: fix wildcard matching for state: absent

Fixes #55938

* Add changelog...

* Fix sanity check failure...
2019-05-14 17:34:10 -04:00

286 lines
7.5 KiB
YAML

- block:
- name: Install foo-1.0-1
dnf:
name: foo-1.0-1
state: present
register: dnf_result
- name: Check foo with rpm
shell: rpm -q foo
register: rpm_result
- name: Verify installation
assert:
that:
- "dnf_result.changed"
- "rpm_result.stdout.startswith('foo-1.0-1')"
- name: Verify dnf module outputs
assert:
that:
- "'results' in dnf_result"
# ============================================================================
- name: Install foo-1.0-1 again
dnf:
name: foo-1.0-1
state: present
register: dnf_result
- name: Check foo with rpm
shell: rpm -q foo
register: rpm_result
- name: Verify installation
assert:
that:
- "not dnf_result.changed"
- "rpm_result.stdout.startswith('foo-1.0-1')"
- name: Verify dnf module outputs
assert:
that:
- "'msg' in dnf_result"
# ============================================================================
- name: Install foo-1:1.0-2
dnf:
name: "foo-1:1.0-2.{{ ansible_architecture }}"
state: present
register: dnf_result
- name: Check foo with rpm
shell: rpm -q foo
register: rpm_result
- name: Verify installation
assert:
that:
- "dnf_result.changed"
- "rpm_result.stdout.startswith('foo-1.0-2')"
- name: Verify dnf module outputs
assert:
that:
- "'results' in dnf_result"
# ============================================================================
- name: Update to the latest foo
dnf:
name: foo
state: latest
register: dnf_result
- name: Check foo with rpm
shell: rpm -q foo
register: rpm_result
- name: Verify installation
assert:
that:
- "dnf_result.changed"
- "rpm_result.stdout.startswith('foo-1.1-1')"
- name: Verify dnf module outputs
assert:
that:
- "'results' in dnf_result"
# ============================================================================
- name: Install foo-1.0-1 from a file (downgrade)
dnf:
name: "{{ repodir }}/foo-1.0-1.{{ ansible_architecture }}.rpm"
state: present
allow_downgrade: True
register: dnf_result
- name: Check foo with rpm
shell: rpm -q foo
register: rpm_result
- name: Verify installation
assert:
that:
- "dnf_result.changed"
- "rpm_result.stdout.startswith('foo-1.0-1')"
- name: Verify dnf module outputs
assert:
that:
- "'results' in dnf_result"
- name: Remove foo
dnf:
name: foo
state: absent
# ============================================================================
- name: Install foo-1.0-1 from a file
dnf:
name: "{{ repodir }}/foo-1.0-1.{{ ansible_architecture }}.rpm"
state: present
register: dnf_result
- name: Check foo with rpm
shell: rpm -q foo
register: rpm_result
- name: Verify installation
assert:
that:
- "dnf_result.changed"
- "rpm_result.stdout.startswith('foo-1.0-1')"
- name: Verify dnf module outputs
assert:
that:
- "'results' in dnf_result"
# ============================================================================
- name: Install foo-1.0-1 from a file again
dnf:
name: "{{ repodir }}/foo-1.0-1.{{ ansible_architecture }}.rpm"
state: present
register: dnf_result
- name: Check foo with rpm
shell: rpm -q foo
register: rpm_result
- name: Verify installation
assert:
that:
- "not dnf_result.changed"
- "rpm_result.stdout.startswith('foo-1.0-1')"
# ============================================================================
- name: Install foo-1.0-2 from a file
dnf:
name: "{{ repodir }}/foo-1.0-2.{{ ansible_architecture }}.rpm"
state: present
register: dnf_result
- name: Check foo with rpm
shell: rpm -q foo
register: rpm_result
- name: Verify installation
assert:
that:
- "dnf_result.changed"
- "rpm_result.stdout.startswith('foo-1.0-2')"
- name: Verify dnf module outputs
assert:
that:
- "'results' in dnf_result"
# ============================================================================
- name: Install foo-1.0-2 from a file again
dnf:
name: "{{ repodir }}/foo-1.0-2.{{ ansible_architecture }}.rpm"
state: present
register: dnf_result
- name: Check foo with rpm
shell: rpm -q foo
register: rpm_result
- name: Verify installation
assert:
that:
- "not dnf_result.changed"
- "rpm_result.stdout.startswith('foo-1.0-2')"
# ============================================================================
- name: Remove foo
dnf:
name: foo
state: absent
- name: Try to install incompatible arch
dnf:
name: "{{ repodir_ppc64 }}/foo-1.0-1.ppc64.rpm"
state: present
register: dnf_result
ignore_errors: yes
- name: Check foo with rpm
shell: rpm -q foo
register: rpm_result
ignore_errors: yes
- name: Verify installation
assert:
that:
- "rpm_result.rc == 1"
- "not dnf_result.changed"
- "dnf_result is failed"
# ============================================================================
# Should install foo-with-weak-dep and foo-weak-dep
- name: Install package with defaults
dnf:
name: foo-with-weak-dep
state: present
- name: Check if foo-with-weak-dep is installed
shell: rpm -q foo-with-weak-dep
register: rpm_main_result
- name: Check if foo-weak-dep is installed
shell: rpm -q foo-weak-dep
register: rpm_weak_result
- name: Verify install with weak deps
assert:
that:
- rpm_main_result.rc == 0
- rpm_weak_result.rc == 0
- name: Uninstall foo weak dep packages
dnf:
name:
- foo-with-weak-dep
- foo-weak-dep
state: absent
- name: Install package with weak deps but skip weak deps
dnf:
name: foo-with-weak-dep
install_weak_deps: False
state: present
- name: Check if foo-with-weak-dep is installed
shell: rpm -q foo-with-weak-dep
register: rpm_main_result
- name: Check if foo-weak-dep is installed
shell: rpm -q foo-weak-dep
register: rpm_weak_result
ignore_errors: yes
- name: Verify install without weak deps
assert:
that:
- rpm_main_result.rc == 0
- rpm_weak_result.rc == 1 # the weak dependency shouldn't be installed
# https://github.com/ansible/ansible/issues/55938
- name: Install foo-*
dnf:
name: foo-*
state: present
- name: Uninstall foo-*
dnf:
name: foo-*
state: absent
- name: Check if all foo packages are removed
shell: rpm -qa foo-* | wc -l
register: rpm_result
- name: Verify rpm result
assert:
that:
- rpm_result.stdout == '0'
always:
- name: Clean up
dnf:
name:
- foo
- foo-with-weak-dep
- foo-weak-dep
state: absent