diff --git a/playbook/roles/repository/tasks/main.yml b/playbook/roles/repository/tasks/main.yml
index 48a5af11081eeacb8812d4937b09de433596151b..7cf7ac497f96a615ea8356c166546167fa019927 100644
--- a/playbook/roles/repository/tasks/main.yml
+++ b/playbook/roles/repository/tasks/main.yml
@@ -6,7 +6,8 @@
   - name: Force HTTP repository for old debian versions without HTTPS support
     set_fact:
       base_open_build_url: "{{ base_open_build_url_http }}"
-    when: ansible_distribution == 'Debian' and ansible_distribution_major_version in ("8", "9", "10")
+    when: (ansible_distribution == "Debian" and ansible_distribution_major_version|int < 10) or
+          (ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int < 18)
 
   - name: Remove {{ base_open_build_url }} key (and add later) on every upgrade, as expiration date is quite short (2 months).
     apt_key: id=94A63987 state=absent