Fix for hponcfg on ESXi hypervisors (#27362)

Add new option to pass the path to the hponcfg binary which may not live in
$PATH. For example on ESXi hypervisors it tends to be located in
/opt/hp/tools/ instead. Also properly implement a verbose option for which the
code was already commented out.
pull/28346/head
Jasper Lievisse Adriaanse 7 years ago committed by Dag Wieers
parent 746b433c29
commit 955cc5a99e

@ -24,12 +24,24 @@ description:
options: options:
path: path:
description: description:
- The XML file as accepted by hponcfg - The XML file as accepted by hponcfg.
required: true required: true
aliases: ['src'] aliases: ['src']
minfw: minfw:
description: description:
- The minimum firmware level needed - The minimum firmware level needed.
required: false
executable:
description:
- Path to the hponcfg executable (`hponcfg` which uses $PATH).
default: hponcfg
version_added: "2.4"
verbose:
description:
- Run hponcfg in verbose mode (-v).
default: no
type: bool
version_added: "2.4"
requirements: requirements:
- hponcfg tool - hponcfg tool
notes: notes:
@ -58,6 +70,11 @@ EXAMPLES = r'''
- name: Configure HP iLO using enable-ssh.xml - name: Configure HP iLO using enable-ssh.xml
hponcfg: hponcfg:
src: /tmp/enable-ssh.xml src: /tmp/enable-ssh.xml
- name: Configure HP iLO on VMware ESXi hypervisor
hponcfg:
src: /tmp/enable-ssh.xml
executable: /opt/hp/tools/hponcfg
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
@ -69,6 +86,8 @@ def main():
argument_spec=dict( argument_spec=dict(
src=dict(type='path', required=True, aliases=['path']), src=dict(type='path', required=True, aliases=['path']),
minfw=dict(type='str'), minfw=dict(type='str'),
executable=dict(default='hponcfg', type='str'),
verbose=dict(default=False, type='bool'),
) )
) )
@ -77,16 +96,18 @@ def main():
src = module.params['src'] src = module.params['src']
minfw = module.params['minfw'] minfw = module.params['minfw']
executable = module.params['executable']
verbose = module.params['verbose']
options = ' -f %s' % src options = ' -f %s' % src
# Add -v for debugging if verbose:
# options += ' -v' options += ' -v'
if minfw: if minfw:
options += ' -m %s' % minfw options += ' -m %s' % minfw
rc, stdout, stderr = module.run_command('hponcfg %s' % options) rc, stdout, stderr = module.run_command('%s %s' % (executable, options))
if rc != 0: if rc != 0:
module.fail_json(rc=rc, msg="Failed to run hponcfg", stdout=stdout, stderr=stderr) module.fail_json(rc=rc, msg="Failed to run hponcfg", stdout=stdout, stderr=stderr)

Loading…
Cancel
Save