Debian Codegraph @

ansible_collections/community/general/plugins/modules/hponcfg.py

raw
1 #!/usr/bin/python
2
3 # Copyright (c) 2012, Dag Wieers <[email protected]>
4 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
5 # SPDX-License-Identifier: GPL-3.0-or-later
6
7 from __future__ import annotations
8
9 DOCUMENTATION = r"""
10 module: hponcfg
11 author: Dag Wieers (@dagwieers)
12 short_description: Configure HP iLO interface using C(hponcfg)
13 description:
14 - This modules configures the HP iLO interface using C(hponcfg).
15 extends_documentation_fragment:
16 - community.general._attributes
17 attributes:
18 check_mode:
19 support: none
20 diff_mode:
21 support: none
22 options:
23 path:
24 description:
25 - The XML file as accepted by C(hponcfg).
26 required: true
27 aliases: ['src']
28 type: path
29 minfw:
30 description:
31 - The minimum firmware level needed.
32 type: str
33 executable:
34 description:
35 - Path to the hponcfg executable (C(hponcfg) which uses E(PATH)).
36 default: hponcfg
37 type: str
38 verbose:
39 description:
40 - Run C(hponcfg) in verbose mode (-v).
41 default: false
42 type: bool
43 requirements:
44 - hponcfg tool
45 notes:
46 - You need a working C(hponcfg) on the target system.
47 """
48
49 EXAMPLES = r"""
50 - name: Example hponcfg configuration XML
51 ansible.builtin.copy:
52 content: |
53 <ribcl VERSION="2.0">
54 <login USER_LOGIN="user" PASSWORD="password">
55 <rib_info MODE="WRITE">
56 <mod_global_settings>
57 <session_timeout value="0"/>
58 <ssh_status value="Y"/>
59 <ssh_port value="22"/>
60 <serial_cli_status value="3"/>
61 <serial_cli_speed value="5"/>
62 </mod_global_settings>
63 </rib_info>
64 </login>
65 </ribcl>
66 dest: /tmp/enable-ssh.xml
67
68 - name: Configure HP iLO using enable-ssh.xml
69 community.general.hponcfg:
70 src: /tmp/enable-ssh.xml
71
72 - name: Configure HP iLO on VMware ESXi hypervisor
73 community.general.hponcfg:
74 src: /tmp/enable-ssh.xml
75 executable: /opt/hp/tools/hponcfg
76 """
77
78 from ansible_collections.community.general.plugins.module_utils._cmd_runner import CmdRunner, cmd_runner_fmt
79 from ansible_collections.community.general.plugins.module_utils._module_helper import ModuleHelper
80
81
82 class HPOnCfg(ModuleHelper):
83 module = dict(
84 argument_spec=dict(
85 src=dict(type="path", required=True, aliases=["path"]),
86 minfw=dict(type="str"),
87 executable=dict(default="hponcfg", type="str"),
88 verbose=dict(default=False, type="bool"),
89 )
90 )
91 command_args_formats = dict(
92 src=cmd_runner_fmt.as_opt_val("-f"),
93 verbose=cmd_runner_fmt.as_bool("-v"),
94 minfw=cmd_runner_fmt.as_opt_val("-m"),
95 )
96
97 def __run__(self):
98 runner = CmdRunner(
99 self.module,
100 self.vars.executable,
101 self.command_args_formats,
102 check_rc=True,
103 )
104 runner(["src", "verbose", "minfw"]).run()
105
106 # Consider every action a change (not idempotent yet!)
107 self.changed = True
108
109
110 def main():
111 HPOnCfg.execute()
112
113
114 if __name__ == "__main__":
115 main()