Browse code

[stable-2.6] 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
(cherry picked from commit 16d6fcf5148e2a527f5c6e2603490a2e79500a91)

Sam Doran authored on 2019/07/04 00:11:20
Showing 2 changed files
... ...
@@ -6,6 +6,8 @@
6 6
   shell: rpm -q python2-dnf
7 7
   register: rpm_result
8 8
   ignore_errors: true
9
+  args:
10
+    warn: no
9 11
 
10 12
 # Don't uninstall python2-dnf with the `dnf` module in case it needs to load
11 13
 # some dnf python files after the package is uninstalled.
... ...
@@ -19,22 +19,20 @@
19 19
 # Note: We install the yum package onto Fedora so that this will work on dnf systems
20 20
 # We want to test that for people who don't want to upgrade their systems.
21 21
 
22
-- include: 'dnf.yml'
23
-  when:
24
-    - ansible_distribution == 'Fedora'
25
-    - ansible_distribution_major_version|int >= 23
22
+- include_tasks: dnf.yml
23
+  when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
24
+        (ansible_distribution == 'RedHat' and ansible_distribution_major_version is version('8', '>='))
26 25
 
27
-- include: 'repo.yml'
28
-  when:
29
-    - ansible_distribution == 'Fedora'
30
-    - ansible_distribution_major_version|int >= 23
26
+- include_tasks: repo.yml
27
+  when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
28
+        (ansible_distribution == 'RedHat' and ansible_distribution_major_version is version('8', '>='))
31 29
 
32
-- include: 'dnfinstallroot.yml'
33
-  when:
34
-    - ansible_distribution == 'Fedora'
35
-    - ansible_distribution_major_version|int >= 23
30
+- include_tasks: dnfinstallroot.yml
31
+  when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
32
+        (ansible_distribution == 'RedHat' and ansible_distribution_major_version is version('8', '>='))
36 33
 
37
-- include: 'dnfreleasever.yml'
34
+# Attempting to install a different RHEL release in a tmpdir doesn't work (rhel8 beta)
35
+- include_tasks: dnfreleasever.yml
38 36
   when:
39 37
     - ansible_distribution == 'Fedora'
40
-    - ansible_distribution_major_version|int >= 23
38
+    - ansible_distribution_major_version is version('23', '>=')