From 7da69a23e68f611d7fe1dcda50797d8ac16859b2 Mon Sep 17 00:00:00 2001 From: Moshe Shitrit Date: Fri, 15 Sep 2017 10:50:47 -0400 Subject: [PATCH] Added nopackages option and Fix #24997 (#28831) * Added nopackages option and Fix #24997 Adding a new option - nopackages. This enables the option to add the --nopackages flag while registering a new node to RHN Satellite. We are not uploading the rpm data on our nodes and since we started utilizing ansible for nodes registration, I figures it would be useful for others as well. Also- Fixes #24997 (verified in my lab) * Fixed documentation * Documentation changes: - typo fix in "default" - Added "version_added" and set to 2.4 * Documentation changes: - Removed trailing whitespaces in nopackages['version_added'] * This change is unrelated for this feature pull request and shouldn't be here (and also seems wrong, see #25079). * Changed "version_added" to 2.5 in the module docs --- lib/ansible/modules/packaging/os/rhn_register.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/packaging/os/rhn_register.py b/lib/ansible/modules/packaging/os/rhn_register.py index ea16288c3b..5f185a5a41 100644 --- a/lib/ansible/modules/packaging/os/rhn_register.py +++ b/lib/ansible/modules/packaging/os/rhn_register.py @@ -81,6 +81,12 @@ options: - If true, extended update support will be requested. required: false default: false + nopackages: + description: + - If true, the registered node will not upload its installed packages information to Satellite server + required: false + default: false + version_added: "2.5" ''' EXAMPLES = ''' @@ -250,7 +256,7 @@ class Rhn(redhat.RegistrationBase): self.update_plugin_conf('rhnplugin', True) self.update_plugin_conf('subscription-manager', False) - def register(self, enable_eus=False, activationkey=None, profilename=None, sslcacert=None, systemorgid=None): + def register(self, enable_eus=False, activationkey=None, profilename=None, sslcacert=None, systemorgid=None, nopackages=False): ''' Register system to RHN. If enable_eus=True, extended update support will be requested. @@ -262,6 +268,8 @@ class Rhn(redhat.RegistrationBase): register_cmd.extend(['--serverUrl', self.server_url]) if enable_eus: register_cmd.append('--use-eus-channel') + if nopackages: + register_cmd.append('--nopackages') if activationkey is not None: register_cmd.extend(['--activationkey', activationkey]) if profilename is not None: @@ -346,6 +354,7 @@ def main(): sslcacert=dict(default=None, required=False, type='path'), systemorgid=dict(default=None, required=False), enable_eus=dict(default=False, type='bool'), + nopackages=dict(default=False, type='bool'), channels=dict(default=[], type='list'), ) ) @@ -364,6 +373,7 @@ def main(): systemorgid = module.params['systemorgid'] channels = module.params['channels'] enable_eus = module.params['enable_eus'] + nopackages = module.params['nopackages'] rhn = Rhn(module=module, username=username, password=password) @@ -392,7 +402,7 @@ def main(): try: rhn.enable() - rhn.register(enable_eus, activationkey, profilename, sslcacert, systemorgid) + rhn.register(enable_eus, activationkey, profilename, sslcacert, systemorgid, nopackages) rhn.subscribe(channels) except Exception as exc: module.fail_json(msg="Failed to register with '%s': %s" % (rhn.hostname, exc))