Revert "Revert "Add --installroot to YUM and DNF modules, issue #11310""

This reverts commit b73ddd5212.
This commit is contained in:
Toshio Kuratomi 2017-01-05 00:24:20 -08:00
commit cd2516bf8d
8 changed files with 265 additions and 43 deletions

View file

@ -210,3 +210,33 @@
assert:
that:
- non_existent_rpm|failed
# Install in installroot='/'. This should be identical to default
- name: install sos in /
dnf: name=sos state=present installroot='/'
register: dnf_result
- name: check sos with rpm in /
shell: rpm -q sos --root=/
failed_when: False
register: rpm_result
- debug: var=dnf_result
- debug: var=rpm_result
- name: verify installation of sos in /
assert:
that:
- "not dnf_result.failed | default(False)"
- "dnf_result.changed"
- "rpm_result.rc == 0"
- name: verify dnf module outputs in /
assert:
that:
- "'changed' in dnf_result"
- "'results' in dnf_result"
- name: uninstall sos in /
dnf: name=sos installroot='/'
register: dnf_result

View file

@ -0,0 +1,47 @@
# make a installroot
- name: Create installroot
local_action:
module: command mktemp -d "{{ lookup('env', 'TMPDIR') | default('/tmp', true) }}/ansible.test.XXXXXX"
register: dnfroot
- name: Make a necessary directory
file:
path: "/{{ dnfroot.stdout }}/etc/dnf/vars/"
state: directory
mode: 0755
- name: Populate directory
copy:
content: "{{ ansible_distribution_version }}\n"
dest: "/{{ dnfroot.stdout }}/etc/dnf/vars/releasever"
# This will drag in > 200 MB.
- name: attempt installroot
dnf: name=sos installroot="/{{ dnfroot.stdout }}/" disable_gpg_check=yes
register: dnf_result
- name: check sos with rpm in installroot
shell: rpm -q sos --root="/{{ dnfroot.stdout }}/"
failed_when: False
register: rpm_result
- debug: var=dnf_result
- debug: var=rpm_result
- name: verify installation of sos in installroot
assert:
that:
- "not dnf_result.failed | default(False)"
- "dnf_result.changed"
- "rpm_result.rc == 0"
- name: verify dnf module outputs in /
assert:
that:
- "'changed' in dnf_result"
- "'results' in dnf_result"
- name: cleanup installroot
file:
path: "/{{ dnfroot.stdout }}/"
state: absent

View file

@ -18,5 +18,9 @@
# Note: We install the yum package onto Fedora so that this will work on dnf systems
# We want to test that for people who don't want to upgrade their systems.
- include: 'dnf.yml'
when: (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and False) or (ansible_distribution in ['Fedora'] and ansible_distribution_major_version >= 23)
- include: 'dnfinstallroot.yml'
when: (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and False) or (ansible_distribution in ['Fedora'] and ansible_distribution_major_version >= 23)