1
0
mirror of https://github.com/ansible-collections/community.general.git synced 2025-07-30 18:43:09 +03:00

rhsm modules: cleanly fail when not run as root (#6211)

subscription-manager on RHEL installs a symlink in /usr/bin to
console-helper (part of usermode), which triggers an interactive prompt
for root credentials when run as user. It seems that console-helper
does not handle well non-interactive contexts (e.g. without a TTY for
input), and thus it will hang waiting for input when run as user in an
Ansible task.

Since subscription-manager requires root already anyway (and it will
fail when explicitly run as user), then apply the same logic locally on
all the modules that interact with it: redhat_subscription,
rhsm_release, and rhsm_repository.
This commit is contained in:
Pino Toscano
2023-03-22 13:15:32 +01:00
committed by GitHub
parent 512bf4b77f
commit 9f67cbbe36
6 changed files with 40 additions and 4 deletions

View File

@ -29,6 +29,8 @@ def patch_redhat_subscription(mocker):
return_value='/testbin/subscription-manager')
mocker.patch('ansible_collections.community.general.plugins.modules.redhat_subscription.Rhsm._can_connect_to_dbus',
return_value=False)
mocker.patch('ansible_collections.community.general.plugins.modules.redhat_subscription.getuid',
return_value=0)
@pytest.mark.parametrize('patch_ansible_module', [{}], indirect=['patch_ansible_module'])