diff --git a/pytest_fixtures/core/sat_cap_factory.py b/pytest_fixtures/core/sat_cap_factory.py index 0c23b1ee4d2..3cfebdee160 100644 --- a/pytest_fixtures/core/sat_cap_factory.py +++ b/pytest_fixtures/core/sat_cap_factory.py @@ -250,6 +250,18 @@ def module_lb_capsule(retry_limit=3, delay=300, **broker_args): Broker(hosts=cap_hosts.out).checkin() +@pytest.fixture(scope='module') +def module_capsule_configured_ansible(module_capsule_configured): + """Configure the capsule instance with Ansible feature enabled""" + result = module_capsule_configured.install( + cmd_args=[ + 'enable-foreman-proxy-plugin-ansible', + ] + ) + assert result.status == 0, 'Installer failed to enable ansible plugin.' + return module_capsule_configured + + @pytest.fixture(scope='module') def module_capsule_configured_async_ssh(module_capsule_configured): """Configure the capsule instance with the satellite from settings.server.hostname, diff --git a/robottelo/hosts.py b/robottelo/hosts.py index a5d5e2319f7..a8ed9858479 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -1597,7 +1597,8 @@ def install(self, installer_obj=None, cmd_args=None, cmd_kwargs=None): """General purpose installer""" if not installer_obj: command_opts = {'scenario': self.__class__.__name__.lower()} - command_opts.update(cmd_kwargs) + if cmd_kwargs: + command_opts.update(cmd_kwargs) installer_obj = InstallerCommand(*cmd_args, **command_opts) return self.execute(installer_obj.get_command(), timeout=0) diff --git a/tests/foreman/installer/test_installer.py b/tests/foreman/installer/test_installer.py index da64593642e..f57647f23b8 100644 --- a/tests/foreman/installer/test_installer.py +++ b/tests/foreman/installer/test_installer.py @@ -1777,6 +1777,37 @@ def test_installer_cap_pub_directory_accessibility(capsule_configured): assert 'Success!' in command_output.stdout +def test_installer_capsule_with_enabled_ansible(module_capsule_configured_ansible): + """Enables Ansible feature on external Capsule and checks the callback is set correctly + + :id: d60c475e-f4e7-11ee-af8a-98fa9b11ac24 + + :steps: + 1. Have a Satellite with external Capsule integrated + 2. Enable Ansible feature on external Capsule + 3. Check the ansible callback plugin on external Capsule + + :expectedresults: + Ansible callback plugin is overridden to "redhat.satellite.foreman" + + :CaseImportance: High + + :BZ: 2245081 + + :customerscenario: true + """ + ansible_env = '/etc/foreman-proxy/ansible.env' + downstream_callback = 'redhat.satellite.foreman' + callback_whitelist = module_capsule_configured_ansible.execute( + f"awk -F= '/ANSIBLE_CALLBACK_WHITELIST/{{print$2}}' {ansible_env}" + ) + assert callback_whitelist.stdout.strip('" \n') == downstream_callback + callbacks_enabled = module_capsule_configured_ansible.execute( + f"awk -F= '/ANSIBLE_CALLBACKS_ENABLED/{{print$2}}' {ansible_env}" + ) + assert callbacks_enabled.stdout.strip('" \n') == downstream_callback + + @pytest.mark.tier1 @pytest.mark.build_sanity @pytest.mark.first_sanity