test dnf - fix groups idempotency on RHEL and fix postgresql issue (#51319)
This commit is contained in:
parent
9eef9a3702
commit
670a45c3ac
5 changed files with 176 additions and 264 deletions
|
@ -2,4 +2,3 @@ destructive
|
||||||
shippable/posix/group1
|
shippable/posix/group1
|
||||||
skip/freebsd
|
skip/freebsd
|
||||||
skip/osx
|
skip/osx
|
||||||
skip/rhel8.0
|
|
||||||
|
|
|
@ -265,223 +265,102 @@
|
||||||
- "not dnf_result is changed"
|
- "not dnf_result is changed"
|
||||||
|
|
||||||
# GROUP INSTALL
|
# GROUP INSTALL
|
||||||
# Using 'Books and Guides' because it is only 5 packages and a 7.3 M download on Fedora 26.
|
- name: install Custom Group group
|
||||||
# It also doesn't install anything that will tamper with our Python environment.
|
dnf:
|
||||||
- name: install Books and Guides group block (Fedora)
|
name: "@Custom Group"
|
||||||
block:
|
state: present
|
||||||
- name: install Books and Guides group
|
register: dnf_result
|
||||||
dnf:
|
|
||||||
name: "@Books and Guides"
|
|
||||||
state: present
|
|
||||||
register: dnf_result
|
|
||||||
|
|
||||||
- name: verify installation of the group
|
- name: check foo with rpm
|
||||||
assert:
|
command: rpm -q foo
|
||||||
that:
|
failed_when: False
|
||||||
- "not dnf_result.failed | default(False)"
|
register: foo_result
|
||||||
- "dnf_result.changed"
|
|
||||||
|
|
||||||
- name: verify dnf module outputs
|
- name: verify installation of the group
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'changed' in dnf_result"
|
- not dnf_result is failed
|
||||||
- "'results' in dnf_result"
|
- dnf_result is changed
|
||||||
|
- "'results' in dnf_result"
|
||||||
|
- foo_result.rc == 0
|
||||||
|
|
||||||
- name: install the group again
|
- name: install the group again
|
||||||
dnf:
|
dnf:
|
||||||
name: "@Books and Guides"
|
name: "@Custom Group"
|
||||||
state: present
|
state: present
|
||||||
register: dnf_result
|
register: dnf_result
|
||||||
|
|
||||||
- name: verify nothing changed
|
- name: verify nothing changed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "not dnf_result.changed"
|
- not dnf_result is changed
|
||||||
|
- "'msg' in dnf_result"
|
||||||
|
|
||||||
- name: verify dnf module outputs
|
- name: verify that bar is not installed
|
||||||
assert:
|
dnf:
|
||||||
that:
|
name: bar
|
||||||
- "'changed' in dnf_result"
|
state: absent
|
||||||
- "'msg' in dnf_result"
|
|
||||||
|
|
||||||
- name: verify that bc is not installed
|
- name: install the group again but also with a package that is not yet installed
|
||||||
dnf:
|
dnf:
|
||||||
name: bc
|
name:
|
||||||
state: absent
|
- "@Custom Group"
|
||||||
|
- bar
|
||||||
|
state: present
|
||||||
|
register: dnf_result
|
||||||
|
|
||||||
- name: install the group again but also with a package that is not yet installed
|
- name: check bar with rpm
|
||||||
dnf:
|
command: rpm -q bar
|
||||||
name:
|
failed_when: False
|
||||||
- "@Books and Guides"
|
register: bar_result
|
||||||
- bc
|
|
||||||
state: present
|
|
||||||
register: dnf_result
|
|
||||||
|
|
||||||
- name: verify bc is installed
|
- name: verify bar is installed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "dnf_result.changed"
|
- dnf_result is changed
|
||||||
|
- "'results' in dnf_result"
|
||||||
|
- bar_result.rc == 0
|
||||||
|
|
||||||
- name: verify dnf module outputs
|
- name: try to install the group again, with --check to check 'changed'
|
||||||
assert:
|
dnf:
|
||||||
that:
|
name: "@Custom Group"
|
||||||
- "'changed' in dnf_result"
|
state: present
|
||||||
- "'results' in dnf_result"
|
check_mode: yes
|
||||||
|
register: dnf_result
|
||||||
|
|
||||||
- name: try to install the group again, with --check to check 'changed'
|
- name: verify nothing changed
|
||||||
dnf:
|
assert:
|
||||||
name: "@Books and Guides"
|
that:
|
||||||
state: present
|
- not dnf_result is changed
|
||||||
check_mode: yes
|
- "'msg' in dnf_result"
|
||||||
register: dnf_result
|
|
||||||
|
|
||||||
- name: verify nothing changed
|
- name: remove bar after test
|
||||||
assert:
|
dnf:
|
||||||
that:
|
name: bar
|
||||||
- "not dnf_result.changed"
|
state: absent
|
||||||
|
|
||||||
- name: verify dnf module outputs
|
# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
|
||||||
assert:
|
- shell: 'dnf -y group install "Custom Group" && dnf -y group remove "Custom Group"'
|
||||||
that:
|
register: shell_dnf_result
|
||||||
- "'changed' in dnf_result"
|
|
||||||
- "'msg' in dnf_result"
|
|
||||||
|
|
||||||
# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
|
# GROUP UPGRADE - this will go to the same method as group install
|
||||||
- shell: 'dnf -y group install "Books and Guides" && dnf -y group remove "Books and Guides"'
|
# but through group_update - it is its invocation we're testing here
|
||||||
register: shell_dnf_result
|
# see commit 119c9e5d6eb572c4a4800fbe8136095f9063c37b
|
||||||
|
- name: install latest Custom Group
|
||||||
|
dnf:
|
||||||
|
name: "@Custom Group"
|
||||||
|
state: latest
|
||||||
|
register: dnf_result
|
||||||
|
|
||||||
# GROUP UPGRADE - this will go to the same method as group install
|
- name: verify installation of the group
|
||||||
# but through group_update - it is its invocation we're testing here
|
assert:
|
||||||
# see commit 119c9e5d6eb572c4a4800fbe8136095f9063c37b
|
that:
|
||||||
- name: install latest Books and Guides
|
- not dnf_result is failed
|
||||||
dnf:
|
- dnf_result is changed
|
||||||
name: "@Books and Guides"
|
- "'results' in dnf_result"
|
||||||
state: latest
|
|
||||||
register: dnf_result
|
|
||||||
|
|
||||||
- name: verify installation of the group
|
# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
|
||||||
assert:
|
- shell: dnf -y group install "Custom Group" && dnf -y group remove "Custom Group"
|
||||||
that:
|
|
||||||
- "not dnf_result.failed | default(False)"
|
|
||||||
- "dnf_result.changed"
|
|
||||||
|
|
||||||
- name: verify dnf module outputs
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "'changed' in dnf_result"
|
|
||||||
- "'results' in dnf_result"
|
|
||||||
|
|
||||||
# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
|
|
||||||
- shell: dnf -y group install "Books and Guides" && dnf -y group remove "Books and Guides"
|
|
||||||
when: ansible_distribution == "Fedora"
|
|
||||||
|
|
||||||
- name: install RPM Development Tools group block (rhel8 beta)
|
|
||||||
block:
|
|
||||||
- name: install RPM Development Tools group
|
|
||||||
dnf:
|
|
||||||
name: "@RPM Development Tools"
|
|
||||||
state: present
|
|
||||||
register: dnf_result
|
|
||||||
|
|
||||||
- name: verify installation of the group
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "not dnf_result.failed | default(False)"
|
|
||||||
- "dnf_result.changed"
|
|
||||||
|
|
||||||
- name: verify dnf module outputs
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "'changed' in dnf_result"
|
|
||||||
- "'results' in dnf_result"
|
|
||||||
|
|
||||||
- name: install the group again
|
|
||||||
dnf:
|
|
||||||
name: "@RPM Development Tools"
|
|
||||||
state: present
|
|
||||||
register: dnf_result
|
|
||||||
|
|
||||||
- name: verify nothing changed
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "not dnf_result.changed"
|
|
||||||
|
|
||||||
- name: verify dnf module outputs
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "'changed' in dnf_result"
|
|
||||||
- "'msg' in dnf_result"
|
|
||||||
|
|
||||||
- name: verify that bc is not installed
|
|
||||||
dnf:
|
|
||||||
name: bc
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: install the group again but also with a package that is not yet installed
|
|
||||||
dnf:
|
|
||||||
name:
|
|
||||||
- "@RPM Development Tools"
|
|
||||||
- bc
|
|
||||||
state: present
|
|
||||||
register: dnf_result
|
|
||||||
|
|
||||||
- name: verify bc is installed
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "dnf_result.changed"
|
|
||||||
|
|
||||||
- name: verify dnf module outputs
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "'changed' in dnf_result"
|
|
||||||
- "'results' in dnf_result"
|
|
||||||
|
|
||||||
- name: try to install the group again, with --check to check 'changed'
|
|
||||||
dnf:
|
|
||||||
name: "@RPM Development Tools"
|
|
||||||
state: present
|
|
||||||
check_mode: yes
|
|
||||||
register: dnf_result
|
|
||||||
|
|
||||||
- name: verify nothing changed
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "not dnf_result.changed"
|
|
||||||
|
|
||||||
- name: verify dnf module outputs
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "'changed' in dnf_result"
|
|
||||||
- "'msg' in dnf_result"
|
|
||||||
|
|
||||||
# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
|
|
||||||
- shell: 'dnf -y group install "RPM Development Tools" && dnf -y group remove "RPM Development Tools"'
|
|
||||||
register: shell_dnf_result
|
|
||||||
|
|
||||||
# GROUP UPGRADE - this will go to the same method as group install
|
|
||||||
# but through group_update - it is its invocation we're testing here
|
|
||||||
# see commit 119c9e5d6eb572c4a4800fbe8136095f9063c37b
|
|
||||||
- name: install latest RPM Development Tools
|
|
||||||
dnf:
|
|
||||||
name: "@RPM Development Tools"
|
|
||||||
state: latest
|
|
||||||
register: dnf_result
|
|
||||||
|
|
||||||
- name: verify installation of the group
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "not dnf_result.failed | default(False)"
|
|
||||||
- "dnf_result.changed"
|
|
||||||
|
|
||||||
- name: verify dnf module outputs
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "'changed' in dnf_result"
|
|
||||||
- "'results' in dnf_result"
|
|
||||||
|
|
||||||
# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
|
|
||||||
- shell: dnf -y group install "RPM Development Tools" && dnf -y group remove "RPM Development Tools"
|
|
||||||
when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 8
|
|
||||||
|
|
||||||
- name: try to install non existing group
|
- name: try to install non existing group
|
||||||
dnf:
|
dnf:
|
||||||
|
@ -542,58 +421,35 @@
|
||||||
|
|
||||||
# ENVIRONMENT UPGRADE
|
# ENVIRONMENT UPGRADE
|
||||||
# see commit de299ef77c03a64a8f515033a79ac6b7db1bc710
|
# see commit de299ef77c03a64a8f515033a79ac6b7db1bc710
|
||||||
|
- name: install Custom Environment Group
|
||||||
|
dnf:
|
||||||
|
name: "@Custom Environment Group"
|
||||||
|
state: latest
|
||||||
|
register: dnf_result
|
||||||
|
|
||||||
# Newer Fedora Docker images come with coreutils-single which is incompatible
|
- name: check bar with rpm
|
||||||
# with coreutils (required by @Web Server). We force the install of coreutils
|
command: rpm -q bar
|
||||||
# before running the environment group install.
|
register: bar_result
|
||||||
# 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
|
|
||||||
when: ansible_distribution == "Fedora"
|
|
||||||
|
|
||||||
- name: install Web Server environment block (Fedora)
|
- name: verify installation of the environment
|
||||||
block:
|
assert:
|
||||||
- name: install Web Server environment
|
that:
|
||||||
dnf:
|
- not dnf_result is failed
|
||||||
name: "@Web Server"
|
- dnf_result is changed
|
||||||
state: latest
|
- "'results' in dnf_result"
|
||||||
register: dnf_result
|
- bar_result.rc == 0
|
||||||
- name: verify installation of the environment
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "not dnf_result.failed | default(False)"
|
|
||||||
- "dnf_result.changed"
|
|
||||||
- name: verify dnf module outputs
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "'changed' in dnf_result"
|
|
||||||
- "'results' in dnf_result"
|
|
||||||
always:
|
|
||||||
- name: reinstall coreutils-single if coreutils was installed
|
|
||||||
command: dnf install --allowerasing -y coreutils-single
|
|
||||||
when: coreutils_install is changed
|
|
||||||
when: ansible_distribution == "Fedora"
|
|
||||||
|
|
||||||
- name: install Server environment block (rhel8 beta)
|
# Fedora 28 (DNF 2) does not support this, just remove the package itself
|
||||||
block:
|
- name: remove bar package on Fedora 28
|
||||||
- name: install Server environment
|
dnf:
|
||||||
dnf:
|
name: bar
|
||||||
name: "@Server"
|
state: absent
|
||||||
state: latest
|
when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int <= 28
|
||||||
register: dnf_result
|
|
||||||
- name: verify installation of the environment
|
# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
|
||||||
assert:
|
- name: remove Custom Environment Group
|
||||||
that:
|
shell: dnf -y group install "Custom Environment Group" && dnf -y group remove "Custom Environment Group"
|
||||||
- "not dnf_result.failed | default(False)"
|
when: not (ansible_distribution == 'Fedora' and ansible_distribution_major_version|int <= 28)
|
||||||
- "dnf_result.changed"
|
|
||||||
- name: verify dnf module outputs
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "'changed' in dnf_result"
|
|
||||||
- "'results' in dnf_result"
|
|
||||||
when: ansible_distribution == "RedHat"
|
|
||||||
|
|
||||||
# https://github.com/ansible/ansible/issues/39704
|
# https://github.com/ansible/ansible/issues/39704
|
||||||
- name: install non-existent rpm, state=latest
|
- name: install non-existent rpm, state=latest
|
||||||
|
|
|
@ -1,46 +1,57 @@
|
||||||
- name: install "@postgresql:9.6/client" module
|
# FUTURE - look at including AppStream support in our local repo
|
||||||
|
- name: set package for RHEL
|
||||||
|
set_fact:
|
||||||
|
astream_name: '@swig:3.0/default'
|
||||||
|
when: ansible_distribution == 'RedHat'
|
||||||
|
|
||||||
|
- name: set package for Fedora
|
||||||
|
set_fact:
|
||||||
|
astream_name: '@ninja:master/default'
|
||||||
|
when: ansible_distribution == 'Fedora'
|
||||||
|
|
||||||
|
- name: install "{{ astream_name }}" module
|
||||||
dnf:
|
dnf:
|
||||||
name: "@postgresql:9.6/client"
|
name: "{{ astream_name }}"
|
||||||
state: present
|
state: present
|
||||||
register: dnf_result
|
register: dnf_result
|
||||||
|
|
||||||
- name: verify installation of "@postgresql:9.6/client" module
|
- name: verify installation of "{{ astream_name }}" module
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "not dnf_result.failed"
|
- "not dnf_result.failed"
|
||||||
- "dnf_result.changed"
|
- "dnf_result.changed"
|
||||||
|
|
||||||
- name: install "@postgresql:9.6/client" module again
|
- name: install "{{ astream_name }}" module again
|
||||||
dnf:
|
dnf:
|
||||||
name: "@postgresql:9.6/client"
|
name: "{{ astream_name }}"
|
||||||
state: present
|
state: present
|
||||||
register: dnf_result
|
register: dnf_result
|
||||||
|
|
||||||
- name: verify installation of "@postgresql:9.6/client" module again
|
- name: verify installation of "{{ astream_name }}" module again
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "not dnf_result.failed"
|
- "not dnf_result.failed"
|
||||||
- "not dnf_result.changed"
|
- "not dnf_result.changed"
|
||||||
|
|
||||||
- name: uninstall "@postgresql:9.6/client" module
|
- name: uninstall "{{ astream_name }}" module
|
||||||
dnf:
|
dnf:
|
||||||
name: "@postgresql:9.6/client"
|
name: "{{ astream_name }}"
|
||||||
state: absent
|
state: absent
|
||||||
register: dnf_result
|
register: dnf_result
|
||||||
|
|
||||||
- name: verify uninstallation of "@postgresql:9.6/client" module
|
- name: verify uninstallation of "{{ astream_name }}" module
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "not dnf_result.failed"
|
- "not dnf_result.failed"
|
||||||
- "dnf_result.changed"
|
- "dnf_result.changed"
|
||||||
|
|
||||||
- name: uninstall "@postgresql:9.6/client" module again
|
- name: uninstall "{{ astream_name }}" module again
|
||||||
dnf:
|
dnf:
|
||||||
name: "@postgresql:9.6/client"
|
name: "{{ astream_name }}"
|
||||||
state: absent
|
state: absent
|
||||||
register: dnf_result
|
register: dnf_result
|
||||||
|
|
||||||
- name: verify uninstallation of "@postgresql:9.6/client" module again
|
- name: verify uninstallation of "{{ astream_name }}" module again
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "not dnf_result.failed"
|
- "not dnf_result.failed"
|
||||||
|
|
36
test/integration/targets/setup_rpm_repo/files/comps.xml
Normal file
36
test/integration/targets/setup_rpm_repo/files/comps.xml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd">
|
||||||
|
<comps>
|
||||||
|
<group>
|
||||||
|
<id>customgroup</id>
|
||||||
|
<name>Custom Group</name>
|
||||||
|
<description></description>
|
||||||
|
<default>false</default>
|
||||||
|
<uservisible>true</uservisible>
|
||||||
|
<display_order>1024</display_order>
|
||||||
|
<packagelist>
|
||||||
|
<packagereq type="mandatory">foo</packagereq>
|
||||||
|
</packagelist>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<group>
|
||||||
|
<id>customenvgroup</id>
|
||||||
|
<name>Custom Environment Group</name>
|
||||||
|
<description></description>
|
||||||
|
<default>false</default>
|
||||||
|
<uservisible>false</uservisible>
|
||||||
|
<display_order>1024</display_order>
|
||||||
|
<packagelist>
|
||||||
|
<packagereq type="mandatory">bar</packagereq>
|
||||||
|
</packagelist>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<environment>
|
||||||
|
<id>customenvgroup-environment</id>
|
||||||
|
<name>Custom Environment Group</name>
|
||||||
|
<description></description>
|
||||||
|
<display_order>1024</display_order>
|
||||||
|
<grouplist>
|
||||||
|
<groupid>customenvgroup</groupid>
|
||||||
|
</grouplist>
|
||||||
|
</environment>
|
||||||
|
</comps>
|
|
@ -11,6 +11,7 @@
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
- python{{ ansible_python_version.split(".")[0] }}-rpmfluff
|
- python{{ ansible_python_version.split(".")[0] }}-rpmfluff
|
||||||
|
- createrepo
|
||||||
when:
|
when:
|
||||||
- ansible_distribution in ['Fedora']
|
- ansible_distribution in ['Fedora']
|
||||||
|
|
||||||
|
@ -72,6 +73,15 @@
|
||||||
baseurl: "file://{{ repodir }}"
|
baseurl: "file://{{ repodir }}"
|
||||||
gpgcheck: no
|
gpgcheck: no
|
||||||
|
|
||||||
|
- name: Copy comps.xml file
|
||||||
|
copy:
|
||||||
|
src: comps.xml
|
||||||
|
dest: "{{ repodir }}"
|
||||||
|
register: repodir_comps
|
||||||
|
|
||||||
|
- name: Register comps.xml on repo
|
||||||
|
command: createrepo -g {{ repodir_comps.dest | quote }} {{ repodir | quote }}
|
||||||
|
|
||||||
- name: Create RPMs and put them into a repo (i686)
|
- name: Create RPMs and put them into a repo (i686)
|
||||||
shell: "{{ansible_python_interpreter}} /tmp/create-repo.py i686"
|
shell: "{{ansible_python_interpreter}} /tmp/create-repo.py i686"
|
||||||
register: repo_i686
|
register: repo_i686
|
||||||
|
|
Loading…
Reference in a new issue