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
Adam Miller 397febd343 YUM4/DNF compatibility via yum action plugin (#44322)
* YUM4/DNF compatibility via yum action plugin

DNF does not natively support allow_downgrade as an option, instead
that is always the default (not configurable by the administrator)
so it had to be implemented

 - Fixed group actions in check mode to report correct changed state
 - Better error handling for depsolve and transaction errors in DNF
 - Fixed group action idempotent transactions
 - Add use_backend to yum module/action plugin
 - Fix dnf handling of autoremove (didn't used to work nor had a
   default value specified, now does work and matches default
   behavior of yum)
 - Enable installroot tests for yum4(dnf) integration testing, dnf
   backend now supports that
 - Switch from zip to bc for certain package install/remove test
   cases in yum integration tests. The dnf depsolver downgrades
   python when you uninstall zip which alters the test environment
   and we have no control over that.
 - Add changelog fragment
 - Return a pkg_mgr fact if it was not previously set.
2018-08-27 10:17:47 -07:00

215 lines
5.7 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"
# ============================================================================
always:
- name: Clean up
dnf:
name: foo
state: absent