ansibleguy/collection_opnsense

Invalid IDNA hostname

Egor-Ozhmegoff opened this issue · 8 comments

Modules

All modules

Version

ansibleguy.opnsense           1.2.8

Ansible Version

ansible [core 2.15.8]
  config file = /Users/eozhmegov/Repos/nautobot-device-config/ansible.cfg
  configured module search path = ['/Users/eozhmegov/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/eozhmegov/Library/Python/3.9/lib/python/site-packages/ansible
  ansible collection location = /Users/eozhmegov/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.6 (default, Nov 10 2023, 13:38:27) [Clang 15.0.0 (clang-1500.1.0.2.5)] (/Library/Developer/CommandLineTools/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

OPNSense Version

23.7.11

OPNSense-Plugin Version

No response

Issue

I created palybook and tried to create vlan interface but i got an error

Config Ansible

inventory
opnsense:
  hosts:
    opnsense_test:
      ansible_host: 10.64.244.2

role

- name: Add Vlan interface
  ansibleguy.opnsense.interface_vlan:
    debug: true
    profiling: true
    firewall: "10.64.244.2"
    ssl_verify: false
    api_key: "{{ api_key }}"
    api_secret: "{{ api_secret }}"
    description: "{{ item.description }}"
    interface: "{{ item.interface }}"
    vlan: "{{ item.vlan }}"
    state: 'present'
  loop: "{{ vlan_interfaces }}"

playbook

---
- name: opnsense
  hosts: opnsense
  gather_facts: no
  roles:
    - role: interface_vlan
      tags:
        - interface_vlan

Config OPNSense

No response

Debug Output

<10.64.244.2> attempting to start connection
<10.64.244.2> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /usr/local/bin/ansible-connection
<10.64.244.2> found existing local domain socket, using it!
<10.64.244.2> updating play_context for connection
<10.64.244.2> Loading collection ansible.builtin from
<10.64.244.2> local domain socket path is /Users/eozhmegov/.ansible/pc/92153acdae
<10.64.244.2> ESTABLISH LOCAL CONNECTION FOR USER: eozhmegov
<10.64.244.2> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy `"&& mkdir "` echo /Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/ansible-tmp-1705655827.2279449-48280-142015464034077 `" && echo ansible-tmp-1705655827.2279449-48280-142015464034077="` echo /Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/ansible-tmp-1705655827.2279449-48280-142015464034077 `" ) && sleep 0'
Using module file /Users/eozhmegov/.ansible/collections/ansible_collections/ansibleguy/opnsense/plugins/modules/interface_vlan.py
<10.64.244.2> PUT /Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/tmp978_1myx TO /Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/ansible-tmp-1705655827.2279449-48280-142015464034077/AnsiballZ_interface_vlan.py
<10.64.244.2> EXEC /bin/sh -c 'chmod u+x /Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/ansible-tmp-1705655827.2279449-48280-142015464034077/ /Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/ansible-tmp-1705655827.2279449-48280-142015464034077/AnsiballZ_interface_vlan.py && sleep 0'
<10.64.244.2> EXEC /bin/sh -c '/usr/bin/env python3 /Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/ansible-tmp-1705655827.2279449-48280-142015464034077/AnsiballZ_interface_vlan.py && sleep 0'
<10.64.244.2> EXEC /bin/sh -c 'rm -f -r /Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/ansible-tmp-1705655827.2279449-48280-142015464034077/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_urlparse.py", line 325, in encode_host
    return idna.encode(host.lower()).decode("ascii")
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/idna/core.py", line 360, in encode
    s = alabel(label)
        ^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/idna/core.py", line 269, in alabel
    check_label(label)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/idna/core.py", line 250, in check_label
    raise InvalidCodepoint('Codepoint {} at position {} of {} not allowed'.format(_unot(cp_value), pos+1, repr(label)))
idna.core.InvalidCodepoint: Codepoint U+002A at position 1 of '*’*’' not allowed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/ansible-tmp-1705655827.2279449-48280-142015464034077/AnsiballZ_interface_vlan.py", line 107, in <module>
    _ansiballz_main()
  File "/Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/ansible-tmp-1705655827.2279449-48280-142015464034077/AnsiballZ_interface_vlan.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/ansible-tmp-1705655827.2279449-48280-142015464034077/AnsiballZ_interface_vlan.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.ansibleguy.opnsense.plugins.modules.interface_vlan', init_globals=dict(_module_fqn='ansible_collections.ansibleguy.opnsense.plugins.modules.interface_vlan', _modlib_path=modlib_path),
  File "<frozen runpy>", line 226, in run_module
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/modules/interface_vlan.py", line 74, in <module>
  File "/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/modules/interface_vlan.py", line 70, in main
  File "/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/modules/interface_vlan.py", line 63, in run_module
  File "/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/module_utils/main/interface_vlan.py", line 43, in __init__
  File "/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/module_utils/base/cls.py", line 19, in __init__
  File "/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/module_utils/base/api.py", line 24, in __init__
  File "/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/module_utils/base/api.py", line 29, in start
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_client.py", line 696, in __init__
    self._mounts: typing.Dict[URLPattern, typing.Optional[BaseTransport]] = {
                                                                            ^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_client.py", line 697, in <dictcomp>
    URLPattern(key): None
    ^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_utils.py", line 370, in __init__
    url = URL(pattern)
          ^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_urls.py", line 115, in __init__
    self._uri_reference = urlparse(url, **kwargs)
                          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_urlparse.py", line 245, in urlparse
    parsed_host: str = encode_host(host)
                       ^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_urlparse.py", line 327, in encode_host
    raise InvalidURL(f"Invalid IDNA hostname: {host!r}")
httpx.InvalidURL: Invalid IDNA hostname: '*’*’'
failed: [opnsense_test] (item={'vlan': 1210, 'interface': 'lagg0', 'description': 'Bozon_DMZ'}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": {
        "description": "Bozon_DMZ",
        "interface": "lagg0",
        "vlan": 1210
    },
    "module_stderr": "Traceback (most recent call last):\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_urlparse.py\", line 325, in encode_host\n    return idna.encode(host.lower()).decode(\"ascii\")\n           ^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/idna/core.py\", line 360, in encode\n    s = alabel(label)\n        ^^^^^^^^^^^^^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/idna/core.py\", line 269, in alabel\n    check_label(label)\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/idna/core.py\", line 250, in check_label\n    raise InvalidCodepoint('Codepoint {} at position {} of {} not allowed'.format(_unot(cp_value), pos+1, repr(label)))\nidna.core.InvalidCodepoint: Codepoint U+002A at position 1 of '*’*’' not allowed\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/ansible-tmp-1705655827.2279449-48280-142015464034077/AnsiballZ_interface_vlan.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/ansible-tmp-1705655827.2279449-48280-142015464034077/AnsiballZ_interface_vlan.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/Users/eozhmegov/.ansible/tmp/ansible-local-48277lki0plgy/ansible-tmp-1705655827.2279449-48280-142015464034077/AnsiballZ_interface_vlan.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.ansibleguy.opnsense.plugins.modules.interface_vlan', init_globals=dict(_module_fqn='ansible_collections.ansibleguy.opnsense.plugins.modules.interface_vlan', _modlib_path=modlib_path),\n  File \"<frozen runpy>\", line 226, in run_module\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/modules/interface_vlan.py\", line 74, in <module>\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/modules/interface_vlan.py\", line 70, in main\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/modules/interface_vlan.py\", line 63, in run_module\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/module_utils/main/interface_vlan.py\", line 43, in __init__\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/module_utils/base/cls.py\", line 19, in __init__\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/module_utils/base/api.py\", line 24, in __init__\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_0rykgfxo/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/module_utils/base/api.py\", line 29, in start\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_client.py\", line 696, in __init__\n    self._mounts: typing.Dict[URLPattern, typing.Optional[BaseTransport]] = {\n                                                                            ^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_client.py\", line 697, in <dictcomp>\n    URLPattern(key): None\n    ^^^^^^^^^^^^^^^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_utils.py\", line 370, in __init__\n    url = URL(pattern)\n          ^^^^^^^^^^^^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_urls.py\", line 115, in __init__\n    self._uri_reference = urlparse(url, **kwargs)\n                          ^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_urlparse.py\", line 245, in urlparse\n    parsed_host: str = encode_host(host)\n                       ^^^^^^^^^^^^^^^^^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_urlparse.py\", line 327, in encode_host\n    raise InvalidURL(f\"Invalid IDNA hostname: {host!r}\")\nhttpx.InvalidURL: Invalid IDNA hostname: '*’*’'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Profiling Output

No response

Make sure to set connection: local as seen in the docs:
https://opnsense.ansibleguy.net/en/latest/usage/2_basic.html#inventory

I added connection: local to playbook but i got the same error

---
- name: opnsense
  hosts: opnsense
  gather_facts: no
  connection: local
  roles:
    - role: interface_vlan
      tags:
        - interface_vlan
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: httpx.InvalidURL: Invalid IDNA hostname: '*’*’'
failed: [opnsense_test] (item={'vlan': 1200, 'interface': 'lagg0', 'description': 'Bozon_PROD'}) => {"ansible_loop_var": "item", "changed": false, "item": {"description": "Bozon_PROD", "interface": "lagg0", "vlan": 1200}, "module_stderr": "Traceback (most recent call last):\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_urlparse.py\", line 325, in encode_host\n    return idna.encode(host.lower()).decode(\"ascii\")\n           ^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/idna/core.py\", line 360, in encode\n    s = alabel(label)\n        ^^^^^^^^^^^^^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/idna/core.py\", line 269, in alabel\n    check_label(label)\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/idna/core.py\", line 250, in check_label\n    raise InvalidCodepoint('Codepoint {} at position {} of {} not allowed'.format(_unot(cp_value), pos+1, repr(label)))\nidna.core.InvalidCodepoint: Codepoint U+002A at position 1 of '*’*’' not allowed\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/Users/eozhmegov/.ansible/tmp/ansible-local-52457uow1du70/ansible-tmp-1705661966.2217119-52460-250333583418229/AnsiballZ_interface_vlan.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/Users/eozhmegov/.ansible/tmp/ansible-local-52457uow1du70/ansible-tmp-1705661966.2217119-52460-250333583418229/AnsiballZ_interface_vlan.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/Users/eozhmegov/.ansible/tmp/ansible-local-52457uow1du70/ansible-tmp-1705661966.2217119-52460-250333583418229/AnsiballZ_interface_vlan.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.ansibleguy.opnsense.plugins.modules.interface_vlan', init_globals=dict(_module_fqn='ansible_collections.ansibleguy.opnsense.plugins.modules.interface_vlan', _modlib_path=modlib_path),\n  File \"<frozen runpy>\", line 226, in run_module\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_snt7lyyv/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/modules/interface_vlan.py\", line 74, in <module>\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_snt7lyyv/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/modules/interface_vlan.py\", line 70, in main\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_snt7lyyv/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/modules/interface_vlan.py\", line 63, in run_module\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_snt7lyyv/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/module_utils/main/interface_vlan.py\", line 43, in __init__\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_snt7lyyv/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/module_utils/base/cls.py\", line 19, in __init__\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_snt7lyyv/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/module_utils/base/api.py\", line 24, in __init__\n  File \"/var/folders/vg/53v4gk1d0_92crvnv3gws_dw0000gn/T/ansible_ansibleguy.opnsense.interface_vlan_payload_snt7lyyv/ansible_ansibleguy.opnsense.interface_vlan_payload.zip/ansible_collections/ansibleguy/opnsense/plugins/module_utils/base/api.py\", line 29, in start\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_client.py\", line 696, in __init__\n    self._mounts: typing.Dict[URLPattern, typing.Optional[BaseTransport]] = {\n                                                                            ^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_client.py\", line 697, in <dictcomp>\n    URLPattern(key): None\n    ^^^^^^^^^^^^^^^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_utils.py\", line 370, in __init__\n    url = URL(pattern)\n          ^^^^^^^^^^^^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_urls.py\", line 115, in __init__\n    self._uri_reference = urlparse(url, **kwargs)\n                          ^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_urlparse.py\", line 245, in urlparse\n    parsed_host: str = encode_host(host)\n                       ^^^^^^^^^^^^^^^^^\n  File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_urlparse.py\", line 327, in encode_host\n    raise InvalidURL(f\"Invalid IDNA hostname: {host!r}\")\nhttpx.InvalidURL: Invalid IDNA hostname: '*’*’'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Edit: Code block

Is the firewall parameter also defined?

module_defaults:
  group/ansibleguy.opnsense.all:
    firewall: "{{ inventory_hostname }}"

https://opnsense.ansibleguy.net/en/latest/usage/2_basic.html#defaults

I've added it to my ansible role

- name: Add Vlan interface
  ansibleguy.opnsense.interface_vlan:
    debug: true
    profiling: true
    firewall: "10.64.244.2"

Interesting behavior indeed.
We basically pass the firewall parameter to httpx without modifying it: https://github.com/ansibleguy/collection_opnsense/blob/latest/plugins/module_utils/base/api.py#L33

You are on MacOS, if I see that correctly?

Could you please provide me your httpx version?
python3 -m pip list | grep httpx

Yes Mac OS 14.2.1, httpx 0.26.0

Alright.
I have some Mac's laying around at work - I will try to reproduce the error on them.

On linux machines I was able to successfully run it:

(Note: I run on latest and also with httpx 0.26.0)

Inventory:

---

all:
  hosts:
    opn-test:
      ansible_host: '172.17.1.52'

Playbook:

---

- name: Test OPNSense
  hosts: opn-test
  gather_facts: false
  connection: local
  module_defaults:
    group/ansibleguy.opnsense.all:
      firewall: "{{ ansible_host }}"
      api_credential_file: 'opn.txt'
      ssl_verify: false

  tasks:
    - name: Add Vlan interface
      ansibleguy.opnsense.interface_vlan:
        debug: true
        description: "{{ item.desc }}"
        interface: "{{ item.int }}"
        vlan: "{{ item.vlan }}"
        state: 'present'
      with_items:
        - {int: 'vtnet1', vlan: 4000, desc: 'test'}

Output:

guy@machine$ ansible-playbook test-opn.yml -i inv/test/hosts.yml --limit opn-test

PLAY [Test OPNSense] ****************************************************************************************************************

TASK [Add Vlan interface] ***********************************************************************************************************
changed: [opn-test] => (item={'int': 'vtnet1', 'vlan': 4000, 'desc': 'test'})
[WARNING]: REQUEST: GET | URL: https://172.17.1.52/api/interfaces/vlan_settings/get
[WARNING]: RESPONSE: '{'status_code': 200, '_request': <Request('GET', 'https://172.17.1.52/api/interfaces/vlan_settings/get')>,
'_num_bytes_downloaded': 20, '_elapsed': datetime.timedelta(microseconds=309159), '_content': b'{"vlan":{"vlan":[]}}'}'
[WARNING]: REQUEST: POST | URL: https://172.17.1.52/api/interfaces/vlan_settings/addItem | HEADERS: '{'Content-Type':
'application/json'}' | DATA: '{"vlan": {"descr": "test", "if": "vtnet1", "tag": 4000, "pcp": 0}}'
[WARNING]: RESPONSE: '{'status_code': 200, '_request': <Request('POST',
'https://172.17.1.52/api/interfaces/vlan_settings/addItem')>, '_num_bytes_downloaded': 64, '_elapsed':
datetime.timedelta(microseconds=164857), '_content': b'{"result":"saved","uuid":"1f958195-f34e-4054-b883-d66458014dcf"}'}'
[WARNING]: REQUEST: POST | URL: https://172.17.1.52/api/interfaces/vlan_settings/reconfigure | HEADERS: '{}'
[WARNING]: RESPONSE: '{'status_code': 200, '_request': <Request('POST',
'https://172.17.1.52/api/interfaces/vlan_settings/reconfigure')>, '_num_bytes_downloaded': 15, '_elapsed':
datetime.timedelta(microseconds=111177), '_content': b'{"status":"ok"}'}'
```