From a89cd5a30f3bb9135bdf60b8242a3fb6ac2ab2e8 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Fri, 2 Nov 2018 02:20:29 +1000 Subject: [PATCH] dnf yum: fix tests running on Fedora 29 (#47910) * dnf yum: fix tests running on Fedora 29 * wrap in always block (cherry picked from commit f0535bac8087e659e599ffd72ac9853ea3823bd4) --- test/integration/targets/dnf/tasks/dnf.yml | 26 +++++++++++++--- .../targets/dnf/tasks/dnfreleasever.yml | 4 +-- test/integration/targets/yum/files/yum.conf | 5 +++ test/integration/targets/yum/tasks/yum.yml | 31 ++++++++++++++----- 4 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 test/integration/targets/yum/files/yum.conf diff --git a/test/integration/targets/dnf/tasks/dnf.yml b/test/integration/targets/dnf/tasks/dnf.yml index 0a373ca3b0a..7b9306af277 100644 --- a/test/integration/targets/dnf/tasks/dnf.yml +++ b/test/integration/targets/dnf/tasks/dnf.yml @@ -430,11 +430,27 @@ # ENVIRONMENT UPGRADE # see commit de299ef77c03a64a8f515033a79ac6b7db1bc710 -- name: install Web Server environment - dnf: - name: "@Web Server" - state: latest - register: dnf_result + +# Newer Fedora Docker images come with coreutils-single which is incompatible +# with coreutils (required by @Web Server). We force the install of coreutils +# before running the environment group install. +# https://github.com/fedora-cloud/docker-brew-fedora/issues/58 +- name: ensure coreutils is installed over coreutils-single + command: dnf install --allowerasing -y coreutils + changed_when: '"Nothing to do" not in coreutils_install.stdout' + register: coreutils_install + +- block: + - name: install Web Server environment + dnf: + name: "@Web Server" + state: latest + register: dnf_result + + always: + - name: reinstall coreutils-single if coreutils was installed + command: dnf install --allowerasing -y coreutils-single + when: coreutils_install is changed - name: verify installation of the environment assert: diff --git a/test/integration/targets/dnf/tasks/dnfreleasever.yml b/test/integration/targets/dnf/tasks/dnfreleasever.yml index ea4d9c5b5ac..d68c6c586b7 100644 --- a/test/integration/targets/dnf/tasks/dnfreleasever.yml +++ b/test/integration/targets/dnf/tasks/dnfreleasever.yml @@ -19,7 +19,7 @@ dnf: name: filesystem installroot: '/{{dnfroot.stdout}}' - releasever: 22 + releasever: '{{ansible_distribution_version|int - 1}}' register: dnf_result - name: check filesystem version @@ -40,7 +40,7 @@ - name: verify the version assert: that: - - "rpm_result.stdout.find('fc22') != -1" + - "rpm_result.stdout.find('fc' ~ (ansible_distribution_version|int - 1)) != -1" - name: cleanup installroot file: diff --git a/test/integration/targets/yum/files/yum.conf b/test/integration/targets/yum/files/yum.conf new file mode 100644 index 00000000000..5a5fca608df --- /dev/null +++ b/test/integration/targets/yum/files/yum.conf @@ -0,0 +1,5 @@ +[main] +gpgcheck=1 +installonly_limit=3 +clean_requirements_on_remove=True +tsflags=nodocs diff --git a/test/integration/targets/yum/tasks/yum.yml b/test/integration/targets/yum/tasks/yum.yml index 6dc29cc73fa..1e99af9b19b 100644 --- a/test/integration/targets/yum/tasks/yum.yml +++ b/test/integration/targets/yum/tasks/yum.yml @@ -120,15 +120,30 @@ that: - "yum_result is successful" -- name: install sos with state latest in check mode with config file param - yum: name=sos state=latest conf_file=/etc/yum.conf - check_mode: true - register: yum_result -- name: verify install sos with state latest in check mode with config file param - assert: - that: +- name: copy yum.conf file in case it is missing + copy: + src: yum.conf + dest: /etc/yum.conf + force: False + register: yum_conf_copy + +- block: + - name: install sos with state latest in check mode with config file param + yum: name=sos state=latest conf_file=/etc/yum.conf + check_mode: true + register: yum_result + - name: verify install sos with state latest in check mode with config file param + assert: + that: - "yum_result is changed" + always: + - name: remove tmp yum.conf file if we created it + file: + path: /etc/yum.conf + state: absent + when: yum_conf_copy is changed + - name: install sos with state latest in check mode yum: name=sos state=latest check_mode: true @@ -742,4 +757,4 @@ # Fedora < 26 has a bug in dnf where package excludes in dnf.conf aren't # actually honored and those releases are EOL'd so we have no expectation they # will ever be fixed - when: not ((ansible_distribution == "Fedora") and (ansible_distribution_major_version|int < 26)) \ No newline at end of file + when: not ((ansible_distribution == "Fedora") and (ansible_distribution_major_version|int < 26))