Skip to content

[Bug]: Cannot set primary IP of a device if the ip address exists in multiple VRFs #1448

@xibriz

Description

@xibriz

Ansible NetBox Collection version

3.21.0

Ansible version

ansible [core 2.17.11]
  python version = 3.10.12 (main, May 27 2025, 17:12:29) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True

NetBox version

v4.0.9

Python version

3.10

Steps to Reproduce

  1. Create two VRFs
  2. Create the same IP address (example 10.0.0.2), one in each VRF
  3. Assign one of the IP addresses to a interface on a device
  4. Set the primary ip of the device with the following code:
- name: Update device with primary ip
  netbox.netbox.netbox_device:
    netbox_url: URL
    netbox_token: TOKEN
    data:
      name: my_device
      primary_ip4: 10.0.0.2
    state: present

Expected Behavior

The IP address already assigned to a interface of the device should be set as the primary ip address.

Observed Behavior

fatal: [my_device]: FAILED! => {"changed": false, "msg": "More than one result returned for primary_ip4"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions