diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
commit | 8a754e0858d922e955e71b253c139e071ecec432 (patch) | |
tree | 527d16e74bfd1840c85efd675fdecad056c54107 /test/integration/targets/yum/tasks/yuminstallroot.yml | |
parent | Initial commit. (diff) | |
download | ansible-core-upstream.tar.xz ansible-core-upstream.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/targets/yum/tasks/yuminstallroot.yml')
-rw-r--r-- | test/integration/targets/yum/tasks/yuminstallroot.yml | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/test/integration/targets/yum/tasks/yuminstallroot.yml b/test/integration/targets/yum/tasks/yuminstallroot.yml new file mode 100644 index 0000000..028e805 --- /dev/null +++ b/test/integration/targets/yum/tasks/yuminstallroot.yml @@ -0,0 +1,132 @@ +# make a installroot +- name: Create installroot + command: mktemp -d "{{ remote_tmp_dir }}/ansible.test.XXXXXX" + register: yumroot + +#- name: Populate directory +# file: +# path: "/{{ yumroot.stdout }}/etc/" +# state: directory +# mode: 0755 +# +#- name: Populate directory2 +# copy: +# content: "[main]\ndistropkgver={{ ansible_distribution_version }}\n" +# dest: "/{{ yumroot.stdout }}/etc/yum.conf" + +- name: Make a necessary directory + file: + path: "{{ yumroot.stdout }}/etc/yum/vars/" + state: directory + mode: 0755 + +- name: get yum releasever + command: "{{ ansible_python_interpreter }} -c 'import yum; yb = yum.YumBase(); print(yb.conf.yumvar[\"releasever\"])'" + register: releasever + ignore_errors: yes + +- name: Populate directory + copy: + content: "{{ releasever.stdout_lines[-1] }}\n" + dest: "/{{ yumroot.stdout }}/etc/yum/vars/releasever" + when: releasever is successful + +# This will drag in > 200 MB. +- name: attempt installroot + yum: name=zlib installroot="{{ yumroot.stdout }}/" disable_gpg_check=yes + register: yum_result + +- name: check sos with rpm in installroot + shell: rpm -q zlib --root="{{ yumroot.stdout }}/" + failed_when: False + register: rpm_result + +- name: verify installation of sos + assert: + that: + - "yum_result.rc == 0" + - "yum_result.changed" + - "rpm_result.rc == 0" + +- name: verify yum module outputs + assert: + that: + - "'changed' in yum_result" + - "'msg' in yum_result" + - "'rc' in yum_result" + - "'results' in yum_result" + +- name: cleanup installroot + file: + path: "{{ yumroot.stdout }}/" + state: absent + +# Test for releasever working correctly +# +# Bugfix: https://github.com/ansible/ansible/issues/67050 +# +# This test case is based on a reproducer originally reported on Reddit: +# https://www.reddit.com/r/ansible/comments/g2ps32/ansible_yum_module_throws_up_an_error_when/ +# +# NOTE: For the Ansible upstream CI we can only run this for RHEL7 because the +# containerized runtimes in shippable don't allow the nested mounting of +# buildah container volumes. +- name: perform yuminstallroot in a buildah mount with releasever + when: + - ansible_facts["distribution_major_version"] == "7" + - ansible_facts["distribution"] == "RedHat" + block: + - name: install required packages for buildah test + yum: + state: present + name: + - buildah + - name: create buildah container from scratch + command: "buildah --name yum_installroot_releasever_test from scratch" + - name: mount the buildah container + command: "buildah mount yum_installroot_releasever_test" + register: buildah_mount + - name: figure out yum value of $releasever + shell: python -c 'import yum; yb = yum.YumBase(); print(yb.conf.yumvar["releasever"])' | tail -1 + register: buildah_host_releasever + - name: test yum install of python using releasever + yum: + name: 'python' + state: present + installroot: "{{ buildah_mount.stdout }}" + releasever: "{{ buildah_host_releasever.stdout }}" + register: yum_result + - name: verify installation of python + assert: + that: + - "yum_result.rc == 0" + - "yum_result.changed" + - "rpm_result.rc == 0" + - name: remove python before another test + yum: + name: 'python' + state: absent + installroot: "{{ buildah_mount.stdout }}" + releasever: "{{ buildah_host_releasever.stdout }}" + - name: test yum install of python using releasever with latest + yum: + name: 'python' + state: latest + installroot: "{{ buildah_mount.stdout }}" + releasever: "{{ buildah_host_releasever.stdout }}" + register: yum_result + - name: verify installation of python + assert: + that: + - "yum_result.rc == 0" + - "yum_result.changed" + - "rpm_result.rc == 0" + always: + - name: remove buildah container + command: "buildah rm yum_installroot_releasever_test" + ignore_errors: yes + - name: remove buildah from CI system + yum: + state: absent + name: + - buildah |