diff --git a/tests/run.yml b/tests/run.yml
index b4ba43ee39466fb60a1c3d174824d1f894daed24..0435059e66eb63cb8e1cef6a6e827b52dfd5dedf 100644
--- a/tests/run.yml
+++ b/tests/run.yml
@@ -202,8 +202,11 @@
 
     - name: install kolla-ansible and dependencies
       vars:
+        ansible_version_min: "==2.10.*"
+        ansible_version_max: "==4.*"
         # Test latest ansible version on Ubuntu, minimum supported on others.
-        ansible_version_constraint: "{{ '==2.10.*' if is_upgrade else '==4.*' }}"
+        ansible_version_constraint: >-
+          {{ ansible_version_min if is_upgrade or base_distro != 'ubuntu' else ansible_version_max }}
       command: >-
         python3 -m pip install --user
         -c {{ upper_constraints_file }}