diff --git a/defaults/main.yml b/defaults/main.yml index 401f4eb..d2ad4b1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -24,9 +24,15 @@ packages_deltarpm_percentage: 75 packages_upgrade_enabled: False -packages_packages_enablerepo: [] +packages_enablerepo: [] packages_install: [] packages_install_extra: [] -packages_uninstall: [] +packages_uninstall: + - setroubleshoot + - mcstransd + - xinetd + - ypbind + - telnet +packages_uninstall_extra: [] diff --git a/molecule/rocky8/tests/test_default.py b/molecule/rocky8/tests/test_default.py index 18236da..c979870 100644 --- a/molecule/rocky8/tests/test_default.py +++ b/molecule/rocky8/tests/test_default.py @@ -1,7 +1,13 @@ import os +import pytest import testinfra.utils.ansible_runner testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( os.environ["MOLECULE_INVENTORY_FILE"] ).get_hosts("all") + + +@pytest.mark.parametrize("package", ["setroubleshoot", "mcstransd", "xinetd", "ypbind", "telnet"]) +def test_packages_uninstalled(host, package): + assert not host.package(package).is_installed diff --git a/tasks/repository.yml b/tasks/repository.yml index 8c27351..6867d9e 100644 --- a/tasks/repository.yml +++ b/tasks/repository.yml @@ -1,6 +1,14 @@ --- - block: - - name: Add common package repositories + - name: Remove repositories + file: + name: "/etc/packages.repos.d/{{ item }}" + state: absent + loop: "{{ packages_repofiles_remove }}" + loop_control: + label: "/etc/packages.repos.d/{{ item }}" + + - name: Add common repositories yum_repository: name: "{{ item.name }}" file: "{{ item.filename }}" @@ -16,25 +24,17 @@ label: "{{ item.name }}" notify: __packages_upgrade - - name: Remove repo files - file: - name: "/etc/packages.repos.d/{{ item }}" - state: absent - loop: "{{ packages_repofiles_remove }}" - loop_control: - label: "/etc/packages.repos.d/{{ item }}" - - - name: Uninstall common packages + - name: Uninstall packages package: name: "{{ item }}" - enablerepo: "{{ packages_packages_enablerepo }}" + enablerepo: "{{ packages_enablerepo }}" state: absent - loop: "{{ packages_uninstall }}" + loop: "{{ packages_uninstall + packages_uninstall_extra }}" - name: Install common packages package: name: "{{ item }}" - enablerepo: "{{ packages_packages_enablerepo }}" + enablerepo: "{{ packages_enablerepo }}" state: present loop: "{{ packages_install + packages_install_extra }}" become: True