summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/dnf
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/dnf')
-rw-r--r--test/integration/targets/dnf/aliases7
-rw-r--r--test/integration/targets/dnf/meta/main.yml4
-rw-r--r--test/integration/targets/dnf/tasks/dnf.yml774
-rw-r--r--test/integration/targets/dnf/tasks/dnfinstallroot.yml47
-rw-r--r--test/integration/targets/dnf/tasks/dnfreleasever.yml47
-rw-r--r--test/integration/targets/dnf/tasks/filters.yml134
-rw-r--r--test/integration/targets/dnf/tasks/filters_check_mode.yml118
-rw-r--r--test/integration/targets/dnf/tasks/gpg.yml72
-rw-r--r--test/integration/targets/dnf/tasks/logging.yml48
-rw-r--r--test/integration/targets/dnf/tasks/main.yml62
-rw-r--r--test/integration/targets/dnf/tasks/modularity.yml99
-rw-r--r--test/integration/targets/dnf/tasks/repo.yml309
-rw-r--r--test/integration/targets/dnf/vars/CentOS.yml2
-rw-r--r--test/integration/targets/dnf/vars/Fedora.yml6
-rw-r--r--test/integration/targets/dnf/vars/RedHat.yml2
-rw-r--r--test/integration/targets/dnf/vars/main.yml4
16 files changed, 1735 insertions, 0 deletions
diff --git a/test/integration/targets/dnf/aliases b/test/integration/targets/dnf/aliases
new file mode 100644
index 00000000..4d1afd64
--- /dev/null
+++ b/test/integration/targets/dnf/aliases
@@ -0,0 +1,7 @@
+destructive
+shippable/posix/group4
+skip/aix
+skip/power/centos
+skip/freebsd
+skip/osx
+skip/macos
diff --git a/test/integration/targets/dnf/meta/main.yml b/test/integration/targets/dnf/meta/main.yml
new file mode 100644
index 00000000..34d81261
--- /dev/null
+++ b/test/integration/targets/dnf/meta/main.yml
@@ -0,0 +1,4 @@
+dependencies:
+ - prepare_tests
+ - setup_rpm_repo
+ - setup_remote_tmp_dir
diff --git a/test/integration/targets/dnf/tasks/dnf.yml b/test/integration/targets/dnf/tasks/dnf.yml
new file mode 100644
index 00000000..19008188
--- /dev/null
+++ b/test/integration/targets/dnf/tasks/dnf.yml
@@ -0,0 +1,774 @@
+# UNINSTALL 'python2-dnf'
+# The `dnf` module has the smarts to auto-install the relevant python
+# bindings. To test, we will first uninstall python2-dnf (so that the tests
+# on python2 will require python2-dnf)
+- name: check python2-dnf with rpm
+ shell: rpm -q python2-dnf
+ register: rpm_result
+ ignore_errors: true
+ args:
+ warn: no
+
+# Don't uninstall python2-dnf with the `dnf` module in case it needs to load
+# some dnf python files after the package is uninstalled.
+- name: uninstall python2-dnf with shell
+ shell: dnf -y remove python2-dnf
+ when: rpm_result is successful
+
+# UNINSTALL
+# With 'python2-dnf' uninstalled, the first call to 'dnf' should install
+# python2-dnf.
+- name: uninstall sos
+ dnf:
+ name: sos
+ state: removed
+ register: dnf_result
+
+- name: check sos with rpm
+ shell: rpm -q sos
+ failed_when: False
+ register: rpm_result
+
+- name: verify uninstallation of sos
+ assert:
+ that:
+ - "not dnf_result.failed | default(False)"
+ - "rpm_result.rc == 1"
+
+# UNINSTALL AGAIN
+- name: uninstall sos
+ dnf:
+ name: sos
+ state: removed
+ register: dnf_result
+
+- name: verify no change on re-uninstall
+ assert:
+ that:
+ - "not dnf_result.changed"
+
+# INSTALL
+- name: install sos (check_mode)
+ dnf:
+ name: sos
+ state: present
+ update_cache: True
+ check_mode: True
+ register: dnf_result
+
+- assert:
+ that:
+ - dnf_result is success
+ - dnf_result.results|length > 0
+ - "dnf_result.results[0].startswith('Installed: ')"
+
+- name: install sos
+ dnf:
+ name: sos
+ state: present
+ update_cache: True
+ register: dnf_result
+
+- name: check sos with rpm
+ shell: rpm -q sos
+ failed_when: False
+ register: rpm_result
+
+- name: verify installation of sos
+ assert:
+ that:
+ - "not dnf_result.failed | default(False)"
+ - "dnf_result.changed"
+ - "rpm_result.rc == 0"
+
+- name: verify dnf module outputs
+ assert:
+ that:
+ - "'changed' in dnf_result"
+ - "'results' in dnf_result"
+
+# INSTALL AGAIN
+- name: install sos again (check_mode)
+ dnf:
+ name: sos
+ state: present
+ check_mode: True
+ register: dnf_result
+
+- assert:
+ that:
+ - dnf_result is not changed
+ - dnf_result.results|length == 0
+
+- name: install sos again
+ dnf:
+ name: sos
+ state: present
+ register: dnf_result
+
+- name: verify no change on second install
+ assert:
+ that:
+ - "not dnf_result.changed"
+
+# Multiple packages
+- name: uninstall sos and pciutils
+ dnf: name=sos,pciutils state=removed
+ register: dnf_result
+
+- name: check sos with rpm
+ shell: rpm -q sos
+ failed_when: False
+ register: rpm_sos_result
+
+- name: check pciutils with rpm
+ shell: rpm -q pciutils
+ failed_when: False
+ register: rpm_pciutils_result
+
+- name: verify packages installed
+ assert:
+ that:
+ - "rpm_sos_result.rc != 0"
+ - "rpm_pciutils_result.rc != 0"
+
+- name: install sos and pciutils as comma separated
+ dnf: name=sos,pciutils state=present
+ register: dnf_result
+
+- name: check sos with rpm
+ shell: rpm -q sos
+ failed_when: False
+ register: rpm_sos_result
+
+- name: check pciutils with rpm
+ shell: rpm -q pciutils
+ failed_when: False
+ register: rpm_pciutils_result
+
+- name: verify packages installed
+ assert:
+ that:
+ - "not dnf_result.failed | default(False)"
+ - "dnf_result.changed"
+ - "rpm_sos_result.rc == 0"
+ - "rpm_pciutils_result.rc == 0"
+
+- name: uninstall sos and pciutils
+ dnf: name=sos,pciutils state=removed
+ register: dnf_result
+
+- name: install sos and pciutils as list
+ dnf:
+ name:
+ - sos
+ - pciutils
+ state: present
+ register: dnf_result
+
+- name: check sos with rpm
+ shell: rpm -q sos
+ failed_when: False
+ register: rpm_sos_result
+
+- name: check pciutils with rpm
+ shell: rpm -q pciutils
+ failed_when: False
+ register: rpm_pciutils_result
+
+- name: verify packages installed
+ assert:
+ that:
+ - "not dnf_result.failed | default(False)"
+ - "dnf_result.changed"
+ - "rpm_sos_result.rc == 0"
+ - "rpm_pciutils_result.rc == 0"
+
+- name: uninstall sos and pciutils
+ dnf:
+ name: "sos,pciutils"
+ state: removed
+ register: dnf_result
+
+- name: install sos and pciutils as comma separated with spaces
+ dnf:
+ name: "sos, pciutils"
+ state: present
+ register: dnf_result
+
+- name: check sos with rpm
+ shell: rpm -q sos
+ failed_when: False
+ register: rpm_sos_result
+
+- name: check sos with rpm
+ shell: rpm -q pciutils
+ failed_when: False
+ register: rpm_pciutils_result
+
+- name: verify packages installed
+ assert:
+ that:
+ - "not dnf_result.failed | default(False)"
+ - "dnf_result.changed"
+ - "rpm_sos_result.rc == 0"
+ - "rpm_pciutils_result.rc == 0"
+
+- name: uninstall sos and pciutils (check_mode)
+ dnf:
+ name:
+ - sos
+ - pciutils
+ state: removed
+ check_mode: True
+ register: dnf_result
+
+- assert:
+ that:
+ - dnf_result is success
+ - dnf_result.results|length == 2
+ - "dnf_result.results[0].startswith('Removed: ')"
+ - "dnf_result.results[1].startswith('Removed: ')"
+
+- name: uninstall sos and pciutils
+ dnf:
+ name:
+ - sos
+ - pciutils
+ state: removed
+ register: dnf_result
+
+- assert:
+ that:
+ - dnf_result is changed
+
+- name: install non-existent rpm
+ dnf:
+ name: does-not-exist
+ register: non_existent_rpm
+ ignore_errors: True
+
+- name: check non-existent rpm install failed
+ assert:
+ that:
+ - non_existent_rpm is 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
+
+- 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
+
+- name: uninstall sos for downloadonly test
+ dnf:
+ name: sos
+ state: absent
+
+- name: Test download_only (check_mode)
+ dnf:
+ name: sos
+ state: latest
+ download_only: true
+ check_mode: true
+ register: dnf_result
+
+- assert:
+ that:
+ - dnf_result is success
+ - "dnf_result.results[0].startswith('Downloaded: ')"
+
+- name: Test download_only
+ dnf:
+ name: sos
+ state: latest
+ download_only: true
+ register: dnf_result
+
+- name: verify download of sos (part 1 -- dnf "install" succeeded)
+ assert:
+ that:
+ - "dnf_result is success"
+ - "dnf_result is changed"
+
+- name: uninstall sos (noop)
+ dnf:
+ name: sos
+ state: absent
+ register: dnf_result
+
+- name: verify download of sos (part 2 -- nothing removed during uninstall)
+ assert:
+ that:
+ - "dnf_result is success"
+ - "not dnf_result is changed"
+
+- name: uninstall sos for downloadonly/downloaddir test
+ dnf:
+ name: sos
+ state: absent
+
+- name: Test download_only/download_dir
+ dnf:
+ name: sos
+ state: latest
+ download_only: true
+ download_dir: "/var/tmp/packages"
+ register: dnf_result
+
+- name: verify dnf output
+ assert:
+ that:
+ - "dnf_result is success"
+ - "dnf_result is changed"
+
+- command: "ls /var/tmp/packages"
+ register: ls_out
+
+- name: Verify specified download_dir was used
+ assert:
+ that:
+ - "'sos' in ls_out.stdout"
+
+# GROUP INSTALL
+- name: install Custom Group group
+ dnf:
+ name: "@Custom Group"
+ state: present
+ register: dnf_result
+
+- name: check dinginessentail with rpm
+ command: rpm -q dinginessentail
+ failed_when: False
+ register: dinginessentail_result
+
+- name: verify installation of the group
+ assert:
+ that:
+ - not dnf_result is failed
+ - dnf_result is changed
+ - "'results' in dnf_result"
+ - dinginessentail_result.rc == 0
+
+- name: install the group again
+ dnf:
+ name: "@Custom Group"
+ state: present
+ register: dnf_result
+
+- name: verify nothing changed
+ assert:
+ that:
+ - not dnf_result is changed
+ - "'msg' in dnf_result"
+
+- name: verify that landsidescalping is not installed
+ dnf:
+ name: landsidescalping
+ state: absent
+
+- name: install the group again but also with a package that is not yet installed
+ dnf:
+ name:
+ - "@Custom Group"
+ - landsidescalping
+ state: present
+ register: dnf_result
+
+- name: check landsidescalping with rpm
+ command: rpm -q landsidescalping
+ failed_when: False
+ register: landsidescalping_result
+
+- name: verify landsidescalping is installed
+ assert:
+ that:
+ - dnf_result is changed
+ - "'results' in dnf_result"
+ - landsidescalping_result.rc == 0
+
+- name: try to install the group again, with --check to check 'changed'
+ dnf:
+ name: "@Custom Group"
+ state: present
+ check_mode: yes
+ register: dnf_result
+
+- name: verify nothing changed
+ assert:
+ that:
+ - not dnf_result is changed
+ - "'msg' in dnf_result"
+
+- name: remove landsidescalping after test
+ dnf:
+ name: landsidescalping
+ state: absent
+
+# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
+- shell: 'dnf -y group install "Custom Group" && dnf -y group remove "Custom Group"'
+ 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 Custom Group
+ dnf:
+ name: "@Custom Group"
+ state: latest
+ register: dnf_result
+
+- name: verify installation of the group
+ assert:
+ that:
+ - not dnf_result is failed
+ - dnf_result is changed
+ - "'results' in dnf_result"
+
+# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
+- shell: dnf -y group install "Custom Group" && dnf -y group remove "Custom Group"
+
+- name: try to install non existing group
+ dnf:
+ name: "@non-existing-group"
+ state: present
+ register: dnf_result
+ ignore_errors: True
+
+- name: verify installation of the non existing group failed
+ assert:
+ that:
+ - "not dnf_result.changed"
+ - "dnf_result is failed"
+
+- name: verify dnf module outputs
+ assert:
+ that:
+ - "'changed' in dnf_result"
+ - "'msg' in dnf_result"
+
+- name: try to install non existing file
+ dnf:
+ name: /tmp/non-existing-1.0.0.fc26.noarch.rpm
+ state: present
+ register: dnf_result
+ ignore_errors: yes
+
+- name: verify installation failed
+ assert:
+ that:
+ - "dnf_result is failed"
+ - "not dnf_result.changed"
+
+- name: verify dnf module outputs
+ assert:
+ that:
+ - "'changed' in dnf_result"
+ - "'msg' in dnf_result"
+
+- name: try to install from non existing url
+ dnf:
+ name: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/dnf/non-existing-1.0.0.fc26.noarch.rpm
+ state: present
+ register: dnf_result
+ ignore_errors: yes
+
+- name: verify installation failed
+ assert:
+ that:
+ - "dnf_result is failed"
+ - "not dnf_result.changed"
+
+- name: verify dnf module outputs
+ assert:
+ that:
+ - "'changed' in dnf_result"
+ - "'msg' in dnf_result"
+
+# ENVIRONMENT UPGRADE
+# see commit de299ef77c03a64a8f515033a79ac6b7db1bc710
+- name: install Custom Environment Group
+ dnf:
+ name: "@Custom Environment Group"
+ state: latest
+ register: dnf_result
+
+- name: check landsidescalping with rpm
+ command: rpm -q landsidescalping
+ register: landsidescalping_result
+
+- name: verify installation of the environment
+ assert:
+ that:
+ - not dnf_result is failed
+ - dnf_result is changed
+ - "'results' in dnf_result"
+ - landsidescalping_result.rc == 0
+
+# Fedora 28 (DNF 2) does not support this, just remove the package itself
+- name: remove landsidescalping package on Fedora 28
+ dnf:
+ name: landsidescalping
+ state: absent
+ when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int <= 28
+
+# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
+- name: remove Custom Environment Group
+ shell: dnf -y group install "Custom Environment Group" && dnf -y group remove "Custom Environment Group"
+ when: not (ansible_distribution == 'Fedora' and ansible_distribution_major_version|int <= 28)
+
+# https://github.com/ansible/ansible/issues/39704
+- name: install non-existent rpm, state=latest
+ dnf:
+ name: non-existent-rpm
+ state: latest
+ ignore_errors: yes
+ register: dnf_result
+
+- name: verify the result
+ assert:
+ that:
+ - "dnf_result is failed"
+ - "'non-existent-rpm' in dnf_result['failures'][0]"
+ - "'No package non-existent-rpm available' in dnf_result['failures'][0]"
+ - "'Failed to install some of the specified packages' in dnf_result['msg']"
+
+- name: use latest to install httpd
+ dnf:
+ name: httpd
+ state: latest
+ register: dnf_result
+
+- name: verify httpd was installed
+ assert:
+ that:
+ - "'changed' in dnf_result"
+
+- name: uninstall httpd
+ dnf:
+ name: httpd
+ state: removed
+
+- name: update httpd only if it exists
+ dnf:
+ name: httpd
+ state: latest
+ update_only: yes
+ register: dnf_result
+
+- name: verify httpd not installed
+ assert:
+ that:
+ - "not dnf_result is changed"
+
+- name: try to install not compatible arch rpm, should fail
+ dnf:
+ name: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/dnf/banner-1.3.4-3.el7.ppc64le.rpm
+ state: present
+ register: dnf_result
+ ignore_errors: True
+
+- name: verify that dnf failed
+ assert:
+ that:
+ - "not dnf_result is changed"
+ - "dnf_result is failed"
+
+# setup for testing installing an RPM from url
+
+- set_fact:
+ pkg_name: fpaste
+
+- name: cleanup
+ dnf:
+ name: "{{ pkg_name }}"
+ state: absent
+
+- set_fact:
+ pkg_url: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/dnf/fpaste-0.3.9.1-1.fc27.noarch.rpm
+# setup end
+
+- name: download an rpm
+ get_url:
+ url: "{{ pkg_url }}"
+ dest: "/tmp/{{ pkg_name }}.rpm"
+
+- name: install the downloaded rpm
+ dnf:
+ name: "/tmp/{{ pkg_name }}.rpm"
+ state: present
+ disable_gpg_check: true
+ register: dnf_result
+
+- name: verify installation
+ assert:
+ that:
+ - "dnf_result is success"
+ - "dnf_result is changed"
+
+- name: install the downloaded rpm again
+ dnf:
+ name: "/tmp/{{ pkg_name }}.rpm"
+ state: present
+ register: dnf_result
+
+- name: verify installation
+ assert:
+ that:
+ - "dnf_result is success"
+ - "not dnf_result is changed"
+
+- name: clean up
+ dnf:
+ name: "{{ pkg_name }}"
+ state: absent
+
+- name: install from url
+ dnf:
+ name: "{{ pkg_url }}"
+ state: present
+ disable_gpg_check: true
+ register: dnf_result
+
+- name: verify installation
+ assert:
+ that:
+ - "dnf_result is success"
+ - "dnf_result is changed"
+ - "dnf_result is not failed"
+
+- name: verify dnf module outputs
+ assert:
+ that:
+ - "'changed' in dnf_result"
+ - "'results' in dnf_result"
+
+- name: Create a temp RPM file which does not contain nevra information
+ file:
+ name: "/tmp/non_existent_pkg.rpm"
+ state: touch
+
+- name: Try installing RPM file which does not contain nevra information
+ dnf:
+ name: "/tmp/non_existent_pkg.rpm"
+ state: present
+ register: no_nevra_info_result
+ ignore_errors: yes
+
+- name: Verify RPM failed to install
+ assert:
+ that:
+ - "'changed' in no_nevra_info_result"
+ - "'msg' in no_nevra_info_result"
+
+- name: Delete a temp RPM file
+ file:
+ name: "/tmp/non_existent_pkg.rpm"
+ state: absent
+
+- name: uninstall lsof
+ dnf:
+ name: lsof
+ state: removed
+
+- name: check lsof with rpm
+ shell: rpm -q lsof
+ ignore_errors: True
+ register: rpm_lsof_result
+
+- name: verify lsof is uninstalled
+ assert:
+ that:
+ - "rpm_lsof_result is failed"
+
+- name: create conf file that excludes lsof
+ copy:
+ content: |
+ [main]
+ exclude=lsof*
+ dest: '{{ output_dir }}/test-dnf.conf'
+ register: test_dnf_copy
+
+- block:
+ # begin test case where disable_excludes is supported
+ - name: Try install lsof without disable_excludes
+ dnf: name=lsof state=latest conf_file={{ test_dnf_copy.dest }}
+ register: dnf_lsof_result
+ ignore_errors: True
+
+ - name: verify lsof did not install because it is in exclude list
+ assert:
+ that:
+ - "dnf_lsof_result is failed"
+
+ - name: install lsof with disable_excludes
+ dnf: name=lsof state=latest disable_excludes=all conf_file={{ test_dnf_copy.dest }}
+ register: dnf_lsof_result_using_excludes
+
+ - name: verify lsof did install using disable_excludes=all
+ assert:
+ that:
+ - "dnf_lsof_result_using_excludes is success"
+ - "dnf_lsof_result_using_excludes is changed"
+ - "dnf_lsof_result_using_excludes is not failed"
+ always:
+ - name: remove exclude lsof conf file
+ file:
+ path: '{{ output_dir }}/test-dnf.conf'
+ state: absent
+
+# end test case where disable_excludes is supported
+
+- name: Test "dnf install /usr/bin/vi"
+ block:
+ - name: Clean vim-minimal
+ dnf:
+ name: vim-minimal
+ state: absent
+
+ - name: Install vim-minimal by specifying "/usr/bin/vi"
+ dnf:
+ name: /usr/bin/vi
+ state: present
+
+ - name: Get rpm output
+ command: rpm -q vim-minimal
+ register: rpm_output
+
+ - name: Check installation was successful
+ assert:
+ that:
+ - "'vim-minimal' in rpm_output.stdout"
+ when:
+ - ansible_distribution == 'Fedora'
+
+- name: Remove wildcard package that isn't installed
+ dnf:
+ name: firefox*
+ state: absent
+ register: wildcard_absent
+
+- assert:
+ that:
+ - wildcard_absent is successful
+ - wildcard_absent is not changed
diff --git a/test/integration/targets/dnf/tasks/dnfinstallroot.yml b/test/integration/targets/dnf/tasks/dnfinstallroot.yml
new file mode 100644
index 00000000..b5e09011
--- /dev/null
+++ b/test/integration/targets/dnf/tasks/dnfinstallroot.yml
@@ -0,0 +1,47 @@
+# make a installroot
+- name: Create installroot
+ command: mktemp -d "{{ remote_tmp_dir }}/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:
+ # We need '8' for CentOS, but '8.x' for RHEL.
+ content: "{{ ansible_distribution_version|int if ansible_distribution != 'RedHat' else 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
diff --git a/test/integration/targets/dnf/tasks/dnfreleasever.yml b/test/integration/targets/dnf/tasks/dnfreleasever.yml
new file mode 100644
index 00000000..351a26b1
--- /dev/null
+++ b/test/integration/targets/dnf/tasks/dnfreleasever.yml
@@ -0,0 +1,47 @@
+# make an installroot
+- name: Create installroot
+ command: mktemp -d "{{ remote_tmp_dir }}/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"
+
+- name: attempt releasever to the installroot
+ dnf:
+ name: filesystem
+ installroot: '/{{dnfroot.stdout}}'
+ releasever: '{{ansible_distribution_version|int - 1}}'
+ register: dnf_result
+
+- name: check filesystem version
+ shell: rpm -q filesystem --root="/{{dnfroot.stdout}}/"
+ failed_when: False
+ register: rpm_result
+
+- debug: var=dnf_result
+- debug: var=rpm_result
+
+- name: verify installation was done
+ assert:
+ that:
+ - "not dnf_result.failed | default(False)"
+ - "dnf_result.changed"
+ - "rpm_result.rc == 0"
+
+- name: verify the version
+ assert:
+ that:
+ - "rpm_result.stdout.find('fc' ~ (ansible_distribution_version|int - 1)) != -1"
+
+- name: cleanup installroot
+ file:
+ path: "/{{dnfroot.stdout}}/"
+ state: absent
diff --git a/test/integration/targets/dnf/tasks/filters.yml b/test/integration/targets/dnf/tasks/filters.yml
new file mode 100644
index 00000000..d5e9ee90
--- /dev/null
+++ b/test/integration/targets/dnf/tasks/filters.yml
@@ -0,0 +1,134 @@
+# We have a test repo set up with a valid updateinfo.xml which is referenced
+# from its repomd.xml.
+- block:
+ - set_fact:
+ updateinfo_repo: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/setup_rpm_repo/repo-with-updateinfo
+
+ - name: Install the test repo
+ yum_repository:
+ name: test-repo-with-updateinfo
+ description: test-repo-with-updateinfo
+ baseurl: "{{ updateinfo_repo }}"
+ gpgcheck: no
+
+ - name: Install old versions of toaster and oven
+ dnf:
+ name:
+ - "{{ updateinfo_repo }}/toaster-1.2.3.4-1.el8.noarch.rpm"
+ - "{{ updateinfo_repo }}/oven-1.2.3.4-1.el8.noarch.rpm"
+ disable_gpg_check: true
+
+ - name: Ask for pending updates
+ dnf:
+ name: '*'
+ state: latest
+ update_only: true
+ disable_gpg_check: true
+ disablerepo: '*'
+ enablerepo: test-repo-with-updateinfo
+ register: update_no_filter
+
+ - assert:
+ that:
+ - update_no_filter is changed
+ - '"Installed: toaster-1.2.3.5-1.el8.noarch" in update_no_filter.results'
+ - '"Installed: oven-1.2.3.5-1.el8.noarch" in update_no_filter.results'
+ - '"Removed: toaster-1.2.3.4-1.el8.noarch" in update_no_filter.results'
+ - '"Removed: oven-1.2.3.4-1.el8.noarch" in update_no_filter.results'
+
+ - name: Install old versions of toaster and oven
+ dnf:
+ name:
+ - "{{ updateinfo_repo }}/toaster-1.2.3.4-1.el8.noarch.rpm"
+ - "{{ updateinfo_repo }}/oven-1.2.3.4-1.el8.noarch.rpm"
+ allow_downgrade: true
+ disable_gpg_check: true
+
+ - name: Ask for pending updates with security=true
+ dnf:
+ name: '*'
+ state: latest
+ update_only: true
+ disable_gpg_check: true
+ security: true
+ disablerepo: '*'
+ enablerepo: test-repo-with-updateinfo
+ register: update_security
+
+ - assert:
+ that:
+ - update_security is changed
+ - '"Installed: toaster-1.2.3.5-1.el8.noarch" in update_security.results'
+ - '"Removed: toaster-1.2.3.4-1.el8.noarch" in update_security.results'
+ - '"Installed: oven-1.2.3.5-1.el8.noarch" not in update_security.results'
+ - '"Removed: oven-1.2.3.4-1.el8.noarch" not in update_security.results'
+
+ - name: Install old versions of toaster and oven
+ dnf:
+ name:
+ - "{{ updateinfo_repo }}/toaster-1.2.3.4-1.el8.noarch.rpm"
+ - "{{ updateinfo_repo }}/oven-1.2.3.4-1.el8.noarch.rpm"
+ allow_downgrade: true
+ disable_gpg_check: true
+
+ - name: Ask for pending updates with bugfix=true
+ dnf:
+ name: '*'
+ state: latest
+ update_only: true
+ disable_gpg_check: true
+ bugfix: true
+ disablerepo: '*'
+ enablerepo: test-repo-with-updateinfo
+ register: update_bugfix
+
+ - assert:
+ that:
+ - update_bugfix is changed
+ - '"Installed: toaster-1.2.3.5-1.el8.noarch" not in update_bugfix.results'
+ - '"Removed: toaster-1.2.3.4-1.el8.noarch" not in update_bugfix.results'
+ - '"Installed: oven-1.2.3.5-1.el8.noarch" in update_bugfix.results'
+ - '"Removed: oven-1.2.3.4-1.el8.noarch" in update_bugfix.results'
+
+ - name: Install old versions of toaster and oven
+ dnf:
+ name:
+ - "{{ updateinfo_repo }}/toaster-1.2.3.4-1.el8.noarch.rpm"
+ - "{{ updateinfo_repo }}/oven-1.2.3.4-1.el8.noarch.rpm"
+ allow_downgrade: true
+ disable_gpg_check: true
+
+ - name: Ask for pending updates with bugfix=true and security=true
+ dnf:
+ name: '*'
+ state: latest
+ update_only: true
+ disable_gpg_check: true
+ bugfix: true
+ security: true
+ disablerepo: '*'
+ enablerepo: test-repo-with-updateinfo
+ register: update_bugfix
+
+ - assert:
+ that:
+ - update_bugfix is changed
+ - '"Installed: toaster-1.2.3.5-1.el8.noarch" in update_bugfix.results'
+ - '"Removed: toaster-1.2.3.4-1.el8.noarch" in update_bugfix.results'
+ - '"Installed: oven-1.2.3.5-1.el8.noarch" in update_bugfix.results'
+ - '"Removed: oven-1.2.3.4-1.el8.noarch" in update_bugfix.results'
+
+ always:
+ - name: Remove installed packages
+ dnf:
+ name:
+ - toaster
+ - oven
+ state: absent
+
+ - name: Remove the repo
+ yum_repository:
+ name: test-repo-with-updateinfo
+ state: absent
+ tags:
+ - filters
diff --git a/test/integration/targets/dnf/tasks/filters_check_mode.yml b/test/integration/targets/dnf/tasks/filters_check_mode.yml
new file mode 100644
index 00000000..024ac066
--- /dev/null
+++ b/test/integration/targets/dnf/tasks/filters_check_mode.yml
@@ -0,0 +1,118 @@
+# We have a test repo set up with a valid updateinfo.xml which is referenced
+# from its repomd.xml.
+- block:
+ - set_fact:
+ updateinfo_repo: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/setup_rpm_repo/repo-with-updateinfo
+
+ - name: Install the test repo
+ yum_repository:
+ name: test-repo-with-updateinfo
+ description: test-repo-with-updateinfo
+ baseurl: "{{ updateinfo_repo }}"
+ gpgcheck: no
+
+ - name: Install old versions of toaster and oven
+ dnf:
+ name:
+ - "{{ updateinfo_repo }}/toaster-1.2.3.4-1.el8.noarch.rpm"
+ - "{{ updateinfo_repo }}/oven-1.2.3.4-1.el8.noarch.rpm"
+ disable_gpg_check: true
+
+ - name: Ask for pending updates (check_mode)
+ dnf:
+ name:
+ - toaster
+ - oven
+ state: latest
+ update_only: true
+ disable_gpg_check: true
+ check_mode: true
+ register: update_no_filter
+
+ - assert:
+ that:
+ - update_no_filter is changed
+ - '"would have if not in check mode" in update_no_filter.msg'
+ - '"Installed: toaster-1.2.3.5-1.el8.noarch" in update_no_filter.results'
+ - '"Installed: oven-1.2.3.5-1.el8.noarch" in update_no_filter.results'
+ - '"Removed: toaster-1.2.3.4-1.el8.noarch" in update_no_filter.results'
+ - '"Removed: oven-1.2.3.4-1.el8.noarch" in update_no_filter.results'
+
+ - name: Ask for pending updates with security=true (check_mode)
+ dnf:
+ name:
+ - toaster
+ - oven
+ state: latest
+ update_only: true
+ disable_gpg_check: true
+ security: true
+ check_mode: true
+ register: update_security
+
+ - assert:
+ that:
+ - update_security is changed
+ - '"would have if not in check mode" in update_security.msg'
+ - '"Installed: toaster-1.2.3.5-1.el8.noarch" in update_security.results'
+ - '"Removed: toaster-1.2.3.4-1.el8.noarch" in update_security.results'
+ - '"Installed: oven-1.2.3.5-1.el8.noarch" not in update_security.results'
+ - '"Removed: oven-1.2.3.4-1.el8.noarch" not in update_security.results'
+
+ - name: Ask for pending updates with bugfix=true (check_mode)
+ dnf:
+ name:
+ - toaster
+ - oven
+ state: latest
+ update_only: true
+ disable_gpg_check: true
+ bugfix: true
+ check_mode: true
+ register: update_bugfix
+
+ - assert:
+ that:
+ - update_bugfix is changed
+ - '"would have if not in check mode" in update_bugfix.msg'
+ - '"Installed: toaster-1.2.3.5-1.el8.noarch" not in update_bugfix.results'
+ - '"Removed: toaster-1.2.3.4-1.el8.noarch" not in update_bugfix.results'
+ - '"Installed: oven-1.2.3.5-1.el8.noarch" in update_bugfix.results'
+ - '"Removed: oven-1.2.3.4-1.el8.noarch" in update_bugfix.results'
+
+ - name: Ask for pending updates with bugfix=true and security=true (check_mode)
+ dnf:
+ name:
+ - toaster
+ - oven
+ state: latest
+ update_only: true
+ disable_gpg_check: true
+ bugfix: true
+ security: true
+ check_mode: true
+ register: update_bugfix
+
+ - assert:
+ that:
+ - update_bugfix is changed
+ - '"would have if not in check mode" in update_bugfix.msg'
+ - '"Installed: toaster-1.2.3.5-1.el8.noarch" in update_bugfix.results'
+ - '"Removed: toaster-1.2.3.4-1.el8.noarch" in update_bugfix.results'
+ - '"Installed: oven-1.2.3.5-1.el8.noarch" in update_bugfix.results'
+ - '"Removed: oven-1.2.3.4-1.el8.noarch" in update_bugfix.results'
+
+ always:
+ - name: Remove installed packages
+ dnf:
+ name:
+ - toaster
+ - oven
+ state: absent
+
+ - name: Remove the repo
+ yum_repository:
+ name: test-repo-with-updateinfo
+ state: absent
+ tags:
+ - filters
diff --git a/test/integration/targets/dnf/tasks/gpg.yml b/test/integration/targets/dnf/tasks/gpg.yml
new file mode 100644
index 00000000..2b6f4079
--- /dev/null
+++ b/test/integration/targets/dnf/tasks/gpg.yml
@@ -0,0 +1,72 @@
+# Set up a repo of unsigned rpms
+- block:
+ - name: Ensure our test package isn't already installed
+ dnf:
+ name:
+ - fpaste
+ state: absent
+
+ - name: Install rpm-sign
+ dnf:
+ name:
+ - rpm-sign
+ state: present
+
+ - name: Create directory to use as local repo
+ file:
+ path: "{{ remote_tmp_dir }}/unsigned"
+ state: directory
+
+ - name: Download an RPM
+ get_url:
+ url: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/dnf/fpaste-0.3.9.1-1.fc27.noarch.rpm
+ dest: "{{ remote_tmp_dir }}/unsigned/fpaste-0.3.9.1-1.fc27.noarch.rpm"
+ mode: 0644
+
+ - name: Unsign the RPM
+ command: rpmsign --delsign "{{ remote_tmp_dir }}/unsigned/fpaste-0.3.9.1-1.fc27.noarch.rpm"
+
+ - name: createrepo
+ command: createrepo .
+ args:
+ chdir: "{{ remote_tmp_dir }}/unsigned"
+
+ - name: Add the repo
+ yum_repository:
+ name: unsigned
+ description: unsigned rpms
+ baseurl: "file://{{ remote_tmp_dir }}/unsigned/"
+ # we want to ensure that signing is verified
+ gpgcheck: true
+
+ - name: Install fpaste from above
+ dnf:
+ name:
+ - fpaste
+ disablerepo: '*'
+ enablerepo: unsigned
+ register: res
+ ignore_errors: yes
+
+ - assert:
+ that:
+ - res is failed
+ - "'Failed to validate GPG signature' in res.msg"
+
+ always:
+ - name: Remove rpm-sign (and fpaste if it got installed)
+ dnf:
+ name:
+ - rpm-sign
+ - fpaste
+ state: absent
+
+ - name: Remove test repo
+ yum_repository:
+ name: unsigned
+ state: absent
+
+ - name: Remove repo dir
+ file:
+ path: "{{ remote_tmp_dir }}/unsigned"
+ state: absent
diff --git a/test/integration/targets/dnf/tasks/logging.yml b/test/integration/targets/dnf/tasks/logging.yml
new file mode 100644
index 00000000..903bf563
--- /dev/null
+++ b/test/integration/targets/dnf/tasks/logging.yml
@@ -0,0 +1,48 @@
+# Verify logging function is enabled in the dnf module.
+# The following tasks has been supported in dnf-4.2.17-6 or later
+# Note: https://bugzilla.redhat.com/show_bug.cgi?id=1788212
+- name: Install latest version python3-dnf
+ dnf:
+ name:
+ - python3-dnf
+ - python3-libdnf # https://bugzilla.redhat.com/show_bug.cgi?id=1887502
+ - libmodulemd # https://bugzilla.redhat.com/show_bug.cgi?id=1942236
+ state: latest
+ register: dnf_result
+
+- name: Verify python3-dnf installed
+ assert:
+ that:
+ - "dnf_result.rc == 0"
+
+- name: Get python3-dnf version
+ shell: "dnf info python3-dnf | awk '/^Version/ { print $3 }'"
+ register: py3_dnf_version
+
+- name: Check logging enabled
+ block:
+ - name: remove logfiles if exist
+ file:
+ path: "{{ item }}"
+ state: absent
+ loop: "{{ dnf_log_files }}"
+
+ - name: Install sos package
+ dnf:
+ name: sos
+ state: present
+ register: dnf_result
+
+ - name: Get status of logfiles
+ stat:
+ path: "{{ item }}"
+ loop: "{{ dnf_log_files }}"
+ register: stats
+
+ - name: Verify logfile exists
+ assert:
+ that:
+ - "item.stat.exists"
+ loop: "{{ stats.results }}"
+ when:
+ - 'py3_dnf_version.stdout is version("4.2.17", ">=")'
diff --git a/test/integration/targets/dnf/tasks/main.yml b/test/integration/targets/dnf/tasks/main.yml
new file mode 100644
index 00000000..1b6e0941
--- /dev/null
+++ b/test/integration/targets/dnf/tasks/main.yml
@@ -0,0 +1,62 @@
+# test code for the dnf module
+# (c) 2014, James Tanner <tanner.jc@gmail.com>
+
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+# 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_tasks: dnf.yml
+ when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
+ (ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
+
+- include_tasks: filters_check_mode.yml
+ when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
+ (ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
+ tags:
+ - filters
+
+- include_tasks: filters.yml
+ when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
+ (ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
+ tags:
+ - filters
+
+- include_tasks: gpg.yml
+ when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
+ (ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
+
+- include_tasks: repo.yml
+ when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
+ (ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
+
+- include_tasks: dnfinstallroot.yml
+ when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
+ (ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
+
+# Attempting to install a different RHEL release in a tmpdir doesn't work (rhel8 beta)
+- include_tasks: dnfreleasever.yml
+ when:
+ - ansible_distribution == 'Fedora'
+ - ansible_distribution_major_version is version('23', '>=')
+
+- include_tasks: modularity.yml
+ when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('29', '>=')) or
+ (ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
+
+- include_tasks: logging.yml
+ when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('31', '>=')) or
+ (ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
diff --git a/test/integration/targets/dnf/tasks/modularity.yml b/test/integration/targets/dnf/tasks/modularity.yml
new file mode 100644
index 00000000..48a0111a
--- /dev/null
+++ b/test/integration/targets/dnf/tasks/modularity.yml
@@ -0,0 +1,99 @@
+# FUTURE - look at including AppStream support in our local repo
+- name: Include distribution specific variables
+ include_vars: "{{ ansible_facts.distribution }}.yml"
+
+- name: install "{{ astream_name }}" module
+ dnf:
+ name: "{{ astream_name }}"
+ state: present
+ register: dnf_result
+
+- name: verify installation of "{{ astream_name }}" module
+ assert:
+ that:
+ - "not dnf_result.failed"
+ - "dnf_result.changed"
+
+- name: install "{{ astream_name }}" module again
+ dnf:
+ name: "{{ astream_name }}"
+ state: present
+ register: dnf_result
+
+- name: verify installation of "{{ astream_name }}" module again
+ assert:
+ that:
+ - "not dnf_result.failed"
+ - "not dnf_result.changed"
+
+- name: uninstall "{{ astream_name }}" module
+ dnf:
+ name: "{{ astream_name }}"
+ state: absent
+ register: dnf_result
+
+- name: verify uninstallation of "{{ astream_name }}" module
+ assert:
+ that:
+ - "not dnf_result.failed"
+ - "dnf_result.changed"
+
+- name: uninstall "{{ astream_name }}" module again
+ dnf:
+ name: "{{ astream_name }}"
+ state: absent
+ register: dnf_result
+
+- name: verify uninstallation of "{{ astream_name }}" module again
+ assert:
+ that:
+ - "not dnf_result.failed"
+ - "not dnf_result.changed"
+
+- name: install "{{ astream_name_no_stream }}" module without providing stream
+ dnf:
+ name: "{{ astream_name_no_stream }}"
+ state: present
+ register: dnf_result
+
+- name: verify installation of "{{ astream_name_no_stream }}" module without providing stream
+ assert:
+ that:
+ - "not dnf_result.failed"
+ - "dnf_result.changed"
+
+- name: install "{{ astream_name_no_stream }}" module again without providing stream
+ dnf:
+ name: "{{ astream_name_no_stream }}"
+ state: present
+ register: dnf_result
+
+- name: verify installation of "{{ astream_name_no_stream }}" module again without providing stream
+ assert:
+ that:
+ - "not dnf_result.failed"
+ - "not dnf_result.changed"
+
+- name: uninstall "{{ astream_name_no_stream }}" module without providing stream
+ dnf:
+ name: "{{ astream_name_no_stream }}"
+ state: absent
+ register: dnf_result
+
+- name: verify uninstallation of "{{ astream_name_no_stream }}" module without providing stream
+ assert:
+ that:
+ - "not dnf_result.failed"
+ - "dnf_result.changed"
+
+- name: uninstall "{{ astream_name_no_stream }}" module again without providing stream
+ dnf:
+ name: "{{ astream_name_no_stream }}"
+ state: absent
+ register: dnf_result
+
+- name: verify uninstallation of "{{ astream_name_no_stream }}" module again without providing stream
+ assert:
+ that:
+ - "not dnf_result.failed"
+ - "not dnf_result.changed"
diff --git a/test/integration/targets/dnf/tasks/repo.yml b/test/integration/targets/dnf/tasks/repo.yml
new file mode 100644
index 00000000..4f82899c
--- /dev/null
+++ b/test/integration/targets/dnf/tasks/repo.yml
@@ -0,0 +1,309 @@
+- block:
+ - name: Install dinginessentail-1.0-1
+ dnf:
+ name: dinginessentail-1.0-1
+ state: present
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ - "dnf_result.changed"
+ - "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
+
+ - name: Verify dnf module outputs
+ assert:
+ that:
+ - "'results' in dnf_result"
+ # ============================================================================
+ - name: Install dinginessentail-1.0-1 again
+ dnf:
+ name: dinginessentail-1.0-1
+ state: present
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ - "not dnf_result.changed"
+ - "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
+
+ - name: Verify dnf module outputs
+ assert:
+ that:
+ - "'msg' in dnf_result"
+ # ============================================================================
+ - name: Install dinginessentail again (noop, module is idempotent)
+ dnf:
+ name: dinginessentail
+ state: present
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ # No upgrade happened to 1.1.1
+ - "not dnf_result.changed"
+ # Old version still installed
+ - "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
+ # ============================================================================
+ - name: Install dinginessentail-1:1.0-2
+ dnf:
+ name: "dinginessentail-1:1.0-2.{{ ansible_architecture }}"
+ state: present
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ - "dnf_result.changed"
+ - "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
+
+ - name: Verify dnf module outputs
+ assert:
+ that:
+ - "'results' in dnf_result"
+ # ============================================================================
+ - name: Update to the latest dinginessentail
+ dnf:
+ name: dinginessentail
+ state: latest
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ - "dnf_result.changed"
+ - "rpm_result.stdout.startswith('dinginessentail-1.1-1')"
+
+ - name: Verify dnf module outputs
+ assert:
+ that:
+ - "'results' in dnf_result"
+ # ============================================================================
+ - name: Install dinginessentail-1.0-1 from a file (downgrade)
+ dnf:
+ name: "{{ repodir }}/dinginessentail-1.0-1.{{ ansible_architecture }}.rpm"
+ state: present
+ allow_downgrade: True
+ disable_gpg_check: True
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ - "dnf_result.changed"
+ - "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
+
+ - name: Verify dnf module outputs
+ assert:
+ that:
+ - "'results' in dnf_result"
+
+ - name: Remove dinginessentail
+ dnf:
+ name: dinginessentail
+ state: absent
+ # ============================================================================
+ - name: Install dinginessentail-1.0-1 from a file
+ dnf:
+ name: "{{ repodir }}/dinginessentail-1.0-1.{{ ansible_architecture }}.rpm"
+ state: present
+ disable_gpg_check: True
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ - "dnf_result.changed"
+ - "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
+
+ - name: Verify dnf module outputs
+ assert:
+ that:
+ - "'results' in dnf_result"
+ # ============================================================================
+ - name: Install dinginessentail-1.0-1 from a file again
+ dnf:
+ name: "{{ repodir }}/dinginessentail-1.0-1.{{ ansible_architecture }}.rpm"
+ state: present
+ disable_gpg_check: True
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ - "not dnf_result.changed"
+ - "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
+ # ============================================================================
+ - name: Install dinginessentail-1.0-2 from a file
+ dnf:
+ name: "{{ repodir }}/dinginessentail-1.0-2.{{ ansible_architecture }}.rpm"
+ state: present
+ disable_gpg_check: True
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ - "dnf_result.changed"
+ - "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
+
+ - name: Verify dnf module outputs
+ assert:
+ that:
+ - "'results' in dnf_result"
+ # ============================================================================
+ - name: Install dinginessentail-1.0-2 from a file again
+ dnf:
+ name: "{{ repodir }}/dinginessentail-1.0-2.{{ ansible_architecture }}.rpm"
+ state: present
+ disable_gpg_check: True
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ - "not dnf_result.changed"
+ - "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
+ # ============================================================================
+ - name: Remove dinginessentail
+ dnf:
+ name: dinginessentail
+ state: absent
+
+ - name: Try to install incompatible arch
+ dnf:
+ name: "{{ repodir_ppc64 }}/dinginessentail-1.0-1.ppc64.rpm"
+ state: present
+ register: dnf_result
+ ignore_errors: yes
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+ ignore_errors: yes
+
+ - name: Verify installation
+ assert:
+ that:
+ - "rpm_result.rc == 1"
+ - "not dnf_result.changed"
+ - "dnf_result is failed"
+ # ============================================================================
+
+ # Should install dinginessentail-with-weak-dep and dinginessentail-weak-dep
+ - name: Install package with defaults
+ dnf:
+ name: dinginessentail-with-weak-dep
+ state: present
+
+ - name: Check if dinginessentail-with-weak-dep is installed
+ shell: rpm -q dinginessentail-with-weak-dep
+ register: rpm_main_result
+
+ - name: Check if dinginessentail-weak-dep is installed
+ shell: rpm -q dinginessentail-weak-dep
+ register: rpm_weak_result
+
+ - name: Verify install with weak deps
+ assert:
+ that:
+ - rpm_main_result.rc == 0
+ - rpm_weak_result.rc == 0
+
+ - name: Uninstall dinginessentail weak dep packages
+ dnf:
+ name:
+ - dinginessentail-with-weak-dep
+ - dinginessentail-weak-dep
+ state: absent
+
+ - name: Install package with weak deps but skip weak deps
+ dnf:
+ name: dinginessentail-with-weak-dep
+ install_weak_deps: False
+ state: present
+
+ - name: Check if dinginessentail-with-weak-dep is installed
+ shell: rpm -q dinginessentail-with-weak-dep
+ register: rpm_main_result
+
+ - name: Check if dinginessentail-weak-dep is installed
+ shell: rpm -q dinginessentail-weak-dep
+ register: rpm_weak_result
+ ignore_errors: yes
+
+ - name: Verify install without weak deps
+ assert:
+ that:
+ - rpm_main_result.rc == 0
+ - rpm_weak_result.rc == 1 # the weak dependency shouldn't be installed
+
+ # https://github.com/ansible/ansible/issues/55938
+ - name: Install dinginessentail-*
+ dnf:
+ name: dinginessentail-*
+ state: present
+
+ - name: Uninstall dinginessentail-*
+ dnf:
+ name: dinginessentail-*
+ state: absent
+
+ - name: Check if all dinginessentail packages are removed
+ shell: rpm -qa dinginessentail-* | wc -l
+ register: rpm_result
+
+ - name: Verify rpm result
+ assert:
+ that:
+ - rpm_result.stdout == '0'
+ always:
+ - name: Clean up
+ dnf:
+ name:
+ - dinginessentail
+ - dinginessentail-with-weak-dep
+ - dinginessentail-weak-dep
+ state: absent
diff --git a/test/integration/targets/dnf/vars/CentOS.yml b/test/integration/targets/dnf/vars/CentOS.yml
new file mode 100644
index 00000000..c70d8538
--- /dev/null
+++ b/test/integration/targets/dnf/vars/CentOS.yml
@@ -0,0 +1,2 @@
+astream_name: '@php:7.2/minimal'
+astream_name_no_stream: '@php/minimal'
diff --git a/test/integration/targets/dnf/vars/Fedora.yml b/test/integration/targets/dnf/vars/Fedora.yml
new file mode 100644
index 00000000..6e0a798c
--- /dev/null
+++ b/test/integration/targets/dnf/vars/Fedora.yml
@@ -0,0 +1,6 @@
+astream_name: '@hub:pre-release/default'
+
+# For this to work, it needs to be that only shows once in `dnf module list`.
+# Such packages, that exist on all the versions we test on, are hard to come by.
+# TODO: This would be solved by using our own repo with modularity/streams.
+astream_name_no_stream: '@hub/default'
diff --git a/test/integration/targets/dnf/vars/RedHat.yml b/test/integration/targets/dnf/vars/RedHat.yml
new file mode 100644
index 00000000..c70d8538
--- /dev/null
+++ b/test/integration/targets/dnf/vars/RedHat.yml
@@ -0,0 +1,2 @@
+astream_name: '@php:7.2/minimal'
+astream_name_no_stream: '@php/minimal'
diff --git a/test/integration/targets/dnf/vars/main.yml b/test/integration/targets/dnf/vars/main.yml
new file mode 100644
index 00000000..86588de3
--- /dev/null
+++ b/test/integration/targets/dnf/vars/main.yml
@@ -0,0 +1,4 @@
+dnf_log_files:
+ - /var/log/dnf.log
+ - /var/log/dnf.rpm.log
+ - /var/log/dnf.librepo.log