From 955cc5a99ec83ec46d9a468fb31ae4ff44ab41b2 Mon Sep 17 00:00:00 2001 From: Jasper Lievisse Adriaanse Date: Thu, 17 Aug 2017 18:20:55 +0200 Subject: [PATCH] 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. --- .../remote_management/hpilo/hponcfg.py | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/remote_management/hpilo/hponcfg.py b/lib/ansible/modules/remote_management/hpilo/hponcfg.py index 3eb0c73d0cc..4daaae3dcec 100644 --- a/lib/ansible/modules/remote_management/hpilo/hponcfg.py +++ b/lib/ansible/modules/remote_management/hpilo/hponcfg.py @@ -24,12 +24,24 @@ description: options: path: description: - - The XML file as accepted by hponcfg + - The XML file as accepted by hponcfg. required: true aliases: ['src'] minfw: 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: - hponcfg tool notes: @@ -58,6 +70,11 @@ EXAMPLES = r''' - name: Configure HP iLO using enable-ssh.xml hponcfg: 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 @@ -69,6 +86,8 @@ def main(): argument_spec=dict( src=dict(type='path', required=True, aliases=['path']), 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'] minfw = module.params['minfw'] + executable = module.params['executable'] + verbose = module.params['verbose'] options = ' -f %s' % src - # Add -v for debugging -# options += ' -v' + if verbose: + options += ' -v' if 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: module.fail_json(rc=rc, msg="Failed to run hponcfg", stdout=stdout, stderr=stderr)