[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 16d6fcf514)

Co-authored-by: Sam Doran <sdoran@redhat.com>
This commit is contained in:
Sam Doran 2019-07-03 11:11:20 -04:00 committed by Toshio Kuratomi
parent 4e63b681f2
commit 9b1575cfeb
5 changed files with 25 additions and 31 deletions

View file

@ -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.

View file

@ -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'
- 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_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_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', '>='))
# 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', '>=')
- include: 'repo.yml'
when:
- ansible_distribution == 'Fedora'
- ansible_distribution_major_version|int >= 23
- include: 'dnfinstallroot.yml'
when:
- ansible_distribution == 'Fedora'
- ansible_distribution_major_version|int >= 23
- include: 'dnfreleasever.yml'
when:
- ansible_distribution == 'Fedora'
- ansible_distribution_major_version|int >= 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', '>='))

View file

@ -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

View file

@ -0,0 +1 @@
astream_name: '@ripgrep:master/default'

View file

@ -0,0 +1 @@
astream_name: '@php:7.1/minimal'