diff --git a/tmt/steps/prepare/feature.py b/tmt/steps/prepare/feature.py index f96357bd82..76eae3589b 100644 --- a/tmt/steps/prepare/feature.py +++ b/tmt/steps/prepare/feature.py @@ -15,7 +15,7 @@ class Feature(tmt.utils.Common): - """ Base class for feature implementations """ + """ Base class for ``feature`` prepare plugin implementations """ NAME: str @@ -41,6 +41,7 @@ def _find_playbook(self, filename: str) -> Optional[Path]: class ToggleableFeature(Feature): def get_root_path(self) -> Path: + """ Get the root path for getting the path of a playbook""" assert self.parent is not None # narrow type assert self.parent.parent is not None # narrow type assert self.parent.parent.parent is not None # narrow type @@ -53,8 +54,8 @@ def get_root_path(self) -> Path: def _run_playbook(self, op: str, playbook_filename: str) -> None: playbook_path = self._find_playbook(playbook_filename) if not playbook_path: - self.warn(f'{op.capitalize()} {self.NAME.upper()} is not supported on this guest.') - return + raise tmt.utils.GeneralError( + f"{op.capitalize()} {self.NAME.upper()} is not supported on this guest.") self.info(f'{op.capitalize()} {self.NAME.upper()}') self.guest.ansible(playbook_path.relative_to(self.get_root_path())) @@ -100,7 +101,7 @@ class PrepareFeatureData(tmt.steps.prepare.PrepareStepData): @tmt.steps.provides_method('feature') class PrepareFeature(tmt.steps.prepare.PreparePlugin[PrepareFeatureData]): """ - Enable or disable common feature `epel` on the guest + Enable or disable common feature ``epel`` on the guest Example config: diff --git a/tmt/steps/prepare/feature/epel-disable.yaml b/tmt/steps/prepare/feature/epel-disable.yaml index 322fe2157b..7521a05e45 100644 --- a/tmt/steps/prepare/feature/epel-disable.yaml +++ b/tmt/steps/prepare/feature/epel-disable.yaml @@ -1,5 +1,4 @@ - hosts: all - user: root tasks: # RHEL 7 or CentOS 7 - when: ansible_distribution_major_version|int == 7 @@ -14,12 +13,10 @@ command: rpm -q epel-release register: result ignore_errors: True + - name: Disable repos of 'epel' shell: yum-config-manager --disable epel epel-debuginfo epel-source when: result.rc == 0 - - name: Fetch attribute 'enabled' of repos of 'epel' - shell: grep enabled /etc/yum.repos.d/epel.repo - when: result.rc == 0 # RHEL N or CentOS Stream N where N >= 8 - when: ansible_distribution_major_version|int >= 8 @@ -32,21 +29,17 @@ command: rpm -q epel-release register: result ignore_errors: True + - name: Disable repos of 'epel' if package 'epel-release' is installed shell: dnf config-manager --disable epel epel-debuginfo epel-source when: result.rc == 0 - - name: Fetch attribute 'enabled' of repos of 'epel' - shell: grep enabled /etc/yum.repos.d/epel.repo - when: result.rc == 0 # Disable repos of 'epel-next' if package 'epel-next-release' is installed - name: Detect package 'epel-next-release' is installed command: rpm -q epel-next-release register: result ignore_errors: True + - name: Disable repos of 'epel-next' shell: dnf config-manager --disable epel-next epel-next-debuginfo epel-next-source when: result.rc == 0 - - name: Fetch attribute 'enabled' of repos of 'epel-next' - shell: grep enabled /etc/yum.repos.d/epel-next.repo - when: result.rc == 0 diff --git a/tmt/steps/prepare/feature/epel-enable.yaml b/tmt/steps/prepare/feature/epel-enable.yaml index 654089b91e..26fba44f29 100644 --- a/tmt/steps/prepare/feature/epel-enable.yaml +++ b/tmt/steps/prepare/feature/epel-enable.yaml @@ -1,5 +1,4 @@ - hosts: all - user: root tasks: # RHEL 7 - when: ansible_distribution == 'RedHat' and ansible_distribution_major_version|int == 7 @@ -17,8 +16,6 @@ - name: Enable repos of 'epel' shell: yum-config-manager --enable epel epel-debuginfo epel-source - - name: Fetch attribute 'enabled' of repos of 'epel' - shell: grep enabled /etc/yum.repos.d/epel.repo # RHEL N, where N >= 8 - when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int >= 8 @@ -40,13 +37,9 @@ - name: Enable repos of 'epel' shell: dnf config-manager --enable epel epel-debuginfo epel-source - - name: Fetch attribute 'enabled' of repos of 'epel' - shell: grep enabled /etc/yum.repos.d/epel.repo - name: Enable repos of 'epel-next' shell: dnf config-manager --enable epel-next epel-next-debuginfo epel-next-source - - name: Fetch attribute 'enabled' of repos of 'epel-next' - shell: grep enabled /etc/yum.repos.d/epel-next.repo # CentOS 7 - when: ansible_distribution == "CentOS" and ansible_distribution_major_version|int == 7 @@ -63,8 +56,6 @@ - name: Enable repos of 'epel' shell: yum-config-manager --enable epel epel-debuginfo epel-source - - name: Fetch attribute 'enabled' of repos of 'epel' - shell: grep enabled /etc/yum.repos.d/epel.repo # CentOS Stream N where N >= 8 - when: ansible_distribution == "CentOS" and ansible_distribution_major_version|int >= 8 @@ -84,10 +75,6 @@ - name: Enable repos of 'epel' shell: dnf config-manager --enable epel epel-debuginfo epel-source - - name: Fetch attribute 'enabled' of repos of 'epel' - shell: grep enabled /etc/yum.repos.d/epel.repo - name: Enable repos of 'epel-next' shell: dnf config-manager --enable epel-next epel-next-debuginfo epel-next-source - - name: Fetch attribute 'enabled' of repos of 'epel-next' - shell: grep enabled /etc/yum.repos.d/epel-next.repo