From f7fa54eed9f82ea2d0287541d9bef31a8e3631d3 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Wed, 30 Nov 2022 22:15:55 +0100 Subject: [PATCH] redhat_subscription: don't discard vars with key (#5627) Fixes #3486. From the man-pages of subscription-manager, none of the parameters used are tied to the activationkey except the two that remain in its else-clause. Note that type is not mentioned in the man-pages on 7.6 (at least), but is still present and available. Co-authored-by: Thor K. H --- ...t_subscription-subscribe-parameters-2.yaml | 3 +++ plugins/modules/redhat_subscription.py | 25 +++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 changelogs/fragments/5627-redhat_subscription-subscribe-parameters-2.yaml diff --git a/changelogs/fragments/5627-redhat_subscription-subscribe-parameters-2.yaml b/changelogs/fragments/5627-redhat_subscription-subscribe-parameters-2.yaml new file mode 100644 index 0000000000..c76f6871d8 --- /dev/null +++ b/changelogs/fragments/5627-redhat_subscription-subscribe-parameters-2.yaml @@ -0,0 +1,3 @@ +bugfixes: + - redhat_subscription - do not ignore ``consumer_name`` and other variables if ``activationkey`` is specified + (https://github.com/ansible-collections/community.general/issues/3486, https://github.com/ansible-collections/community.general/pull/5627). diff --git a/plugins/modules/redhat_subscription.py b/plugins/modules/redhat_subscription.py index bb21578fa5..041c1a0097 100644 --- a/plugins/modules/redhat_subscription.py +++ b/plugins/modules/redhat_subscription.py @@ -411,23 +411,28 @@ class Rhsm(RegistrationBase): if org_id: args.extend(['--org', org_id]) + if auto_attach: + args.append('--auto-attach') + + if consumer_type: + args.extend(['--type', consumer_type]) + + if consumer_name: + args.extend(['--name', consumer_name]) + + if consumer_id: + args.extend(['--consumerid', consumer_id]) + + if environment: + args.extend(['--environment', environment]) + if activationkey: args.extend(['--activationkey', activationkey]) else: - if auto_attach: - args.append('--auto-attach') if username: args.extend(['--username', username]) if password: args.extend(['--password', password]) - if consumer_type: - args.extend(['--type', consumer_type]) - if consumer_name: - args.extend(['--name', consumer_name]) - if consumer_id: - args.extend(['--consumerid', consumer_id]) - if environment: - args.extend(['--environment', environment]) if release: args.extend(['--release', release])