From b62c488eab26af77a543d9a84bfcd168a425a532 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Tue, 17 Dec 2019 10:46:13 -0800 Subject: [PATCH] Fix ansible use of filters and tests Ansible 2.9 requires the use of "version" as a filter and "version_compare" has been removed. Also tests cannot be used as filters which means we cannot do when: foo | test and must do when: foo is test instead. Make these fixes. Both changes should be backward compatible to ansible 2.5: https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#version-comparison https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.5.html#jinja-tests-used-as-filters Change-Id: Id95f674a485877db2a7924994366d1c6c591a684 --- roles/configure-mirrors/tasks/mirror/Suse.yaml | 6 +++--- .../templates/fedora/etc/yum.repos.d/fedora-updates.repo.j2 | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/roles/configure-mirrors/tasks/mirror/Suse.yaml b/roles/configure-mirrors/tasks/mirror/Suse.yaml index 8b0fa06db..549ef445f 100644 --- a/roles/configure-mirrors/tasks/mirror/Suse.yaml +++ b/roles/configure-mirrors/tasks/mirror/Suse.yaml @@ -1,12 +1,12 @@ - name: set zypper base package repository (openSUSE Leap) set_fact: opensuse_repo_baseurl: "{{ package_mirror }}/distribution/leap/$releasever/repo/oss/" - when: not ansible_distribution | search("Tumbleweed") + when: ansible_distribution is not search("Tumbleweed") - name: set zypper base package repository (openSUSE Tumbleweed) set_fact: opensuse_repo_baseurl: "{{ package_mirror }}/tumbleweed/repo/oss/" - when: ansible_distribution | search("Tumbleweed") + when: ansible_distribution is search("Tumbleweed") - name: Install Suse repository files become: yes @@ -31,4 +31,4 @@ src: suse/etc/zypp/repos.d/repo-update.repo.j2 notify: - Update zypper cache - when: not ansible_distribution | search("Tumbleweed") + when: ansible_distribution is not search("Tumbleweed") diff --git a/roles/configure-mirrors/templates/fedora/etc/yum.repos.d/fedora-updates.repo.j2 b/roles/configure-mirrors/templates/fedora/etc/yum.repos.d/fedora-updates.repo.j2 index b1b6f7938..64669fa63 100644 --- a/roles/configure-mirrors/templates/fedora/etc/yum.repos.d/fedora-updates.repo.j2 +++ b/roles/configure-mirrors/templates/fedora/etc/yum.repos.d/fedora-updates.repo.j2 @@ -2,7 +2,7 @@ [updates] name=Fedora $releasever - $basearch - Updates failovermethod=priority -{% if ansible_distribution_version | version_compare('28', '<') %} +{% if ansible_distribution_version is version('28', '<') %} baseurl={{ package_mirror }}/updates/$releasever/$basearch/ {% else %} baseurl={{ package_mirror }}/updates/$releasever/Everything/$basearch/ @@ -18,7 +18,7 @@ skip_if_unavailable=False [updates-debuginfo] name=Fedora $releasever - $basearch - Updates - Debug failovermethod=priority -{% if ansible_distribution_version | version_compare('28', '<') %} +{% if ansible_distribution_version is version('28', '<') %} baseurl={{ package_mirror }}/updates/$releasever/$basearch/debug/ {% else %} baseurl={{ package_mirror }}/updates/$releasever/Everything/$basearch/debug/tree/ @@ -34,7 +34,7 @@ skip_if_unavailable=False [updates-source] name=Fedora $releasever - Updates Source failovermethod=priority -{% if ansible_distribution_version | version_compare('28', '<') %} +{% if ansible_distribution_version is version('28', '<') %} baseurl={{ package_mirror }}/updates/$releasever/SRPMS/ {% else %} baseurl={{ package_mirror }}/updates/$releasever/Everything/source/tree/