From 9b1575cfeb439ee4c353335409e6b82386001493 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Wed, 3 Jul 2019 11:11:20 -0400 Subject: [PATCH] [stable-2.7] Improve dnf test formatting and fix RHEL 8 module name (#58648) - use single include_vars task rather than multiple set_fact tasks - use multi-line YAML to break up long conditionals - use version() test rather than direct comparisions - use different appstream package on RHEL since '@swig:3.0/default' is not working in the GA. (cherry picked from commit 16d6fcf5148e2a527f5c6e2603490a2e79500a91) Co-authored-by: Sam Doran --- test/integration/targets/dnf/tasks/dnf.yml | 2 ++ test/integration/targets/dnf/tasks/main.yml | 33 +++++++++---------- .../targets/dnf/tasks/modularity.yml | 13 ++------ test/integration/targets/dnf/vars/Fedora.yml | 1 + test/integration/targets/dnf/vars/RedHat.yml | 1 + 5 files changed, 22 insertions(+), 28 deletions(-) create mode 100644 test/integration/targets/dnf/vars/Fedora.yml create mode 100644 test/integration/targets/dnf/vars/RedHat.yml diff --git a/test/integration/targets/dnf/tasks/dnf.yml b/test/integration/targets/dnf/tasks/dnf.yml index 990e0f1106c..9c7c2efe5e8 100644 --- a/test/integration/targets/dnf/tasks/dnf.yml +++ b/test/integration/targets/dnf/tasks/dnf.yml @@ -6,6 +6,8 @@ shell: rpm -q python2-dnf register: rpm_result ignore_errors: true + args: + warn: no # Don't uninstall python2-dnf with the `dnf` module in case it needs to load # some dnf python files after the package is uninstalled. diff --git a/test/integration/targets/dnf/tasks/main.yml b/test/integration/targets/dnf/tasks/main.yml index aba860fe5a1..1135509f94d 100644 --- a/test/integration/targets/dnf/tasks/main.yml +++ b/test/integration/targets/dnf/tasks/main.yml @@ -19,27 +19,24 @@ # Note: We install the yum package onto Fedora so that this will work on dnf systems # We want to test that for people who don't want to upgrade their systems. -- include: 'dnf.yml' - when: - - ansible_distribution == 'Fedora' - - ansible_distribution_major_version|int >= 23 +- include_tasks: dnf.yml + when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or + (ansible_distribution == 'RedHat' and ansible_distribution_major_version is version('8', '>=')) -- include: 'repo.yml' - when: - - ansible_distribution == 'Fedora' - - ansible_distribution_major_version|int >= 23 +- include_tasks: repo.yml + when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or + (ansible_distribution == 'RedHat' and ansible_distribution_major_version is version('8', '>=')) -- include: 'dnfinstallroot.yml' - when: - - ansible_distribution == 'Fedora' - - ansible_distribution_major_version|int >= 23 +- include_tasks: dnfinstallroot.yml + when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or + (ansible_distribution == 'RedHat' and ansible_distribution_major_version is version('8', '>=')) -- include: 'dnfreleasever.yml' +# Attempting to install a different RHEL release in a tmpdir doesn't work (rhel8 beta) +- include_tasks: dnfreleasever.yml when: - ansible_distribution == 'Fedora' - - ansible_distribution_major_version|int >= 23 + - ansible_distribution_major_version is version('23', '>=') -- import_tasks: 'modularity.yml' - when: - - ansible_distribution == 'Fedora' and ansible_distribution_major_version|int >= 29 - - ansible_distribution == 'RedHat' and ansible_distribution_major_version|int >= 8 +- include_tasks: modularity.yml + when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('29', '>=')) or + (ansible_distribution == 'RedHat' and ansible_distribution_major_version is version('8', '>=')) diff --git a/test/integration/targets/dnf/tasks/modularity.yml b/test/integration/targets/dnf/tasks/modularity.yml index beaa0b9e5e9..0c5520d2411 100644 --- a/test/integration/targets/dnf/tasks/modularity.yml +++ b/test/integration/targets/dnf/tasks/modularity.yml @@ -1,13 +1,6 @@ # FUTURE - look at including AppStream support in our local repo -- name: set package for RHEL - set_fact: - astream_name: '@swig:3.0/default' - when: ansible_distribution == 'RedHat' - -- name: set package for Fedora - set_fact: - astream_name: '@ripgrep:master/default' - when: ansible_distribution == 'Fedora' +- name: Include distribution specific variables + include_vars: "{{ ansible_facts.distribution }}.yml" - name: install "@postgresql:9.6/client" module dnf: @@ -48,7 +41,7 @@ - name: uninstall "@postgresql:9.6/client" module again dnf: name: "@postgresql:9.6/client" - state: install + state: absent register: dnf_result - name: verify uninstallation of "@postgresql:9.6/client" module again diff --git a/test/integration/targets/dnf/vars/Fedora.yml b/test/integration/targets/dnf/vars/Fedora.yml new file mode 100644 index 00000000000..25a04e74563 --- /dev/null +++ b/test/integration/targets/dnf/vars/Fedora.yml @@ -0,0 +1 @@ +astream_name: '@ripgrep:master/default' diff --git a/test/integration/targets/dnf/vars/RedHat.yml b/test/integration/targets/dnf/vars/RedHat.yml new file mode 100644 index 00000000000..3285e76151b --- /dev/null +++ b/test/integration/targets/dnf/vars/RedHat.yml @@ -0,0 +1 @@ +astream_name: '@php:7.1/minimal'