Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: multiple results returned for untagged_vlan when vlan & vlan_group for interface is defined #1237

Open
sebastianreifetshammer opened this issue May 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@sebastianreifetshammer
Copy link

sebastianreifetshammer commented May 22, 2024

Ansible NetBox Collection version

v3.18.0

Ansible version

ansible [core 2.15.4]
  config file = /opt/ansible/ansible-playbooks/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/ansible/ansible-venv/lib/python3.10/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/ansible/ansible-venv/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/opt/ansible/ansible-venv/bin/python3)
  jinja version = 3.1.2
  libyaml = True

NetBox version

v.4.0.2

Python version

3.10

Steps to Reproduce

this is a setup to reproduce this issue, in my prod. i have multiple vlans with the same vlan-id & name but in different vlan_groups

netbox:

site_group:

  • name: hq

site:

  • name: main
    associated to site_group 'hq'

vlan_group:

  • name: access-vlan
    associated to scope site_group 'hq'

vlan:

  • name: VLAN100
  • name: VLAN200
    both vlans in vlan_group 'access-vlan'

device:

  • name switch1
    associated to site 'main'
  • interface GigabitEthernet1/0/1

ansible

- name: Add access interface to NetBox
  netbox.netbox.netbox_device_interface:
    netbox_url: "{{ netbox_url }}"
    netbox_token: "{{ netbox_api_key }}"
    data:
      device: switch1
      name: interface GigabitEthernet1/0/1
      mode: access
      untagged_vlan:
        - name: VLAN100
        - vlan_group: access-vlan

Expected Behavior

Expected to update interface GigabitEthernet1/0/1 mode access, untagged_vlan to VLAN100 from vlan_group access-vlan

Observed Behavior

The full traceback is:
  File "/tmp/ansible_netbox.netbox.netbox_device_interface_payload_vhpyarj5/ansible_netbox.netbox.netbox_device_interface_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py", line 795, in _nb_endpoint_get
    response = nb_endpoint.get(**query_params)
  File "/opt/ansible/ansible-venv/lib/python3.10/site-packages/pynetbox/core/endpoint.py", line 166, in get
    raise ValueError(
fatal: [switch1]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "cert": null,
            "data": {
                "bridge": null,
                "custom_fields": null,
                "description": null,
                "device": "switch1",
                "duplex": null,
                "enabled": null,
                "form_factor": null,
                "label": null,
                "lag": null,
                "mac_address": null,
                "mark_connected": null,
                "mgmt_only": null,
                "mode": "access",
                "mtu": null,
                "name": "interface GigabitEthernet1/0/1",
                "parent_interface": null,
                "poe_mode": null,
                "poe_type": null,
                "speed": null,
                "tagged_vlans": null,
                "tags": null,
                "tx_power": null,
                "type": null,
                "untagged_vlan": [
                    {
                        "name": "VLAN100"
                    },
                    {
                        "vlan_group": "access-vlan"
                    }
                ],
                "vrf": null,
                "wwn": null
            },
            "netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "netbox_url": "http://127.0.0.1:8000",
            "query_params": null,
            "state": "present",
            "update_vc_child": false,
            "validate_certs": true
        }
    },
    "msg": "More than one result returned for untagged_vlan"
}
@sebastianreifetshammer sebastianreifetshammer added the bug Something isn't working label May 22, 2024
@sebastianreifetshammer sebastianreifetshammer changed the title [Bug]: multiple result returned of untagged_vlans when defining vlan & vlan_group for interface [Bug]: multiple results returned for untagged_vlan when vlan & vlan_group for interface is defined May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant