Add release argument for redhat_subscription (#47888)

This commit is contained in:
Jason Walsh 2018-11-09 17:19:06 -05:00 committed by Sam Doran
parent 55f5a707fe
commit 96cdc9ec06

View file

@ -127,6 +127,10 @@ options:
type: bool type: bool
default: 'no' default: 'no'
version_added: "2.2" version_added: "2.2"
release:
description:
- Set a release version
version_added: "2.8"
''' '''
EXAMPLES = ''' EXAMPLES = '''
@ -190,6 +194,13 @@ EXAMPLES = '''
password: somepass password: somepass
environment: Library environment: Library
auto_attach: true auto_attach: true
- name: Register as user (joe_user) with password (somepass) and a specific release
redhat_subscription:
state: present
username: joe_user
password: somepass
release: 7.4
''' '''
RETURN = ''' RETURN = '''
@ -313,7 +324,7 @@ class Rhsm(RegistrationBase):
def register(self, username, password, auto_attach, activationkey, org_id, def register(self, username, password, auto_attach, activationkey, org_id,
consumer_type, consumer_name, consumer_id, force_register, environment, consumer_type, consumer_name, consumer_id, force_register, environment,
rhsm_baseurl, server_insecure, server_hostname, server_proxy_hostname, rhsm_baseurl, server_insecure, server_hostname, server_proxy_hostname,
server_proxy_port, server_proxy_user, server_proxy_password): server_proxy_port, server_proxy_user, server_proxy_password, release):
''' '''
Register the current system to the provided RHSM or Sat6 server Register the current system to the provided RHSM or Sat6 server
Raises: Raises:
@ -361,6 +372,9 @@ class Rhsm(RegistrationBase):
if server_proxy_password: if server_proxy_password:
args.extend(['--proxypassword', server_proxy_password]) args.extend(['--proxypassword', server_proxy_password])
if release:
args.extend(['--release', release])
rc, stderr, stdout = self.module.run_command(args, check_rc=True) rc, stderr, stdout = self.module.run_command(args, check_rc=True)
def unsubscribe(self, serials=None): def unsubscribe(self, serials=None):
@ -657,6 +671,7 @@ def main():
server_proxy_password=dict(default=None, server_proxy_password=dict(default=None,
required=False, required=False,
no_log=True), no_log=True),
release=dict(default=None, required=False)
), ),
required_together=[['username', 'password'], required_together=[['username', 'password'],
['server_proxy_hostname', 'server_proxy_port'], ['server_proxy_hostname', 'server_proxy_port'],
@ -704,6 +719,7 @@ def main():
server_proxy_port = module.params['server_proxy_port'] server_proxy_port = module.params['server_proxy_port']
server_proxy_user = module.params['server_proxy_user'] server_proxy_user = module.params['server_proxy_user']
server_proxy_password = module.params['server_proxy_password'] server_proxy_password = module.params['server_proxy_password']
release = module.params['release']
global SUBMAN_CMD global SUBMAN_CMD
SUBMAN_CMD = module.get_bin_path('subscription-manager', True) SUBMAN_CMD = module.get_bin_path('subscription-manager', True)
@ -732,7 +748,7 @@ def main():
rhsm.register(username, password, auto_attach, activationkey, org_id, rhsm.register(username, password, auto_attach, activationkey, org_id,
consumer_type, consumer_name, consumer_id, force_register, consumer_type, consumer_name, consumer_id, force_register,
environment, rhsm_baseurl, server_insecure, server_hostname, environment, rhsm_baseurl, server_insecure, server_hostname,
server_proxy_hostname, server_proxy_port, server_proxy_user, server_proxy_password) server_proxy_hostname, server_proxy_port, server_proxy_user, server_proxy_password, release)
if pool_ids: if pool_ids:
subscribed_pool_ids = rhsm.subscribe_by_pool_ids(pool_ids) subscribed_pool_ids = rhsm.subscribe_by_pool_ids(pool_ids)
else: else: