You've already forked community.general
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:
@ -30,9 +30,16 @@ class RhsmRepositoryReleaseModuleTestCase(ModuleTestCase):
|
||||
self.get_bin_path = self.mock_get_bin_path.start()
|
||||
self.get_bin_path.return_value = '/testbin/subscription-manager'
|
||||
|
||||
# subscription-manager needs to be run as root
|
||||
self.mock_os_getuid = patch('ansible_collections.community.general.plugins.modules.rhsm_release.'
|
||||
'os.getuid')
|
||||
self.os_getuid = self.mock_os_getuid.start()
|
||||
self.os_getuid.return_value = 0
|
||||
|
||||
def tearDown(self):
|
||||
self.mock_run_command.stop()
|
||||
self.mock_get_bin_path.stop()
|
||||
self.mock_os_getuid.stop()
|
||||
super(RhsmRepositoryReleaseModuleTestCase, self).tearDown()
|
||||
|
||||
def module_main(self, exit_exc):
|
||||
|
Reference in New Issue
Block a user