2 Module fixes (#3611)
* Fix syntax error in azure_rm_virtualmachine.py * Allow rhn_register to fail gracefully when rhn-client-tools is not installed
This commit is contained in:
parent
76b7de943b
commit
1d87213de1
2 changed files with 13 additions and 3 deletions
|
@ -520,7 +520,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|||
changed=False,
|
||||
actions=[],
|
||||
powerstate_change=None,
|
||||
ansible_facts=dict('azure_rm_vm')
|
||||
ansible_facts=dict(azure_rm_vm=None)
|
||||
)
|
||||
|
||||
super(AzureRMVirtualMachine, self).__init__(derived_arg_spec=self.module_arg_spec,
|
||||
|
|
|
@ -119,8 +119,9 @@ sys.path.insert(0, '/usr/share/rhn')
|
|||
try:
|
||||
import up2date_client
|
||||
import up2date_client.config
|
||||
HAS_UP2DATE_CLIENT = True
|
||||
except ImportError, e:
|
||||
module.fail_json(msg="Unable to import up2date_client. Is 'rhn-client-tools' installed?\n%s" % e)
|
||||
HAS_UP2DATE_CLIENT = False
|
||||
|
||||
# INSERT REDHAT SNIPPETS
|
||||
from ansible.module_utils.redhat import *
|
||||
|
@ -137,6 +138,9 @@ class Rhn(RegistrationBase):
|
|||
'''
|
||||
Read configuration from /etc/sysconfig/rhn/up2date
|
||||
'''
|
||||
if not HAS_UP2DATE_CLIENT:
|
||||
return None
|
||||
|
||||
self.config = up2date_client.config.initUp2dateConfig()
|
||||
|
||||
# Add support for specifying a default value w/o having to standup some
|
||||
|
@ -339,7 +343,7 @@ def main():
|
|||
state = dict(default='present', choices=['present', 'absent']),
|
||||
username = dict(default=None, required=False),
|
||||
password = dict(default=None, required=False, no_log=True),
|
||||
server_url = dict(default=rhn.config.get_option('serverURL'), required=False),
|
||||
server_url = dict(default=None, required=False),
|
||||
activationkey = dict(default=None, required=False, no_log=True),
|
||||
profilename = dict(default=None, required=False),
|
||||
sslcacert = dict(default=None, required=False, type='path'),
|
||||
|
@ -349,6 +353,12 @@ def main():
|
|||
)
|
||||
)
|
||||
|
||||
if not HAS_UP2DATE_CLIENT:
|
||||
module.fail_json(msg="Unable to import up2date_client. Is 'rhn-client-tools' installed?")
|
||||
|
||||
if not module.params['server_url']:
|
||||
module.params['server_url'] = rhn.config.get_option('serverURL')
|
||||
|
||||
state = module.params['state']
|
||||
rhn.username = module.params['username']
|
||||
rhn.password = module.params['password']
|
||||
|
|
Loading…
Reference in a new issue