dell / dellemc-openmanage-ansible-modules

Dell OpenManage Ansible Modules
GNU General Public License v3.0
329 stars 162 forks source link

IPV6 not parsed: idrac_server_config_profile #162

Closed janr7 closed 3 years ago

janr7 commented 3 years ago

Hi

Our IDRAC have both IPV4 and IPV6 configured. If idrac_ip is configured to used the IP name, itadell135c,, the IPV6 address is looked up and used in the play.

Could you please assist?

If this is used it works as no lookup is needed: idrac_ip: "10.145.103.135" This does not work: idrac_ip: "itadell135c" ( this looks up the IPV6 and cannot parse ) idrac_ip: "2a03:1e80:f803:500:0:0:1000:235"

Ansible suggests to use ipwrap for IPV6 addresses but does not work with this module.

idrac_ip: "{{ idrac_ip | ipwrap }}"

Looks like the encapsulating the IPV6 with [] is not happening. https://2a03:1e80:f804:502::1000:135:443 should look like this? https://[2a03:1e80:f804:502::1000:135]:443

Model | PowerEdge R740xd Operating System | SUSE Linux Enterprise Server Operating System Version | Version 12 SP4 Kernel 4.12.14-95.57-default (x86_64) BIOS Version | 2.8.2 iDRAC Firmware Version | 4.22.00.53

fatal: [localhost]: FAILED! => { "changed": false, "invocation": { "module_args": { "command": "import", "end_host_power_state": "On", "export_format": "XML", "export_use": "Default", "idrac_ip": "itadell135c", "idrac_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "idrac_port": 443, "idrac_user": "Laboradmin", "job_wait": true, "scp_components": "BIOS", "scp_file": "itadell1135_bios_scp.xml", "share_name": "/tmp", "share_password": null, "share_user": null, "shutdown_type": "Graceful" } }, "msg": "Failed to import scp.", "scp_status": { "Data": { "Message": "Failed to execute redfish request: Failed to parse: https://2a03:1e80:f804:502::1000:135:443/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ImportSystemConfiguration", "Status": "Failed" }, "Message": "none", "Status": "Failed", "file": "/tmp/itadell1135_bios_scp.xml", "retval": true } } ` collections:

anupamaloke commented 3 years ago

@janr7, I tried the ipwrap filter to wrap the IPv6 address and it properly wraps it in square brackets.

[inventory]

[idrac]
FE80:0000:0000:5EFE:0192.0168.0001.0123

[playbook]

  tasks:
    - name: Print IPv6
      debug:
        msg: "{{ inventory_hostname | ansible.netcommon.ipwrap }}"

[playbook run]

$ ansible-playbook ipv6.yml -i hosts

PLAY [idrac] *******************************************************************

TASK [Print IPv6] **************************************************************
ok: [FE80:0000:0000:5EFE:0192.0168.0001.0123] => {
    "msg": "[FE80:0000:0000:5EFE:0192.0168.0001.0123]"
}

PLAY RECAP *********************************************************************
FE80:0000:0000:5EFE:0192.0168.0001.0123 : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
Wobak commented 3 years ago

Hi

I can confirm that the IPv6 works in certain modules but not this one, even in ipwrap.

So it probably needs reviewing :

[root@ansible idrac]# cat host_vars/r840/vars.yml
my_user: root
my_pass: xxx
my_ip: 2a03:1e80:f804:502::1000:135
ansible_host: localhost
---
- name: Get iDRAC info
  hosts: r840
  tasks:
  - name: Get Installed Firmware Inventory
    dellemc_get_firmware_inventory:
        idrac_ip: "{{ my_ip }}"
        idrac_user: "{{ my_user }}"
        idrac_password: "{{ my_pass }}"
    register: result_fw
    delegate_to: localhost

  - name: View specific volume details.
    dellemc_idrac_storage_volume:
      idrac_ip: "{{ my_ip }}"
      idrac_user: "{{ my_user }}"
      idrac_password: "{{ my_pass }}"
      state: "view"
      controller_id: "RAID.Slot.1-1"
      volume_id: "Disk.Virtual.0:RAID.Slot.1-1"
    register: result_sto
    delegate_to: localhost

  - name: Apply Server config profile
    idrac_server_config_profile:
      idrac_ip: "{{ my_ip }}"
      idrac_user: "{{ my_user }}"
      idrac_password: "{{ my_pass }}"
      share_name: "/tmp/"
      command: import
      shutdown_type: "NoReboot"
      scp_file: "r840-thibaut.xml"
      job_wait: "False"
      end_host_power_state: "On"
    delegate_to: localhost
    register: result_config
[root@ansible idrac]# ansible-playbook idrac_case_problem.yml

PLAY [Get iDRAC info] ****************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
ok: [r840]

TASK [Get Installed Firmware Inventory] **********************************************************************************************************************************************************************
ok: [r840 -> localhost]

TASK [View specific volume details.] *************************************************************************************************************************************************************************
ok: [r840 -> localhost]

TASK [Apply Server config profile] ***************************************************************************************************************************************************************************
fatal: [r840 -> localhost]: FAILED! => {"changed": false, "msg": "Failed to import scp.", "scp_status": {"Data": {"Message": "Failed to execute redfish request: Failed to parse: 2a03:1e80:f804:502::1000:135:443", "Status": "Failed"}, "Message": "none", "Status": "Failed", "file": "/tmp//r840-thibaut.xml", "retval": true}}

PLAY RECAP ***************************************************************************************************************************************************************************************************
r840                       : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

When using ipwrap :

fatal: [r840 -> localhost]: FAILED! => {"changed": false, "module_stderr": "[2a03:1e80:f804:502::1000:135]: [Errno -2] Name or service not known: cannot resolve hostname!\nTraceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1603357141.304522-49384097423356/AnsiballZ_idrac_server_config_profile.py\", line 114, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1603357141.304522-49384097423356/AnsiballZ_idrac_server_config_profile.py\", line 106, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1603357141.304522-49384097423356/AnsiballZ_idrac_server_config_profile.py\", line 49, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/usr/lib64/python3.6/imp.py\", line 235, in load_module\n    return load_source(name, filename, file)\n  File \"/usr/lib64/python3.6/imp.py\", line 170, in load_source\n    module = _exec(spec, sys.modules[name])\n  File \"<frozen importlib._bootstrap>\", line 618, in _exec\n  File \"<frozen importlib._bootstrap_external>\", line 678, in exec_module\n  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n  File \"/tmp/ansible_idrac_server_config_profile_payload_8athhxui/__main__.py\", line 329, in <module>\n  File \"/tmp/ansible_idrac_server_config_profile_payload_8athhxui/__main__.py\", line 311, in main\n  File \"/tmp/ansible_idrac_server_config_profile_payload_8athhxui/ansible_idrac_server_config_profile_payload.zip/ansible/module_utils/remote_management/dellemc/dellemc_idrac.py\", line 47, in __enter__\n  File \"/usr/local/lib/python3.6/site-packages/omsdk/sdkinfra.py\", line 144, in get_driver\n    return self._create_driver(mod, ipaddr, creds, protopref, pOptions)\n  File \"/usr/local/lib/python3.6/site-packages/omsdk/sdkinfra.py\", line 172, in _create_driver\n    hostname, aliaslist, addresslist = socket.gethostbyaddr(ipaddr)\nsocket.gaierror: [Errno -2] Name or service not known\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
jagadeeshnv commented 3 years ago

@janr7 Can you please verify with the latest code, for idrac_server_config_profile