2020-03-09 10:11:07 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2022-08-05 22:12:10 +02:00
|
|
|
# Copyright (c) 2012, Dag Wieers <dag@wieers.com>
|
2022-08-05 12:28:29 +02:00
|
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
---
|
|
|
|
module: hponcfg
|
|
|
|
author: Dag Wieers (@dagwieers)
|
|
|
|
short_description: Configure HP iLO interface using hponcfg
|
|
|
|
description:
|
2022-04-28 07:58:03 +02:00
|
|
|
- This modules configures the HP iLO interface using hponcfg.
|
2020-03-09 10:11:07 +01:00
|
|
|
options:
|
|
|
|
path:
|
|
|
|
description:
|
2022-04-28 07:58:03 +02:00
|
|
|
- The XML file as accepted by hponcfg.
|
2020-03-09 10:11:07 +01:00
|
|
|
required: true
|
|
|
|
aliases: ['src']
|
2022-04-28 07:58:03 +02:00
|
|
|
type: path
|
2020-03-09 10:11:07 +01:00
|
|
|
minfw:
|
|
|
|
description:
|
2022-04-28 07:58:03 +02:00
|
|
|
- The minimum firmware level needed.
|
2020-03-09 10:11:07 +01:00
|
|
|
required: false
|
2022-04-28 07:58:03 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
executable:
|
|
|
|
description:
|
2022-06-22 22:43:48 +02:00
|
|
|
- Path to the hponcfg executable (C(hponcfg) which uses $PATH).
|
2020-03-09 10:11:07 +01:00
|
|
|
default: hponcfg
|
2022-04-28 07:58:03 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
verbose:
|
|
|
|
description:
|
2022-04-28 07:58:03 +02:00
|
|
|
- Run hponcfg in verbose mode (-v).
|
2022-08-24 20:00:26 +02:00
|
|
|
default: false
|
2020-03-09 10:11:07 +01:00
|
|
|
type: bool
|
|
|
|
requirements:
|
2022-04-28 07:58:03 +02:00
|
|
|
- hponcfg tool
|
2020-03-09 10:11:07 +01:00
|
|
|
notes:
|
2022-04-28 07:58:03 +02:00
|
|
|
- You need a working hponcfg on the target system.
|
2020-03-09 10:11:07 +01:00
|
|
|
'''
|
|
|
|
|
|
|
|
EXAMPLES = r'''
|
|
|
|
- name: Example hponcfg configuration XML
|
2020-07-14 17:28:08 +02:00
|
|
|
ansible.builtin.copy:
|
2020-03-09 10:11:07 +01:00
|
|
|
content: |
|
|
|
|
<ribcl VERSION="2.0">
|
|
|
|
<login USER_LOGIN="user" PASSWORD="password">
|
|
|
|
<rib_info MODE="WRITE">
|
|
|
|
<mod_global_settings>
|
|
|
|
<session_timeout value="0"/>
|
|
|
|
<ssh_status value="Y"/>
|
|
|
|
<ssh_port value="22"/>
|
|
|
|
<serial_cli_status value="3"/>
|
|
|
|
<serial_cli_speed value="5"/>
|
|
|
|
</mod_global_settings>
|
|
|
|
</rib_info>
|
|
|
|
</login>
|
|
|
|
</ribcl>
|
|
|
|
dest: /tmp/enable-ssh.xml
|
|
|
|
|
|
|
|
- name: Configure HP iLO using enable-ssh.xml
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.hponcfg:
|
2020-03-09 10:11:07 +01:00
|
|
|
src: /tmp/enable-ssh.xml
|
|
|
|
|
|
|
|
- name: Configure HP iLO on VMware ESXi hypervisor
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.hponcfg:
|
2020-03-09 10:11:07 +01:00
|
|
|
src: /tmp/enable-ssh.xml
|
|
|
|
executable: /opt/hp/tools/hponcfg
|
|
|
|
'''
|
|
|
|
|
2022-11-07 06:43:21 +01:00
|
|
|
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt
|
|
|
|
from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
|
2022-11-07 06:43:21 +01:00
|
|
|
class HPOnCfg(ModuleHelper):
|
2021-12-11 21:15:33 +01:00
|
|
|
module = dict(
|
2020-03-09 10:11:07 +01:00
|
|
|
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'),
|
|
|
|
)
|
|
|
|
)
|
2021-12-11 21:15:33 +01:00
|
|
|
command_args_formats = dict(
|
2022-11-07 06:43:21 +01:00
|
|
|
src=cmd_runner_fmt.as_opt_val("-f"),
|
|
|
|
verbose=cmd_runner_fmt.as_bool("-v"),
|
|
|
|
minfw=cmd_runner_fmt.as_opt_val("-m"),
|
2021-12-11 21:15:33 +01:00
|
|
|
)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2022-11-07 06:43:21 +01:00
|
|
|
def __run__(self):
|
|
|
|
runner = CmdRunner(
|
|
|
|
self.module,
|
|
|
|
self.vars.executable,
|
|
|
|
self.command_args_formats,
|
|
|
|
check_rc=True,
|
|
|
|
)
|
|
|
|
runner(['src', 'verbose', 'minfw']).run()
|
|
|
|
|
2021-12-11 21:15:33 +01:00
|
|
|
# Consider every action a change (not idempotent yet!)
|
|
|
|
self.changed = True
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
|
2021-12-11 21:15:33 +01:00
|
|
|
def main():
|
|
|
|
HPOnCfg.execute()
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|