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 René Moser
parent a144663953
commit d83c269b82

View file

@ -80,12 +80,34 @@ options:
- Specify a subscription pool name to consume. Regular expressions accepted.
required: False
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 = '''
# 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
# 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
# the names (Red hat Enterprise Server) and (Red Hat Virtualization)
- redhat_subscription: state=present
@ -224,7 +246,8 @@ class Rhsm(RegistrationBase):
else:
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
Raises:
@ -244,6 +267,12 @@ class Rhsm(RegistrationBase):
args.extend(['--username', username])
if 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)
@ -411,6 +440,9 @@ def main():
activationkey = dict(default=None, required=False),
org_id = dict(default=None, required=False),
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']
org_id = module.params['org_id']
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
if state == 'present':
@ -450,7 +485,8 @@ def main():
try:
rhn.enable()
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)
except Exception, e:
module.fail_json(msg="Failed to register with '%s': %s" % (server_hostname, e))