From 04a196488128f6aa6fbc3af42c5a48f9b0af48af Mon Sep 17 00:00:00 2001 From: Gaurav Talreja Date: Tue, 7 Jul 2026 13:54:41 +0530 Subject: [PATCH] Fix host_conf to resolve post_configs from content_host settings (#22065) host_conf() was reading post_configs from request.param (never set by fixture_markers), instead of the version's YAML config, so FIPS variants like rhel7_fips never ran their enable-fips post-deploy action. Track applied post-configs on host object via _post_deploy_config attribute Also fixes a dict aliasing issue (conf = params = {}), and migrates rhel_contenthost_with_repos and module_flatpak_contenthost to use contenthost_factory so all content host fixtures consistently handle post_configs. Signed-off-by: Gaurav Talreja (cherry picked from commit 497bf6bb31f5818d2a7eba40c6f97596475fd61e) --- pytest_fixtures/core/contenthosts.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pytest_fixtures/core/contenthosts.py b/pytest_fixtures/core/contenthosts.py index 27de1ed8c6c..b7915a44bbb 100644 --- a/pytest_fixtures/core/contenthosts.py +++ b/pytest_fixtures/core/contenthosts.py @@ -18,13 +18,16 @@ def host_conf(request): """A function that returns arguments for Broker host deployment""" - conf = params = {} + params = {} if hasattr(request, 'param'): params = request.param distro = params.get('distro', 'rhel') network = params.get('network', settings.content_host.network_type) _rhelver = f"{distro}{params.get('rhel_version', settings.content_host.default_rhel_version)}" + version_conf = settings.content_host.get(_rhelver).to_dict() + post_configs = version_conf.get('post_configs', []) + # check to see if no-containers is passed as an argument to pytest deploy_kwargs = {} if not any( @@ -34,18 +37,20 @@ def host_conf(request): request.node.get_closest_marker('no_containers'), ] ): - deploy_kwargs = settings.content_host.get(_rhelver).to_dict().get('container', {}) + deploy_kwargs = version_conf.get('container', {}) if deploy_kwargs and network: deploy_kwargs.update({'Container': str(network)}) # if we're not using containers or a container isn't available, use a VM if not deploy_kwargs: - deploy_kwargs = settings.content_host.get(_rhelver).to_dict().get('vm', {}) + deploy_kwargs = version_conf.get('vm', {}) if network: deploy_kwargs.update({'deploy_network_type': network}) if network: # pass the network type to the deploy kwargs, so the host class can use it deploy_kwargs.update({'net_type': network}) - conf.update(deploy_kwargs) + conf = {**deploy_kwargs} + if post_configs: + conf['post_configs'] = post_configs return conf @@ -77,6 +82,8 @@ def host_post_config(hosts, config_name): if isinstance(val, str) and "{" in val: broker_args[key] = val.format(host=host) Broker(**broker_args).execute() + host._post_deploy_config = getattr(host, '_post_deploy_config', set()) | {config_name} + host.connect() @contextmanager @@ -256,7 +263,7 @@ def katello_host_tools_tracer_host(rex_contenthost, target_sat): def rhel_contenthost_with_repos(request, target_sat): """Install katello-host-tools-tracer, create custom repositories on the host""" - with Broker(**host_conf(request), host_class=ContentHost) as host: + with contenthost_factory(request=request) as host: # add IPv6 proxy for IPv6 communication if not host.network_type.has_ipv4: host.enable_ipv6_dnf_and_rhsm_proxy() @@ -300,7 +307,7 @@ def module_container_contenthost(request, module_target_sat, module_org, module_ def module_flatpak_contenthost(request): assert request.param['rhel_version'] > 8, 'Unsupported RHEL version' request.param['no_containers'] = True - with Broker(**host_conf(request), host_class=ContentHost) as host: + with contenthost_factory(request=request) as host: host.register_to_cdn() res = host.execute('dnf -y install podman flatpak dbus-x11') assert res.status == 0, f'Initial installation failed: {res.stderr}'