diff options
author | Adam Miller <admiller@redhat.com> | 2018-08-27 12:17:47 -0500 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2018-08-27 10:17:47 -0700 |
commit | 397febd343396d427f8bc7eef174174805c924ed (patch) | |
tree | 3e0bc0a8d4a9c851d8610803cc9461105fc9bf55 /test/integration/targets/yum | |
parent | 9ff20521d1ada2acc64b623875b1d8e51809e0f9 (diff) | |
download | ansible-397febd343396d427f8bc7eef174174805c924ed.tar.gz |
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.
Diffstat (limited to 'test/integration/targets/yum')
-rw-r--r-- | test/integration/targets/yum/tasks/main.yml | 11 | ||||
-rw-r--r-- | test/integration/targets/yum/tasks/repo.yml | 150 | ||||
-rw-r--r-- | test/integration/targets/yum/tasks/yum.yml | 223 | ||||
-rw-r--r-- | test/integration/targets/yum/tasks/yum_group_remove.yml | 10 |
4 files changed, 240 insertions, 154 deletions
diff --git a/test/integration/targets/yum/tasks/main.yml b/test/integration/targets/yum/tasks/main.yml index 4c0376ebc1..876147e8f9 100644 --- a/test/integration/targets/yum/tasks/main.yml +++ b/test/integration/targets/yum/tasks/main.yml @@ -46,8 +46,8 @@ - ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and ansible_distribution_major_version|int <= 6 when: - ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora'] - - ansible_python.version.major == 2 +# DNF1 doesn't handle downgrade operations properly (Fedora < 26) - block: - include: 'repo.yml' always: @@ -58,16 +58,10 @@ - command: yum clean metadata when: - ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora'] - - ansible_python.version.major == 2 -# We can't run yum --installroot tests on dnf systems. Dnf systems revert to -# yum-deprecated, and yum-deprecated refuses to run if yum.conf exists -# so we cannot configure yum-deprecated correctly in an empty /tmp/fake.root/ -# It will always run with $releasever unset - include: 'yuminstallroot.yml' when: - - (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] or (ansible_distribution in ['Fedora'] and ansible_distribution_major_version|int < 23)) - - ansible_python.version.major == 2 + - ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora'] # el6 has a broken yum group implementation, when you try to remove a group it goes through # deps and ends up with trying to remove yum itself and the whole process fails @@ -75,4 +69,3 @@ - include: 'yum_group_remove.yml' when: - (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and ansible_distribution_major_version|int > 6) or ansible_distribution in ['Fedora'] - - ansible_python.version.major == 2 diff --git a/test/integration/targets/yum/tasks/repo.yml b/test/integration/targets/yum/tasks/repo.yml index 76bc96891b..33fdd3b43f 100644 --- a/test/integration/targets/yum/tasks/repo.yml +++ b/test/integration/targets/yum/tasks/repo.yml @@ -73,10 +73,11 @@ name: foo state: absent # ============================================================================ - - name: Install 1:foo-1.0-2 + - name: Downgrade foo yum: - name: "1:foo-1.0-2.{{ ansible_architecture }}" + name: foo-1.0-1 state: present + allow_downgrade: yes register: yum_result - name: Check foo with rpm @@ -87,30 +88,7 @@ assert: that: - "yum_result.changed" - - "rpm_result.stdout.startswith('foo-1.0-2')" - - - name: Verify yum module outputs - assert: - that: - - "'msg' in yum_result" - - "'rc' in yum_result" - - "'results' in yum_result" - # ============================================================================ - - name: Install foo-1.0-2 again - yum: - name: foo-1.0-2 - state: present - register: yum_result - - - name: Check foo with rpm - shell: rpm -q foo - register: rpm_result - - - name: Verify installation - assert: - that: - - "not yum_result.changed" - - "rpm_result.stdout.startswith('foo-1.0-2')" + - "rpm_result.stdout.startswith('foo-1.0-1')" - name: Verify yum module outputs assert: @@ -286,30 +264,6 @@ - "'rc' in yum_result" - "'results' in yum_result" # ============================================================================ - - name: Downgrade foo - yum: - name: foo-1.0-1 - state: present - allow_downgrade: yes - register: yum_result - - - name: Check foo with rpm - shell: rpm -q foo - register: rpm_result - - - name: Verify installation - assert: - that: - - "yum_result.changed" - - "rpm_result.stdout.startswith('foo-1.0-1')" - - - name: Verify yum module outputs - assert: - that: - - "'msg' in yum_result" - - "'rc' in yum_result" - - "'results' in yum_result" - # ============================================================================ - name: Update foo with update_only set yum: name: foo @@ -506,3 +460,99 @@ yum: name: foo state: absent + +# FIXME: dnf currently doesn't support epoch as part of it's pkg_spec for +# finding install candidates +# https://bugzilla.redhat.com/show_bug.cgi?id=1619687 +- block: + - name: Install 1:foo-1.0-2 + yum: + name: "1:foo-1.0-2.{{ ansible_architecture }}" + state: present + register: yum_result + + - name: Check foo with rpm + shell: rpm -q foo + register: rpm_result + + - name: Verify installation + assert: + that: + - "yum_result.changed" + - "rpm_result.stdout.startswith('foo-1.0-2')" + + - name: Verify yum module outputs + assert: + that: + - "'msg' in yum_result" + - "'rc' in yum_result" + - "'results' in yum_result" + always: + - name: Clean up + yum: + name: foo + state: absent + + when: ansible_pkg_mgr == 'yum' + +# DNF1 (Fedora < 26) had some issues: +# - did not accept architecture tag as valid component of a package spec unless +# installing a file (i.e. can't search the repo) +# - doesn't handle downgrade transactions via the API properly, marks it as a +# conflict +# +# NOTE: Both DNF1 and Fedora < 26 have long been EOL'd by their respective +# upstreams +- block: + # ============================================================================ + - name: Install foo-1.0-2 + yum: + name: "foo-1.0-2.{{ ansible_architecture }}" + state: present + register: yum_result + + - name: Check foo with rpm + shell: rpm -q foo + register: rpm_result + + - name: Verify installation + assert: + that: + - "yum_result.changed" + - "rpm_result.stdout.startswith('foo-1.0-2')" + + - name: Verify yum module outputs + assert: + that: + - "'msg' in yum_result" + - "'rc' in yum_result" + - "'results' in yum_result" + + - name: Install foo-1.0-2 again + yum: + name: foo-1.0-2 + state: present + register: yum_result + + - name: Check foo with rpm + shell: rpm -q foo + register: rpm_result + + - name: Verify installation + assert: + that: + - "not yum_result.changed" + - "rpm_result.stdout.startswith('foo-1.0-2')" + + - name: Verify yum module outputs + assert: + that: + - "'msg' in yum_result" + - "'rc' in yum_result" + - "'results' in yum_result" + always: + - name: Clean up + yum: + name: foo + state: absent + when: not (ansible_distribution == "Fedora" and ansible_distribution_major_version|int < 26) diff --git a/test/integration/targets/yum/tasks/yum.yml b/test/integration/targets/yum/tasks/yum.yml index 5da8011ebc..1a5d7333bf 100644 --- a/test/integration/targets/yum/tasks/yum.yml +++ b/test/integration/targets/yum/tasks/yum.yml @@ -477,6 +477,11 @@ - set_fact: pkg_url: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/yum/fpaste-0.3.7.4.1-2.el7.noarch.rpm + when: ansible_python.version.major == 2 + +- set_fact: + pkg_url: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/yum/fpaste-0.3.9.2-1.fc28.noarch.rpm + when: ansible_python.version.major == 3 # setup end - name: download an rpm @@ -566,7 +571,6 @@ that: - "'changed' in no_nevra_info_result" - "'msg' in no_nevra_info_result" - - "'Failed to get nevra information from RPM package' in no_nevra_info_result.msg" - name: Delete a temp RPM file file: @@ -583,102 +587,131 @@ yum_version: "{%- if item.yumstate == 'installed' -%}{{ item.version }}{%- else -%}{{ yum_version }}{%- endif -%}" with_items: "{{ yum_version.results }}" -- name: check whether yum supports disableexcludes (>= 3.4) - set_fact: - supports_disable_excludes: "{{ yum_version is version_compare('3.4.0', '>=') }}" +- block: + - name: check whether yum supports disableexcludes (>= 3.4) + set_fact: + supports_disable_excludes: "{{ yum_version is version_compare('3.4.0', '>=') }}" + when: ansible_pkg_mgr == "yum" -- name: uninstall zip - yum: name=zip state=removed - -- name: check zip with rpm - shell: rpm -q zip - ignore_errors: True - register: rpm_zip_result + - name: unset disableexcludes tests for dnf(yum4) backend temporarily + set_fact: + supports_disable_excludes: True + when: ansible_pkg_mgr == "dnf" -- name: verify zip is uninstalled - assert: - that: - - "rpm_zip_result is failed" - -- name: exclude zip - lineinfile: - dest: /etc/yum.conf - regexp: (^exclude=)(.)* - line: "exclude=zip*" - state: present + - name: uninstall bc + yum: name=bc state=removed -# begin test case where disable_excludes is supported -- name: Try install zip without disable_excludes - yum: name=zip state=latest - register: yum_zip_result - ignore_errors: True - when: supports_disable_excludes - -- name: verify zip did not install because it is in exclude list - assert: - that: - - "yum_zip_result is failed" - when: supports_disable_excludes - -- name: install zip with disable_excludes - yum: name=zip state=latest disable_excludes=all - register: yum_zip_result_using_excludes - when: supports_disable_excludes - -- name: verify zip did install using disable_excludes=all - assert: - that: - - "yum_zip_result_using_excludes is success" - - "yum_zip_result_using_excludes is changed" - - "yum_zip_result_using_excludes is not failed" - when: supports_disable_excludes + - name: check bc with rpm + shell: rpm -q bc + ignore_errors: True + register: rpm_bc_result -- name: remove exclude zip (cleanup yum.conf) - lineinfile: - dest: /etc/yum.conf - regexp: (^exclude=zip*) - line: "exclude=" - state: present - when: supports_disable_excludes -# end test case where disable_excludes is supported - -# begin test case where disable_excludes is not supported -- name: Try install zip with disable_excludes - yum: name=zip state=latest disable_excludes=all - register: yum_fail_zip_result_old_yum - ignore_errors: True - when: not supports_disable_excludes - -- name: verify packages did not install because yum version is unsupported - assert: - that: - - "yum_fail_zip_result_old_yum is failed" - when: not supports_disable_excludes - -- name: verify yum module outputs - assert: - that: - - "'is available in yum version 3.4 and onwards.' in yum_fail_zip_result_old_yum.msg" - when: not supports_disable_excludes - -- name: remove exclude zip (cleanup yum.conf) - lineinfile: - dest: /etc/yum.conf - regexp: (^exclude=zip*) - line: "exclude=" - state: present - when: not supports_disable_excludes - -- name: install zip (bring test env in same state as when testing started) - yum: name=zip state=latest - register: yum_zip_result_old_yum - when: not supports_disable_excludes + - name: verify bc is uninstalled + assert: + that: + - "rpm_bc_result is failed" -- name: verify zip installed - assert: - that: - - "yum_zip_result_old_yum is success" - - "yum_zip_result_old_yum is changed" - - "yum_zip_result_old_yum is not failed" - when: not supports_disable_excludes -# end test case where disable_excludes is not supported
\ No newline at end of file + - name: exclude bc (yum backend) + lineinfile: + dest: /etc/yum.conf + regexp: (^exclude=)(.)* + line: "exclude=bc*" + state: present + when: ansible_pkg_mgr == 'yum' + + - name: exclude bc (dnf backend) + lineinfile: + dest: /etc/dnf/dnf.conf + regexp: (^excludepkgs=)(.)* + line: "excludepkgs=bc*" + state: present + when: ansible_pkg_mgr == 'dnf' + + # begin test case where disable_excludes is supported + - name: Try install bc without disable_excludes + yum: name=bc state=latest + register: yum_bc_result + ignore_errors: True + when: supports_disable_excludes + + - name: verify bc did not install because it is in exclude list + assert: + that: + - "yum_bc_result is failed" + when: supports_disable_excludes + + - name: install bc with disable_excludes + yum: name=bc state=latest disable_excludes=all + register: yum_bc_result_using_excludes + when: supports_disable_excludes + + - name: verify bc did install using disable_excludes=all + assert: + that: + - "yum_bc_result_using_excludes is success" + - "yum_bc_result_using_excludes is changed" + - "yum_bc_result_using_excludes is not failed" + when: supports_disable_excludes + + - name: remove exclude bc (cleanup yum.conf) + lineinfile: + dest: /etc/yum.conf + regexp: (^exclude=bc*) + line: "exclude=" + state: present + when: supports_disable_excludes and (ansible_pkg_mgr == 'yum') + + - name: remove exclude bc (cleanup dnf.conf) + lineinfile: + dest: /etc/dnf/dnf.conf + regexp: (^excludepkgs=bc*) + line: "excludepkgs=" + state: present + when: ansible_pkg_mgr == 'dnf' + # end test case where disable_excludes is supported + + # begin test case where disable_excludes is not supported + - name: Try install bc with disable_excludes + yum: name=bc state=latest disable_excludes=all + register: yum_fail_bc_result_old_yum + ignore_errors: True + when: not supports_disable_excludes + + - name: verify packages did not install because yum version is unsupported + assert: + that: + - "yum_fail_bc_result_old_yum is failed" + when: not supports_disable_excludes + + - name: verify yum module outputs + assert: + that: + - "'is available in yum version 3.4 and onwards.' in yum_fail_bc_result_old_yum.msg" + when: not supports_disable_excludes + + - name: remove exclude bc (cleanup yum.conf) + lineinfile: + dest: /etc/yum.conf + regexp: (^exclude=bc*) + line: "exclude=" + state: present + when: not supports_disable_excludes and ansible_pkg_mgr == 'yum' + + - name: install bc (bring test env in same state as when testing started) + yum: name=bc state=latest + register: yum_bc_result_old_yum + when: not supports_disable_excludes + + - name: verify bc installed + assert: + that: + - "yum_bc_result_old_yum is success" + - "yum_bc_result_old_yum is changed" + - "yum_bc_result_old_yum is not failed" + when: not supports_disable_excludes and ansible_pkg_mgr == "yum" + # end test case where disable_excludes is not supported + + # Fedora < 26 has a bug in dnf where package excludes in dnf.conf aren't + # actually honored and those releases are EOL'd so we have no expectation they + # will ever be fixed + when: not ((ansible_distribution == "Fedora") and (ansible_distribution_major_version|int < 26))
\ No newline at end of file diff --git a/test/integration/targets/yum/tasks/yum_group_remove.yml b/test/integration/targets/yum/tasks/yum_group_remove.yml index 96a7dc5266..8a9e5f6523 100644 --- a/test/integration/targets/yum/tasks/yum_group_remove.yml +++ b/test/integration/targets/yum/tasks/yum_group_remove.yml @@ -5,6 +5,16 @@ with_items: - "@Development Tools" - yum-utils + when: ansible_pkg_mgr == "yum" + +- name: install a group to test and dnf-utils + yum: + name: "{{ item }}" + state: present + with_items: + - "@Development Tools" + - dnf-utils + when: ansible_pkg_mgr == "dnf" - name: check mode remove the group yum: |