fortinet-ansible-dev / ansible-galaxy-fortios-collection

GNU General Public License v3.0
85 stars 49 forks source link

Request for example usage of module fortios_hardware_nic #175

Closed refriedjello closed 10 months ago

refriedjello commented 2 years ago

I have been trying to get the module fortios_hardware_nic working to display NIC information but so far have been unsuccessful.

I am able to interact with my FortiGate using other modules, so connectivity and authentication is successful.

My lab FortiGate is a 201E running 6.2.10 and is running VDOMs. I would like to display NIC status information for the NIC "mgmt" which is owned by the VDOM "root". I am using Ansible version 2.11.3 and collection fortinet.fortios is version 2.1.4.

Here is my playbook task:

  - name: nic hardware
    fortinet.fortios.fortios_hardware_nic:
      vdom: root
      hardware_nic:
        <nic>: mgmt

When I run that I get this error:

The full traceback is:
Traceback (most recent call last):
  File "/tmp/.ansible/ansible-local-31231p1kfu8dh/ansible-tmp-1649780607.8892927-31241-86002084875118/AnsiballZ_fortios_hardware_nic.py", line 100, in <module>
    _ansiballz_main()
  File "/tmp/.ansible/ansible-local-31231p1kfu8dh/ansible-tmp-1649780607.8892927-31241-86002084875118/AnsiballZ_fortios_hardware_nic.py", line 92, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/tmp/.ansible/ansible-local-31231p1kfu8dh/ansible-tmp-1649780607.8892927-31241-86002084875118/AnsiballZ_fortios_hardware_nic.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.fortinet.fortios.plugins.modules.fortios_hardware_nic', init_globals=dict(_module_fqn='ansible_collections.fortinet.fortios.plugins.modules.fortios_hardware_nic', _modlib_path=modlib_path),
  File "/usr/local/lib/python3.9/runpy.py", line 210, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/local/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_fortinet.fortios.fortios_hardware_nic_payload_jjolvdvi/ansible_fortinet.fortios.fortios_hardware_nic_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_hardware_nic.py", line 326, in <module>
  File "/tmp/ansible_fortinet.fortios.fortios_hardware_nic_payload_jjolvdvi/ansible_fortinet.fortios.fortios_hardware_nic_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_hardware_nic.py", line 305, in main
  File "/tmp/ansible_fortinet.fortios.fortios_hardware_nic_payload_jjolvdvi/ansible_fortinet.fortios.fortios_hardware_nic_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_hardware_nic.py", line 224, in fortios_hardware
  File "/tmp/ansible_fortinet.fortios.fortios_hardware_nic_payload_jjolvdvi/ansible_fortinet.fortios.fortios_hardware_nic_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_hardware_nic.py", line 208, in hardware_nic
  File "/tmp/ansible_fortinet.fortios.fortios_hardware_nic_payload_jjolvdvi/ansible_fortinet.fortios.fortios_hardware_nic_payload.zip/ansible_collections/fortinet/fortios/plugins/module_utils/fortios/fortios.py", line 600, in set
  File "/tmp/ansible_fortinet.fortios.fortios_hardware_nic_payload_jjolvdvi/ansible_fortinet.fortios.fortios_hardware_nic_payload.zip/ansible/module_utils/connection.py", line 195, in __rpc__
ansible.module_utils.connection.ConnectionError: Remote end closed connection without response
fatal: [mylab.fortigate.net]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/.ansible/ansible-local-31231p1kfu8dh/ansible-tmp-1649780607.8892927-31241-86002084875118/AnsiballZ_fortios_hardware_nic.py\", line 100, in <module>\n    _ansiballz_main()\n  File \"/tmp/.ansible/ansible-local-31231p1kfu8dh/ansible-tmp-1649780607.8892927-31241-86002084875118/AnsiballZ_fortios_hardware_nic.py\", line 92, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/tmp/.ansible/ansible-local-31231p1kfu8dh/ansible-tmp-1649780607.8892927-31241-86002084875118/AnsiballZ_fortios_hardware_nic.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.fortinet.fortios.plugins.modules.fortios_hardware_nic', init_globals=dict(_module_fqn='ansible_collections.fortinet.fortios.plugins.modules.fortios_hardware_nic', _modlib_path=modlib_path),\n  File \"/usr/local/lib/python3.9/runpy.py\", line 210, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/local/lib/python3.9/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/local/lib/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_fortinet.fortios.fortios_hardware_nic_payload_jjolvdvi/ansible_fortinet.fortios.fortios_hardware_nic_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_hardware_nic.py\", line 326, in <module>\n  File \"/tmp/ansible_fortinet.fortios.fortios_hardware_nic_payload_jjolvdvi/ansible_fortinet.fortios.fortios_hardware_nic_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_hardware_nic.py\", line 305, in main\n  File \"/tmp/ansible_fortinet.fortios.fortios_hardware_nic_payload_jjolvdvi/ansible_fortinet.fortios.fortios_hardware_nic_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_hardware_nic.py\", line 224, in fortios_hardware\n  File \"/tmp/ansible_fortinet.fortios.fortios_hardware_nic_payload_jjolvdvi/ansible_fortinet.fortios.fortios_hardware_nic_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_hardware_nic.py\", line 208, in hardware_nic\n  File \"/tmp/ansible_fortinet.fortios.fortios_hardware_nic_payload_jjolvdvi/ansible_fortinet.fortios.fortios_hardware_nic_payload.zip/ansible_collections/fortinet/fortios/plugins/module_utils/fortios/fortios.py\", line 600, in set\n  File \"/tmp/ansible_fortinet.fortios.fortios_hardware_nic_payload_jjolvdvi/ansible_fortinet.fortios.fortios_hardware_nic_payload.zip/ansible/module_utils/connection.py\", line 195, in __rpc__\nansible.module_utils.connection.ConnectionError: Remote end closed connection without response\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

The error says "Remote end closed connection without response" but as mentioned, I am able to get other modules to work against this same FortiGate.

Thanks!

JieX19 commented 2 years ago

@refriedjello fortios_configuration_fact is used to retrieve the information about a specific module.

Here's an example:

- hosts: fortigates
  collections:
  - fortinet.fortios
  connection: httpapi
  vars:
   vdom: "root"
   ansible_httpapi_use_ssl: yes
   ansible_httpapi_validate_certs: no
   ansible_httpapi_port: 443
  tasks:
  - name: get hardware nic info
    fortios_configuration_fact:
     selectors:
      - selector: hardware_nic

fortios_hardware_nic is used to update the information.

JieX19 commented 10 months ago

Hi @refriedjello

I will close this issue as it's been a while and no further updates or responses have been received, indicating that the matter has likely been resolved or is no longer active.

If you have any further questions or concerns, please feel free to reopen the ticket or create a new one.