2017-01-05 09:24:20 +01:00
|
|
|
# make a installroot
|
|
|
|
- name: Create installroot
|
2019-04-27 02:33:59 +02:00
|
|
|
command: mktemp -d "{{ remote_tmp_dir }}/ansible.test.XXXXXX"
|
2017-01-05 09:24:20 +01:00
|
|
|
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:
|
2017-01-05 19:42:43 +01:00
|
|
|
path: "{{ yumroot.stdout }}/etc/yum/vars/"
|
2017-01-05 09:24:20 +01:00
|
|
|
state: directory
|
|
|
|
mode: 0755
|
|
|
|
|
2017-07-07 22:02:11 +02:00
|
|
|
- name: get yum releasever
|
2019-03-29 09:19:51 +01:00
|
|
|
command: "{{ ansible_python_interpreter }} -c 'import yum; yb = yum.YumBase(); print(yb.conf.yumvar[\"releasever\"])'"
|
2017-07-07 22:02:11 +02:00
|
|
|
register: releasever
|
2019-03-29 09:19:51 +01:00
|
|
|
ignore_errors: yes
|
2017-07-07 22:02:11 +02:00
|
|
|
|
2017-01-05 19:42:43 +01:00
|
|
|
- name: Populate directory
|
|
|
|
copy:
|
2019-03-29 09:19:51 +01:00
|
|
|
content: "{{ releasever.stdout_lines[-1] }}\n"
|
2017-01-05 19:42:43 +01:00
|
|
|
dest: "/{{ yumroot.stdout }}/etc/yum/vars/releasever"
|
2019-03-29 09:19:51 +01:00
|
|
|
when: releasever is successful
|
2017-01-05 19:42:43 +01:00
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
2017-01-05 09:24:20 +01:00
|
|
|
- name: cleanup installroot
|
|
|
|
file:
|
2017-01-05 19:42:43 +01:00
|
|
|
path: "{{ yumroot.stdout }}/"
|
2017-01-05 09:24:20 +01:00
|
|
|
state: absent
|
2020-04-23 09:02:00 +02:00
|
|
|
|
|
|
|
# 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:
|
|
|
|
# Need to enable this RHUI repo for RHEL7 testing in AWS, CentOS has Extras
|
|
|
|
# enabled by default and this is not needed there.
|
2020-08-06 23:07:35 +02:00
|
|
|
- name: enable rhel-7-server-rhui-extras-rpms repo for RHEL7
|
|
|
|
command: yum-config-manager --enable rhel-7-server-rhui-extras-rpms
|
2020-04-23 09:02:00 +02:00
|
|
|
- name: update cache to pull repodata
|
|
|
|
yum:
|
|
|
|
update_cache: yes
|
|
|
|
- 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"
|
|
|
|
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
|
2020-08-06 23:07:35 +02:00
|
|
|
- name: disable rhel-7-server-rhui-extras-rpms repo for RHEL7
|
|
|
|
command: yum-config-manager --disable rhel-7-server-rhui-extras-rpms
|