improve redhat_subscription documentation (#3348)

* add subscription-manager's --type, --consumerid, --name option support

* redhat_subscription: More docs on consumerid
This commit is contained in:
Adrian Likins 2016-04-20 11:33:08 -04:00 committed by Matt Clay
parent 69f2b3d727
commit 4141cc5548

View file

@ -80,12 +80,34 @@ options:
- Specify a subscription pool name to consume. Regular expressions accepted. - Specify a subscription pool name to consume. Regular expressions accepted.
required: False required: False
default: '^$' default: '^$'
consumer_type:
description:
- The type of unit to register, defaults to system
required: False
default: null
version_added: "2.1"
consumer_name:
description:
- Name of the system to register, defaults to the hostname
required: False
default: null
version_added: "2.1"
consumer_id:
description:
- References an existing consumer ID to resume using a previous registration for this system. If the system's identity certificate is lost or corrupted, this option allows it to resume using its previous identity and subscriptions. The default is to not specify a consumer ID so a new ID is created.
required: False
default: null
version_added: "2.1"
''' '''
EXAMPLES = ''' EXAMPLES = '''
# Register as user (joe_user) with password (somepass) and auto-subscribe to available content. # Register as user (joe_user) with password (somepass) and auto-subscribe to available content.
- redhat_subscription: state=present username=joe_user password=somepass autosubscribe=true - redhat_subscription: state=present username=joe_user password=somepass autosubscribe=true
# Same as above but with pulling existing system data.
- redhat_subscription: state=present username=joe_user password=somepass
consumer_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
# Register with activationkey (1-222333444) and consume subscriptions matching # Register with activationkey (1-222333444) and consume subscriptions matching
# the names (Red hat Enterprise Server) and (Red Hat Virtualization) # the names (Red hat Enterprise Server) and (Red Hat Virtualization)
- redhat_subscription: state=present - redhat_subscription: state=present
@ -224,7 +246,8 @@ class Rhsm(RegistrationBase):
else: else:
return False return False
def register(self, username, password, autosubscribe, activationkey, org_id): def register(self, username, password, autosubscribe, activationkey, org_id,
consumer_type, consumer_name, consumer_id):
''' '''
Register the current system to the provided RHN server Register the current system to the provided RHN server
Raises: Raises:
@ -244,6 +267,12 @@ class Rhsm(RegistrationBase):
args.extend(['--username', username]) args.extend(['--username', username])
if password: if password:
args.extend(['--password', 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])
rc, stderr, stdout = self.module.run_command(args, check_rc=True) rc, stderr, stdout = self.module.run_command(args, check_rc=True)
@ -411,6 +440,9 @@ def main():
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),
pool = dict(default='^$', required=False, type='str'), pool = dict(default='^$', required=False, type='str'),
consumer_type = dict(default=None, required=False),
consumer_name = dict(default=None, required=False),
consumer_id = dict(default=None, required=False),
) )
) )
@ -425,6 +457,9 @@ def main():
activationkey = module.params['activationkey'] activationkey = module.params['activationkey']
org_id = module.params['org_id'] org_id = module.params['org_id']
pool = module.params['pool'] pool = module.params['pool']
consumer_type = module.params["consumer_type"]
consumer_name = module.params["consumer_name"]
consumer_id = module.params["consumer_id"]
# Ensure system is registered # Ensure system is registered
if state == 'present': if state == 'present':
@ -450,7 +485,8 @@ def main():
try: try:
rhn.enable() rhn.enable()
rhn.configure(**module.params) rhn.configure(**module.params)
rhn.register(username, password, autosubscribe, activationkey, org_id) rhn.register(username, password, autosubscribe, activationkey, org_id,
consumer_type, consumer_name, consumer_id)
subscribed_pool_ids = rhn.subscribe(pool) subscribed_pool_ids = rhn.subscribe(pool)
except Exception, e: except Exception, e:
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))