mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
Support IPMI encryption key parameter in ipmi_boot (#3702)
* Support IPMI encryption key parameter in ipmi_boot * Support py2 on hex parsing, error handling Change parsing hex string to support python2 and add error handling to it based on feedback. * Don't explicitly set required to false * Add version_added to key arg * Add changelog fragment * Add IPMI encryption key arg to ipmi_power * Fix the formatting of changelog fragment
This commit is contained in:
parent
17c3708f31
commit
4013d0c9ca
3 changed files with 39 additions and 2 deletions
|
@ -35,6 +35,12 @@ options:
|
|||
- Password to connect to the BMC.
|
||||
required: true
|
||||
type: str
|
||||
key:
|
||||
description:
|
||||
- Encryption key to connect to the BMC in hex format.
|
||||
required: false
|
||||
type: str
|
||||
version_added: 4.1.0
|
||||
bootdev:
|
||||
description:
|
||||
- Set boot device to use on next reboot
|
||||
|
@ -115,11 +121,13 @@ EXAMPLES = '''
|
|||
name: test.testdomain.com
|
||||
user: admin
|
||||
password: password
|
||||
key: 1234567890AABBCCDEFF000000EEEE12
|
||||
bootdev: network
|
||||
state: absent
|
||||
'''
|
||||
|
||||
import traceback
|
||||
import binascii
|
||||
|
||||
PYGHMI_IMP_ERR = None
|
||||
try:
|
||||
|
@ -138,6 +146,7 @@ def main():
|
|||
port=dict(default=623, type='int'),
|
||||
user=dict(required=True, no_log=True),
|
||||
password=dict(required=True, no_log=True),
|
||||
key=dict(type='str', no_log=True),
|
||||
state=dict(default='present', choices=['present', 'absent']),
|
||||
bootdev=dict(required=True, choices=['network', 'hd', 'floppy', 'safe', 'optical', 'setup', 'default']),
|
||||
persistent=dict(default=False, type='bool'),
|
||||
|
@ -162,10 +171,18 @@ def main():
|
|||
if state == 'absent' and bootdev == 'default':
|
||||
module.fail_json(msg="The bootdev 'default' cannot be used with state 'absent'.")
|
||||
|
||||
try:
|
||||
if module.params['key']:
|
||||
key = binascii.unhexlify(module.params['key'])
|
||||
else:
|
||||
key = None
|
||||
except Exception as e:
|
||||
module.fail_json(msg="Unable to convert 'key' from hex string.")
|
||||
|
||||
# --- run command ---
|
||||
try:
|
||||
ipmi_cmd = command.Command(
|
||||
bmc=name, userid=user, password=password, port=port
|
||||
bmc=name, userid=user, password=password, port=port, kg=key
|
||||
)
|
||||
module.debug('ipmi instantiated - name: "%s"' % name)
|
||||
current = ipmi_cmd.get_bootdev()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue