From 2cd6e56dc2d34eb36dc25487d45c5079799bd5f9 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Mon, 27 Feb 2017 12:44:09 +0100 Subject: [PATCH] hponcfg: Configure HP iLO mgmt board (in-band) (#21677) This is the original `hponcfg` module that was once accepted in Ansible but had been removed subsequently because it could not be tested by the Ansible project. Since then it was moved to the ansible-provisioning project and maintained by HP engineers going forward. Now we are trying to get it upstreamed again. --- .../remote_management/hpilo/hponcfg.py | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 lib/ansible/modules/remote_management/hpilo/hponcfg.py diff --git a/lib/ansible/modules/remote_management/hpilo/hponcfg.py b/lib/ansible/modules/remote_management/hpilo/hponcfg.py new file mode 100644 index 00000000000..2e0e62604c4 --- /dev/null +++ b/lib/ansible/modules/remote_management/hpilo/hponcfg.py @@ -0,0 +1,105 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2012, Dag Wieers +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +ANSIBLE_METADATA = {'status': ['preview'], + 'supported_by': 'community', + 'version': '1.0'} + +DOCUMENTATION = r''' +--- +module: hponcfg +author: Dag Wieers (@dagwieers) +version_added: "2.3" +short_description: Configure HP iLO interface using hponcfg +description: +- This modules configures the HP iLO interface using hponcfg. +options: + path: + description: + - The XML file as accepted by hponcfg + required: true + aliases: ['src'] + minfw: + description: + - The minimum firmware level needed +requirements: +- hponcfg tool +notes: +- You need a working hponcfg on the target system. +''' + +EXAMPLES = r''' +- name: Example hponcfg configuration XML + copy: + content: | + + + + + + + + + + + + + + dest: /tmp/enable-ssh.xml + +- name: Configure HP iLO using enable-ssh.xml + hponcfg: + src: /tmp/enable-ssh.xml +''' + +from ansible.module_utils.basic import AnsibleModule + +def main(): + + module = AnsibleModule( + argument_spec = dict( + src = dict(required=True, type='path', aliases=['path']), + minfw = dict(type='str'), + ) + ) + + # Consider every action a change (not idempotent yet!) + changed = True + + src = module.params['src'] + minfw = module.params['minfw'] + + options = ' -f %s' % src + + # Add -v for debugging +# options += ' -v' + + if minfw: + option += ' -m %s' % minfw + + rc, stdout, stderr = module.run_command('hponcfg %s' % options) + + if rc != 0: + module.fail_json(rc=rc, msg="Failed to run hponcfg", stdout=stdout, stderr=stderr) + + module.exit_json(changed=changed, stdout=stdout, stderr=stderr) + +if __name__ == '__main__': + main()