2017-01-05 09:24:20 +01:00
|
|
|
# make a installroot
|
|
|
|
- name: Create installroot
|
|
|
|
local_action:
|
|
|
|
module: command mktemp -d "{{ lookup('env', 'TMPDIR') | default('/tmp', true) }}/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:
|
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
|