Update docs and internal naming s/RHN/RHSM (#3977)

pull/18777/head
Adrian Likins 8 years ago committed by Matt Clay
parent 09b34c764a
commit e2bd4a87d8

@ -18,9 +18,9 @@
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: redhat_subscription module: redhat_subscription
short_description: Manage Red Hat Network registration and subscriptions using the C(subscription-manager) command short_description: Manage registration and subscriptions to RHSM using the C(subscription-manager) command
description: description:
- Manage registration and subscription to the Red Hat Network entitlement platform. - Manage registration and subscription to the Red Hat Subscription Management entitlement platform using the C(subscription-manager) command
version_added: "1.2" version_added: "1.2"
author: "Barnaby Court (@barnabycourt)" author: "Barnaby Court (@barnabycourt)"
notes: notes:
@ -36,17 +36,17 @@ options:
default: "present" default: "present"
username: username:
description: description:
- Red Hat Network username - access.redhat.com or Sat6 username
required: False required: False
default: null default: null
password: password:
description: description:
- Red Hat Network password - access.redhat.com or Sat6 password
required: False required: False
default: null default: null
server_hostname: server_hostname:
description: description:
- Specify an alternative Red Hat Network server - Specify an alternative Red Hat Subscription Management or Sat6 server
required: False required: False
default: Current value from C(/etc/rhsm/rhsm.conf) is the default default: Current value from C(/etc/rhsm/rhsm.conf) is the default
server_insecure: server_insecure:
@ -217,7 +217,7 @@ class Rhsm(RegistrationBase):
def configure(self, **kwargs): def configure(self, **kwargs):
''' '''
Configure the system as directed for registration with RHN Configure the system as directed for registration with RHSM
Raises: Raises:
* Exception - if error occurs while running command * Exception - if error occurs while running command
''' '''
@ -238,7 +238,7 @@ class Rhsm(RegistrationBase):
Determine whether the current system Determine whether the current system
Returns: Returns:
* Boolean - whether the current system is currently registered to * Boolean - whether the current system is currently registered to
RHN. RHSM.
''' '''
# Quick version... # Quick version...
if False: if False:
@ -255,7 +255,7 @@ class Rhsm(RegistrationBase):
def register(self, username, password, autosubscribe, activationkey, org_id, def register(self, username, password, autosubscribe, activationkey, org_id,
consumer_type, consumer_name, consumer_id, force_register): consumer_type, consumer_name, consumer_id, force_register):
''' '''
Register the current system to the provided RHN server Register the current system to the provided RHSM or Sat6 server
Raises: Raises:
* Exception - if error occurs while running command * Exception - if error occurs while running command
''' '''
@ -434,16 +434,16 @@ class RhsmPools(object):
def main(): def main():
# Load RHSM configuration from file # Load RHSM configuration from file
rhn = Rhsm(None) rhsm = Rhsm(None)
module = AnsibleModule( module = AnsibleModule(
argument_spec = dict( argument_spec = dict(
state = dict(default='present', choices=['present', 'absent']), state = dict(default='present', choices=['present', 'absent']),
username = dict(default=None, required=False), username = dict(default=None, required=False),
password = dict(default=None, required=False, no_log=True), password = dict(default=None, required=False, no_log=True),
server_hostname = dict(default=rhn.config.get_option('server.hostname'), required=False), server_hostname = dict(default=rhsm.config.get_option('server.hostname'), required=False),
server_insecure = dict(default=rhn.config.get_option('server.insecure'), required=False), server_insecure = dict(default=rhsm.config.get_option('server.insecure'), required=False),
rhsm_baseurl = dict(default=rhn.config.get_option('rhsm.baseurl'), required=False), rhsm_baseurl = dict(default=rhsm.config.get_option('rhsm.baseurl'), required=False),
autosubscribe = dict(default=False, type='bool'), autosubscribe = dict(default=False, type='bool'),
activationkey = dict(default=None, required=False), activationkey = dict(default=None, required=False),
org_id = dict(default=None, required=False), org_id = dict(default=None, required=False),
@ -455,7 +455,7 @@ def main():
) )
) )
rhn.module = module rhsm.module = module
state = module.params['state'] state = module.params['state']
username = module.params['username'] username = module.params['username']
password = module.params['password'] password = module.params['password']
@ -481,10 +481,10 @@ def main():
module.fail_json(msg="Missing arguments, If registering without an activationkey, must supply username or password") module.fail_json(msg="Missing arguments, If registering without an activationkey, must supply username or password")
# Register system # Register system
if rhn.is_registered and not force_register: if rhsm.is_registered and not force_register:
if pool != '^$': if pool != '^$':
try: try:
result = rhn.update_subscriptions(pool) result = rhsm.update_subscriptions(pool)
except Exception: except Exception:
e = get_exception() e = get_exception()
module.fail_json(msg="Failed to update subscriptions for '%s': %s" % (server_hostname, e)) module.fail_json(msg="Failed to update subscriptions for '%s': %s" % (server_hostname, e))
@ -494,11 +494,11 @@ def main():
module.exit_json(changed=False, msg="System already registered.") module.exit_json(changed=False, msg="System already registered.")
else: else:
try: try:
rhn.enable() rhsm.enable()
rhn.configure(**module.params) rhsm.configure(**module.params)
rhn.register(username, password, autosubscribe, activationkey, org_id, rhsm.register(username, password, autosubscribe, activationkey, org_id,
consumer_type, consumer_name, consumer_id, force_register) consumer_type, consumer_name, consumer_id, force_register)
subscribed_pool_ids = rhn.subscribe(pool) subscribed_pool_ids = rhsm.subscribe(pool)
except Exception: except Exception:
e = get_exception() e = get_exception()
module.fail_json(msg="Failed to register with '%s': %s" % (server_hostname, e)) module.fail_json(msg="Failed to register with '%s': %s" % (server_hostname, e))
@ -508,12 +508,12 @@ def main():
subscribed_pool_ids=subscribed_pool_ids) subscribed_pool_ids=subscribed_pool_ids)
# Ensure system is *not* registered # Ensure system is *not* registered
if state == 'absent': if state == 'absent':
if not rhn.is_registered: if not rhsm.is_registered:
module.exit_json(changed=False, msg="System already unregistered.") module.exit_json(changed=False, msg="System already unregistered.")
else: else:
try: try:
rhn.unsubscribe() rhsm.unsubscribe()
rhn.unregister() rhsm.unregister()
except Exception: except Exception:
e = get_exception() e = get_exception()
module.fail_json(msg="Failed to unregister: %s" % e) module.fail_json(msg="Failed to unregister: %s" % e)

Loading…
Cancel
Save