def main(): module = AnsibleModule( argument_spec={ "idrac_ip": {"required": True, "type": 'str'}, "idrac_user": {"required": True, "type": 'str'}, "idrac_password": {"required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True}, "idrac_port": {"required": False, "default": 443, "type": 'int'}, "share_name": {"required": True, "type": 'str'}, "share_user": {"required": False, "type": 'str'}, "share_password": {"required": False, "type": 'str', "aliases": ['share_pwd'], "no_log": True}, "share_mnt": {"required": False, "type": 'str'}, "syslog": {"required": False, "choices": ['Enabled', 'Disabled'], "default": 'Enabled'} }, supports_check_mode=True) try: with iDRACConnection(module.params) as idrac: msg = run_setup_idrac_syslog(idrac, module) changed = False if msg.get('Status') == "Success": changed = True if msg.get('Message') == "No changes found to commit!": changed = False except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (RuntimeError, SSLValidationError, ConnectionError, KeyError, ImportError, ValueError, TypeError) as e: module.fail_json(msg=str(e)) module.exit_json(msg="Successfully fetch the syslogs.", syslog_status=msg, changed=changed)
def main(): module = AnsibleModule( argument_spec={ "idrac_ip": {"required": True, "type": 'str'}, "idrac_user": {"required": True, "type": 'str'}, "idrac_password": {"required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True}, "idrac_port": {"required": False, "default": 443, "type": 'int'}, "share_name": {"required": True, "type": 'str'}, "share_user": {"required": False, "type": 'str'}, "share_password": {"required": False, "type": 'str', "aliases": ['share_pwd'], "no_log": True}, "job_wait": {"required": False, "type": 'bool', "default": True}, }, supports_check_mode=False) try: with iDRACConnection(module.params) as idrac: msg = run_export_lc_logs(idrac, module) except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (RuntimeError, SSLValidationError, ConnectionError, KeyError, ImportError, ValueError, TypeError) as e: module.fail_json(msg=str(e)) module.exit_json(msg="Successfully exported the lifecycle controller logs.", lc_logs_status=msg)
def main(): module = AnsibleModule( argument_spec={ "idrac_ip": {"required": True, "type": 'str'}, "idrac_user": {"required": True, "type": 'str'}, "idrac_password": {"required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True}, "idrac_port": {"required": False, "default": 443, "type": 'int'}, "share_name": {"required": True, "type": 'str'}, "share_user": {"required": False, "type": 'str'}, "share_password": {"required": False, "type": 'str', "aliases": ['share_pwd'], "no_log": True}, "job_wait": {"required": False, "type": 'bool', "default": True}, }, supports_check_mode=False) try: with iDRACConnection(module.params) as idrac: msg = run_export_lc_logs(idrac, module) if msg.get("Status") in ["Failed", "Failure"] or msg.get("JobStatus") in ["Failed", "Failure"]: msg.pop("file", None) module.fail_json(msg="Unable to export the lifecycle controller logs.", lc_logs_status=msg) message = "Successfully exported the lifecycle controller logs." if module.params['job_wait'] is False: message = "The export lifecycle controller log job is submitted successfully." module.exit_json(msg=message, lc_logs_status=msg) except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (RuntimeError, SSLValidationError, ConnectionError, KeyError, ImportError, ValueError, TypeError) as e: module.fail_json(msg=str(e))
def main(): module = AnsibleModule( argument_spec=dict( # iDRAC credentials idrac_ip=dict(required=True, type='str'), idrac_user=dict(required=True, type='str'), idrac_password=dict(required=True, type='str', aliases=['idrac_pwd'], no_log=True), idrac_port=dict(required=False, type='int', default=443)), supports_check_mode=True) try: with iDRACConnection(module.params) as idrac: msg, err = run_get_system_inventory(idrac, module) except (ImportError, ValueError, RuntimeError) as e: module.fail_json(msg=str(e)) if err: module.fail_json(**msg) module.exit_json( ansible_facts={idrac.ipaddr: { 'SystemInventory': msg['msg'] }})
def main(): module = AnsibleModule( argument_spec={ "idrac_ip": {"required": True, "type": 'str'}, "idrac_user": {"required": True, "type": 'str'}, "idrac_password": {"required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True}, "idrac_port": {"required": False, "default": 443, "type": 'int'}, "command": {"required": False, "type": 'str', "choices": ['export', 'import'], "default": 'export'}, "job_wait": {"required": True, "type": 'bool'}, "share_name": {"required": True, "type": 'str'}, "share_user": {"required": False, "type": 'str'}, "share_password": {"required": False, "type": 'str', "aliases": ['share_pwd'], "no_log": True}, "scp_components": {"required": False, "choices": ['ALL', 'IDRAC', 'BIOS', 'NIC', 'RAID'], "default": 'ALL'}, "scp_file": {"required": False, "type": 'str'}, "shutdown_type": {"required": False, "choices": ['Graceful', 'Forced', 'NoReboot'], "default": 'Graceful'}, "end_host_power_state": {"required": False, "choices": ['On', 'Off'], "default": 'On'}, "export_format": {"required": False, "type": 'str', "choices": ['JSON', 'XML'], "default": 'XML'}, "export_use": {"required": False, "type": 'str', "choices": ['Default', 'Clone', 'Replace'], "default": 'Default'} }, required_if=[ ["command", "import", ["scp_file"]] ], supports_check_mode=False) try: changed = False with iDRACConnection(module.params) as idrac: command = module.params['command'] if command == 'import': scp_status = run_import_server_config_profile(idrac, module) if "No changes were applied" not in scp_status.get('Message', ""): changed = True else: scp_status = run_export_server_config_profile(idrac, module) if module.params.get('job_wait'): msg = "Successfully {0}ed the Server Configuration Profile." else: msg = "Successfully triggered the job to {0} the Server Configuration Profile." module.exit_json(changed=changed, msg=msg.format(command), scp_status=scp_status) except (ImportError, ValueError, RuntimeError) as e: module.fail_json(msg=str(e))
def main(): module = AnsibleModule(argument_spec={ "idrac_ip": { "required": True, "type": 'str' }, "idrac_user": { "required": True, "type": 'str' }, "idrac_password": { "required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True }, "idrac_port": { "required": False, "default": 443, "type": 'int' }, "share_name": { "required": True, "type": 'str' }, "share_user": { "required": False, "type": 'str' }, "share_password": { "required": False, "type": 'str', "aliases": ['share_pwd'], "no_log": True }, "iso_image": { "required": True, "type": 'str' }, "expose_duration": { "required": False, "type": 'int', "default": 1080 } }, supports_check_mode=False) try: with iDRACConnection(module.params) as idrac: boot_status = run_boot_to_network_iso(idrac, module) module.exit_json(changed=True, boot_status=boot_status) except (ImportError, ValueError, RuntimeError) as e: module.fail_json(msg=str(e))
def main(): module = AnsibleModule(argument_spec={ "idrac_ip": { "required": True, "type": 'str' }, "idrac_user": { "required": True, "type": 'str' }, "idrac_password": { "required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True }, "idrac_port": { "required": False, "default": 443, "type": 'int' }, "job_id": { "required": False, "type": 'str' } }, supports_check_mode=False) try: with iDRACConnection(module.params) as idrac: job_id, resp = module.params.get('job_id'), {} if job_id is not None: resp = idrac.job_mgr.delete_job(job_id) jobstr = "job" else: resp = idrac.job_mgr.delete_all_jobs() jobstr = "job queue" if resp["Status"] == "Error": msg = "Failed to delete the Job: {0}.".format(job_id) module.fail_json(msg=msg, status=resp) except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (ImportError, ValueError, RuntimeError, TypeError) as e: module.fail_json(msg=str(e)) module.exit_json(msg="Successfully deleted the {0}.".format(jobstr), status=resp, changed=True)
def main(): module = AnsibleModule( argument_spec={ # iDRAC credentials "idrac_ip": {"required": True, "type": 'str'}, "idrac_user": {"required": True, "type": 'str'}, "idrac_password": {"required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True}, "idrac_port": {"required": False, "default": 443, "type": 'int'}, # Export Destination "share_name": {"required": True, "type": 'str'}, "share_password": {"required": False, "type": 'str', "aliases": ['share_pwd'], "no_log": True}, "share_user": {"required": False, "type": 'str'}, "share_mnt": {"required": False, "type": 'str'}, # setup NTP "enable_ntp": {"required": False, "choices": ['Enabled', 'Disabled']}, "ntp_server_1": {"required": False}, "ntp_server_2": {"required": False}, "ntp_server_3": {"required": False}, # set up timezone "setup_idrac_timezone": {"required": False, "type": 'str'}, }, supports_check_mode=True) try: with iDRACConnection(module.params) as idrac: changed = False msg = run_idrac_timezone_config(idrac, module) if "Status" in msg: if msg['Status'] == "Success": changed = True if "Message" in msg: if msg['Message'] == "No changes found to commit!": changed = False except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (RuntimeError, SSLValidationError, ConnectionError, KeyError, ImportError, ValueError, TypeError) as e: module.fail_json(msg=str(e)) module.exit_json(msg="Successfully configured the iDRAC time settings.", timezone_ntp_status=msg, changed=changed)
def main(): module = AnsibleModule(argument_spec={ "idrac_ip": { "required": True, "type": 'str' }, "idrac_user": { "required": True, "type": 'str' }, "idrac_password": { "required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True }, "idrac_port": { "required": False, "default": 443, "type": 'int' }, "job_id": { "required": True, "type": 'str' } }, supports_check_mode=True) try: with iDRACConnection(module.params) as idrac: job_id, msg, failed = module.params.get('job_id'), {}, False msg = idrac.job_mgr.get_job_status(job_id) if msg.get('Status') == "Found Fault": module.fail_json(msg="Job ID is invalid.") except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (RuntimeError, SSLValidationError, ConnectionError, KeyError, ImportError, ValueError, TypeError) as e: module.fail_json(msg=str(e)) module.exit_json(msg="Successfully fetched the job info", job_info=msg)
def main(): module = AnsibleModule( argument_spec=dict( # iDRAC credentials idrac_ip=dict(required=True, type='str'), idrac_user=dict(required=True, type='str'), idrac_password=dict(required=True, type='str', aliases=['idrac_pwd'], no_log=True), idrac_port=dict(required=False, default=443, type='int'), # Export Destination share_name=dict(required=True, type='str'), share_password=dict(required=False, type='str', aliases=['share_pwd'], no_log=True), share_user=dict(required=False, type='str'), share_mnt=dict(required=False, type='str'), csior=dict(required=False, choices=['Enabled', 'Disabled'], default='Enabled') ), supports_check_mode=True) try: with iDRACConnection(module.params) as idrac: status = run_setup_idrac_csior(idrac, module) if status.get('Status') == "Success": changed = True msg = "Successfully configured the iDRAC LC attributes." if status.get('Message') and (status.get('Message') == "No changes found to commit!" or "No changes were applied" in status.get('Message')): msg = status.get('Message') changed = False elif status.get('Status') == "Failed": module.fail_json(msg="Failed to configure the iDRAC LC attributes.") module.exit_json(msg=msg, lc_attribute_status=status, changed=changed) else: module.fail_json(msg="Failed to configure the iDRAC LC attributes.") except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (RuntimeError, ImportError, SSLValidationError, IOError, ValueError, TypeError, ConnectionError) as e: module.fail_json(msg=str(e))
def main(): module = AnsibleModule(argument_spec={ "idrac_ip": { "required": True, "type": 'str' }, "idrac_user": { "required": True, "type": 'str' }, "idrac_password": { "required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True }, "idrac_port": { "required": False, "default": 443, "type": 'int' }, }, supports_check_mode=True) try: with iDRACConnection(module.params) as idrac: lcready = idrac.config_mgr.LCReady lcstatus = idrac.config_mgr.LCStatus except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (RuntimeError, SSLValidationError, ConnectionError, KeyError, ImportError, ValueError, TypeError) as e: module.fail_json(msg=str(e)) module.exit_json( msg="Successfully fetched the lifecycle controller status.", lc_status_info={ 'LCReady': lcready, 'LCStatus': lcstatus })
def main(): module = AnsibleModule( argument_spec={ "idrac_ip": {"required": True, "type": 'str'}, "idrac_user": {"required": True, "type": 'str'}, "idrac_password": {"required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True}, "idrac_port": {"required": False, "default": 443, "type": 'int'}, }, supports_check_mode=True) try: with iDRACConnection(module.params) as idrac: msg = idrac.update_mgr.InstalledFirmware except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (RuntimeError, SSLValidationError, IOError, ValueError, TypeError, ConnectionError) as e: module.fail_json(msg=str(e)) module.exit_json(msg="Successfully fetched the firmware inventory details.", firmware_info=msg)
def main(): module = AnsibleModule( argument_spec=dict( # iDRAC credentials idrac_ip=dict(required=True, type='str'), idrac_user=dict(required=True, type='str'), idrac_password=dict(required=True, type='str', aliases=['idrac_pwd'], no_log=True), idrac_port=dict(required=False, default=443, type='int'), # Share Details share_name=dict(required=True, type='str'), share_password=dict(required=False, type='str', aliases=['share_pwd'], no_log=True), share_user=dict(required=False, type='str'), share_mnt=dict(required=False, type='str'), lockdown_mode=dict(required=True, choices=['Enabled', 'Disabled'])), supports_check_mode=False) try: with iDRACConnection(module.params) as idrac: msg = run_system_lockdown_mode(idrac, module) except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (RuntimeError, ImportError, SSLValidationError, IOError, ValueError, TypeError, ConnectionError) as e: module.fail_json(msg=str(e)) module.exit_json(msg=msg["msg"], system_lockdown_status=msg["system_lockdown_status"], changed=msg["changed"])
def main(): module = AnsibleModule(argument_spec={ "idrac_ip": { "required": True, "type": 'str' }, "idrac_user": { "required": True, "type": 'str' }, "idrac_password": { "required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True }, "idrac_port": { "required": False, "default": 443, "type": 'int' } }, supports_check_mode=True) try: with iDRACConnection(module.params) as idrac: msg = run_idrac_reset(idrac, module) except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (RuntimeError, SSLValidationError, ConnectionError, KeyError, ImportError, ValueError, TypeError) as e: module.fail_json(msg=str(e)) module.exit_json(msg="Successfully performed iDRAC reset.", reset_status=msg)
def main(): module = AnsibleModule( argument_spec=dict( # iDRAC credentials idrac_ip=dict(required=True, type='str'), idrac_user=dict(required=True, type='str'), idrac_password=dict(required=True, type='str', aliases=['idrac_pwd'], no_log=True), idrac_port=dict(required=False, default=443, type='int'), # Export Destination share_name=dict(required=True, type='str'), share_password=dict(required=False, type='str', aliases=['share_pwd'], no_log=True), share_user=dict(required=False, type='str'), share_mnt=dict(required=False, type='str'), # setup SNMP Trap Destination destination_number=dict(required=False, type="int"), destination=dict(required=False, type="str"), snmp_v3_username=dict(required=False, type="str"), snmp_trap_state=dict(required=False, choices=["Enabled", "Disabled"], default=None), # setup Email Alerts alert_number=dict(required=False, type="int"), address=dict(required=False, default=None, type="str"), custom_message=dict(required=False, default=None, type="str"), email_alert_state=dict(required=False, choices=["Enabled", "Disabled"], default=None), # setup iDRAC Alerts enable_alerts=dict(required=False, choices=["Enabled", "Disabled"], default=None), # setup SMTP authentication=dict(required=False, choices=['Enabled', 'Disabled'], default=None), smtp_ip_address=dict(required=False, default=None, type='str'), smtp_port=dict(required=False, type='str'), username=dict(required=False, type="str"), password=dict(required=False, type="str", no_log=True), ), supports_check_mode=True) try: with iDRACConnection(module.params) as idrac: status = run_idrac_eventing_config(idrac, module) msg, changed = "Successfully configured the iDRAC eventing settings.", True if status.get('Status') == "Success": if (status.get('Message') == "No changes found to commit!") or \ ("No changes were applied" in status.get('Message')): msg = status.get('Message') changed = False elif status.get('Status') == "Failed": module.fail_json( msg="Failed to configure the iDRAC eventing settings") module.exit_json(msg=msg, eventing_status=status, changed=changed) except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (RuntimeError, ImportError, SSLValidationError, IOError, ValueError, TypeError, ConnectionError) as e: module.fail_json(msg=str(e))
def main(): module = AnsibleModule(argument_spec={ "idrac_ip": { "required": True, "type": 'str' }, "idrac_user": { "required": True, "type": 'str' }, "idrac_password": { "required": True, "type": 'str', "aliases": ["idrac_pwd"], "no_log": True }, "idrac_port": { "required": False, "default": 443, "type": 'int' }, "state": { "required": False, "choices": ['create', 'delete', 'view'], "default": 'view' }, "volume_id": { "required": False, "type": 'str' }, "volumes": { "required": False, "type": 'list', "elements": 'dict' }, "span_depth": { "required": False, "type": 'int', "default": 1 }, "span_length": { "required": False, "type": 'int', "default": 1 }, "number_dedicated_hot_spare": { "required": False, "type": 'int', "default": 0 }, "volume_type": { "required": False, "choices": [ 'RAID 0', 'RAID 1', 'RAID 5', 'RAID 6', 'RAID 10', 'RAID 50', 'RAID 60' ], "default": 'RAID 0' }, "disk_cache_policy": { "required": False, "choices": ["Default", "Enabled", "Disabled"], "default": "Default" }, "write_cache_policy": { "required": False, "choices": ["WriteThrough", "WriteBack", "WriteBackForce"], "default": "WriteThrough" }, "read_cache_policy": { "required": False, "choices": ["NoReadAhead", "ReadAhead", "AdaptiveReadAhead"], "default": "NoReadAhead" }, "stripe_size": { "required": False, "type": 'int', "default": 64 * 1024 }, "capacity": { "required": False, "type": 'float' }, "controller_id": { "required": False, "type": 'str' }, "media_type": { "required": False, "choices": ['HDD', 'SSD'] }, "protocol": { "required": False, "choices": ['SAS', 'SATA'] }, "raid_reset_config": { "required": False, "choices": ['True', 'False'], "default": 'False' }, "raid_init_operation": { "required": False, "choices": ['None', 'Fast'] } }, supports_check_mode=True) try: _validate_options(module.params) with iDRACConnection(module.params) as idrac: storage_status = run_server_raid_config(idrac, module) changed = False if 'changes_applicable' in storage_status: changed = storage_status['changes_applicable'] elif module.params['state'] != 'view': if storage_status.get("Status", "") == "Success": changed = True if storage_status.get("Message", "") == "No changes found to commit!" \ or storage_status.get("Message", "") == "Unable to find the virtual disk": changed = False module.exit_json(msg=storage_status.get('Message', ""), changed=changed, storage_status=storage_status) elif storage_status.get("Status") == "Failed": module.fail_json(msg=storage_status.get("Message")) else: module.fail_json(msg="Failed to perform storage operation") except (ImportError, ValueError, RuntimeError, TypeError) as e: module.fail_json(msg=str(e)) msg = "Successfully completed the {0} storage volume operation".format( module.params['state']) if module.check_mode and module.params['state'] != 'view': msg = storage_status.get("Message", "") module.exit_json(msg=msg, changed=changed, storage_status=storage_status)
def main(): module = AnsibleModule(argument_spec={ "idrac_ip": { "required": True, "type": 'str' }, "idrac_user": { "required": True, "type": 'str' }, "idrac_password": { "required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True }, "idrac_port": { "required": False, "default": 443, "type": 'int' }, "command": { "required": False, "type": 'str', "choices": ['export', 'import'], "default": 'export' }, "job_wait": { "required": True, "type": 'bool' }, "share_name": { "required": True, "type": 'str' }, "share_user": { "required": False, "type": 'str' }, "share_password": { "required": False, "type": 'str', "aliases": ['share_pwd'], "no_log": True }, "scp_components": { "required": False, "choices": ['ALL', 'IDRAC', 'BIOS', 'NIC', 'RAID'], "default": 'ALL' }, "scp_file": { "required": False, "type": 'str' }, "shutdown_type": { "required": False, "choices": ['Graceful', 'Forced', 'NoReboot'], "default": 'Graceful' }, "end_host_power_state": { "required": False, "choices": ['On', 'Off'], "default": 'On' }, "export_format": { "required": False, "type": 'str', "choices": ['JSON', 'XML'], "default": 'XML' }, "export_use": { "required": False, "type": 'str', "choices": ['Default', 'Clone', 'Replace'], "default": 'Default' } }, required_if=[["command", "import", ["scp_file"]]], supports_check_mode=False) try: changed = False http_share = module.params["share_name"].lower().startswith( ('http://', 'https://')) with iDRACConnection( module.params) if not http_share else iDRACRedfishAPI( module.params) as idrac: command = module.params['command'] if command == 'import': if http_share: scp_status = run_export_import_scp_http(idrac, module) if isinstance(scp_status, dict): if scp_status.get("MessageId") == "SYS069": changed = False elif scp_status.get("MessageId") == "SYS053": changed = True else: scp_status = run_import_server_config_profile( idrac, module) if "No changes were applied" not in scp_status.get( 'Message', ""): changed = True elif scp_status.get("MessageId") == "SYS043": changed = True elif scp_status.get("MessageId") == "SYS069": changed = False else: if http_share: scp_status = run_export_import_scp_http(idrac, module) else: scp_status = run_export_server_config_profile( idrac, module) if module.params.get('job_wait'): msg = "Successfully {0}ed the Server Configuration Profile." module.exit_json(changed=changed, msg=msg.format(command), scp_status=scp_status) else: msg = "Successfully triggered the job to {0} the Server Configuration Profile." module.exit_json(msg=msg.format(command), scp_status=scp_status) except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (ImportError, ValueError, RuntimeError, SSLValidationError, ConnectionError, KeyError, TypeError, IndexError) as e: module.fail_json(msg=str(e))
def main(): module = AnsibleModule( argument_spec=dict( # iDRAC credentials idrac_ip=dict(required=True, type='str'), idrac_user=dict(required=True, type='str'), idrac_password=dict(required=True, type='str', aliases=['idrac_pwd'], no_log=True), idrac_port=dict(required=False, default=443, type='int'), # Export Destination share_name=dict(required=True, type='str'), share_password=dict(required=False, type='str', aliases=['share_pwd'], no_log=True), share_user=dict(required=False, type='str'), share_mnt=dict(required=False, type='str'), # setup Webserver enable_web_server=dict(required=False, choices=['Enabled', 'Disabled'], default=None), http_port=dict(required=False, default=None, type='int'), https_port=dict(required=False, default=None, type='int'), ssl_encryption=dict(required=False, choices=[ 'Auto_Negotiate', 'T_128_Bit_or_higher', 'T_168_Bit_or_higher', 'T_256_Bit_or_higher' ], default=None), tls_protocol=dict(required=False, choices=[ 'TLS_1_0_and_Higher', 'TLS_1_1_and_Higher', 'TLS_1_2_Only' ], default=None), timeout=dict(required=False, default=None, type="str"), # set up SNMP settings snmp_enable=dict(required=False, choices=['Enabled', 'Disabled'], default=None), community_name=dict(required=False, type='str'), snmp_protocol=dict(required=False, choices=['All', 'SNMPv3'], default=None), discovery_port=dict(required=False, type="int", default=161), # set up SNMP settings ipmi_lan=dict( required=False, type='dict', options=dict(community_name=dict(required=False, type='str'))), alert_port=dict(required=False, type='int', default=162), trap_format=dict(required=False, choices=['SNMPv1', 'SNMPv2', 'SNMPv3'], default=None), ), supports_check_mode=True) try: with iDRACConnection(module.params) as idrac: status = run_idrac_services_config(idrac, module) if status.get('Status') == "Success": changed = True msg = "Successfully configured the iDRAC services settings." if status.get('Message') and ( status.get('Message') == "No changes found to commit!" or "No changes were applied" in status.get('Message')): msg = status.get('Message') changed = False elif status.get('Status') == "Failed": module.fail_json( msg="Failed to configure the iDRAC services.") module.exit_json(msg=msg, service_status=status, changed=changed) else: module.fail_json(msg="Failed to configure the iDRAC services.") except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except (RuntimeError, ImportError, SSLValidationError, IOError, ValueError, TypeError, ConnectionError) as e: module.fail_json(msg=str(e))
def main(): mutual_exclusive_args = [['boot_sources', 'attributes'], ['boot_sources', 'secure_boot_mode'], ['boot_sources', 'boot_mode'], ['boot_sources', 'boot_sequence'], ['boot_sources', 'nvme_mode'], ['boot_sources', 'onetime_boot_mode']] module = AnsibleModule(argument_spec={ "idrac_ip": { "required": True, "type": 'str' }, "idrac_user": { "required": True, "type": 'str' }, "idrac_password": { "required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True }, "idrac_port": { "required": False, "default": 443, "type": 'int' }, "share_name": { "required": False, "type": 'str' }, "share_user": { "required": False, "type": 'str' }, "share_password": { "required": False, "type": 'str', "aliases": ['share_pwd'], "no_log": True }, "share_mnt": { "required": False, "type": 'str' }, "boot_mode": { "required": False, "choices": ['Bios', 'Uefi'] }, "nvme_mode": { "required": False, "choices": ['NonRaid', 'Raid'] }, "secure_boot_mode": { "required": False, "choices": ['AuditMode', 'DeployedMode', 'SetupMode', 'UserMode'] }, "onetime_boot_mode": { "required": False, "choices": [ 'Disabled', 'OneTimeBootSeq', 'OneTimeCustomBootSeqStr', 'OneTimeCustomHddSeqStr', 'OneTimeCustomUefiBootSeqStr', 'OneTimeHddSeq', 'OneTimeUefiBootSeq' ] }, "boot_sequence": { "required": False, "type": "str" }, "attributes": { "required": False, "type": 'dict' }, "boot_sources": { "required": False, "type": 'list', 'elements': 'raw' } }, mutually_exclusive=mutual_exclusive_args, supports_check_mode=True) try: with iDRACConnection(module.params) as idrac: msg = run_server_bios_config(idrac, module) changed, failed = False, False if msg.get('Status') == "Success": changed = True if msg.get('Message') == "No changes found to commit!": changed = False elif msg.get('Status') == "Failed": failed = True except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except AttributeError as err: if "NoneType" in str(err): module.fail_json( msg="Unable to access the share. Ensure that the share name, " "share mount, and share credentials provided are correct.") except (RuntimeError, SSLValidationError, ConnectionError, KeyError, ImportError, ValueError, TypeError) as e: module.fail_json(msg=str(e)) module.exit_json(msg=msg, changed=changed, failed=failed)
def main(): module = AnsibleModule(argument_spec={ "idrac_ip": { "required": True, "type": 'str' }, "idrac_user": { "required": True, "type": 'str' }, "idrac_password": { "required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True }, "idrac_port": { "required": False, "default": 443, "type": 'int' }, "share_name": { "required": True, "type": 'str' }, "share_user": { "required": False, "type": 'str' }, "share_password": { "required": False, "type": 'str', "aliases": ['share_pwd'], "no_log": True }, "share_mnt": { "required": False, "type": 'str' }, "catalog_file_name": { "required": False, "type": 'str', "default": "Catalog.xml" }, "reboot": { "required": False, "type": 'bool', "default": False }, "job_wait": { "required": False, "type": 'bool', "default": True }, "ignore_cert_warning": { "required": False, "type": 'bool', "default": True }, "apply_update": { "required": False, "type": 'bool', "default": True }, }, supports_check_mode=True) redfish_check = False try: with iDRACRedfishAPI(module.params) as obj: resp = obj.invoke_request(IDRAC_PATH, method="GET") idrac_data = resp.json_data if idrac_data: firm_id = idrac_data.get("FirmwareVersion") firmware_version = re.match(r"^\d.\d{2}", firm_id).group() if float(firmware_version) >= float(REDFISH_VERSION): redfish_check = True except (HTTPError, RuntimeError, URLError, SSLValidationError, ConnectionError, KeyError, ImportError, ValueError, TypeError, SSLError) as e: redfish_check = False try: # Validate the catalog file _validate_catalog_file(module.params['catalog_file_name']) if module.check_mode: module.params['apply_update'] = False module.params['reboot'] = False module.params['job_wait'] = True # Connect to iDRAC and update firmware if redfish_check: with iDRACRedfishAPI(module.params) as redfish_obj: status = update_firmware_redfish(redfish_obj, module) else: with iDRACConnection(module.params) as idrac: status = update_firmware_omsdk(idrac, module) except HTTPError as err: module.fail_json(msg=str(err), update_status=json.load(err)) except (RuntimeError, URLError, SSLValidationError, ConnectionError, KeyError, ImportError, ValueError, TypeError) as e: module.fail_json(msg=str(e)) module.exit_json(msg=status['update_msg'], update_status=status['update_status'], changed=status['changed'], failed=status['failed'])
def main(): module = AnsibleModule( argument_spec={ # iDRAC credentials "idrac_ip": { "required": True, "type": 'str' }, "idrac_user": { "required": True, "type": 'str' }, "idrac_password": { "required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True }, "idrac_port": { "required": False, "default": 443, "type": 'int' }, # Export Destination "share_name": { "required": True, "type": 'str' }, "share_password": { "required": False, "type": 'str', "aliases": ['share_pwd'], "no_log": True }, "share_user": { "required": False, "type": 'str' }, "share_mnt": { "required": False, "type": 'str' }, # setup DNS "register_idrac_on_dns": { "required": False, "choices": ['Enabled', 'Disabled'], "default": None }, "dns_idrac_name": { "required": False, "default": None, "type": 'str' }, "auto_config": { "required": False, "choices": ['Enabled', 'Disabled'], "default": None, 'type': 'str' }, "static_dns": { "required": False, "default": None, "type": "str" }, # set up idrac vlan "setup_idrac_nic_vlan": { "required": False, "choices": ['Enabled', 'Disabled'] }, "vlan_id": { "required": False, "type": 'int' }, "vlan_priority": { "required": False, "type": 'int' }, # set up NIC "enable_nic": { "required": False, "choices": ['Enabled', 'Disabled'], "default": None }, "nic_selection": { "required": False, "choices": ['Dedicated', 'LOM1', 'LOM2', 'LOM3', 'LOM4'], "default": None }, "failover_network": { "required": False, "choices": ['ALL', 'LOM1', 'LOM2', 'LOM3', 'LOM4', 'T_None'], "default": None }, "auto_detect": { "required": False, "choices": ['Enabled', 'Disabled'], "default": None }, "auto_negotiation": { "required": False, "choices": ['Enabled', 'Disabled'], "default": None }, "network_speed": { "required": False, "choices": ['T_10', 'T_100', 'T_1000'], "default": None }, "duplex_mode": { "required": False, "choices": ['Full', 'Half'], "default": None }, "nic_mtu": { "required": False, 'type': 'int' }, # setup iDRAC IPV4 "ip_address": { "required": False, "default": None, "type": "str" }, "enable_dhcp": { "required": False, "choices": ["Enabled", "Disabled"], "default": None }, "enable_ipv4": { "required": False, "choices": ["Enabled", "Disabled"], "default": None }, # setup iDRAC Static IPv4 "dns_from_dhcp": { "required": False, "choices": ["Enabled", "Disabled"], "default": None }, "static_dns_1": { "required": False, "default": None, "type": "str" }, "static_dns_2": { "required": False, "default": None, "type": "str" }, "static_gateway": { "required": False, "type": "str" }, "static_net_mask": { "required": False, "type": "str" }, }, supports_check_mode=True) try: with iDRACConnection(module.params) as idrac: msg = run_idrac_network_config(idrac, module) changed, failed = False, False if msg.get('Status') == "Success": changed = True if msg.get('Message') == "No changes found to commit!": changed = False if "No changes were applied" in msg.get('Message'): changed = False elif msg.get('Status') == "Failed": failed = True except HTTPError as err: module.fail_json(msg=str(err), error_info=json.load(err)) except URLError as err: module.exit_json(msg=str(err), unreachable=True) except AttributeError as err: if "NoneType" in str(err): module.fail_json( msg="Unable to access the share. Ensure that the share name, " "share mount, and share credentials provided are correct.") except (RuntimeError, SSLValidationError, ConnectionError, KeyError, ImportError, ValueError, TypeError) as e: module.fail_json(msg=str(e)) module.exit_json(msg="Successfully configured the idrac network settings.", network_status=msg, changed=changed, failed=failed)