diff --git a/changelogs/fragments/6319-redhat_subscription-fix-environment-parameter.yaml b/changelogs/fragments/6319-redhat_subscription-fix-environment-parameter.yaml new file mode 100644 index 0000000000..672d8dc03e --- /dev/null +++ b/changelogs/fragments/6319-redhat_subscription-fix-environment-parameter.yaml @@ -0,0 +1,5 @@ +bugfixes: + - redhat_subscription - do not use D-Bus for registering when ``environment`` is specified, + so it possible to specify again the environment names for registering, + as the D-Bus APIs work only with IDs + (https://github.com/ansible-collections/community.general/pull/6319). diff --git a/plugins/modules/redhat_subscription.py b/plugins/modules/redhat_subscription.py index 2896e73181..adfa1ca21a 100644 --- a/plugins/modules/redhat_subscription.py +++ b/plugins/modules/redhat_subscription.py @@ -461,8 +461,10 @@ class Rhsm(RegistrationBase): * Exception - if any error occurs during the registration ''' # There is no support for token-based registration in the D-Bus API - # of rhsm, so always use the CLI in that case. - if not token and self._can_connect_to_dbus(): + # of rhsm, so always use the CLI in that case; + # also, since the specified environments are names, and the D-Bus APIs + # require IDs for the environments, use the CLI also in that case + if not token and not environment and self._can_connect_to_dbus(): self._register_using_dbus(was_registered, username, password, auto_attach, activationkey, org_id, consumer_type, consumer_name, consumer_id,