# Issues linking parent interface with netbox\_device\_interface module

**URL:** <https://forum.ansible.com/t/issues-linking-parent-interface-with-netbox-device-interface-module/9690>\
**Category:** Get Help\
**Tags:** api, module, ansible, netbox\
**Created:** [October 4, 2024, 7:01pm UTC](https://forum.ansible.com/t/issues-linking-parent-interface-with-netbox-device-interface-module/9690 "2024-10-04T19:01:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sam\_karateman](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@sam\_karateman](https://forum.ansible.com/u/sam_karateman)\
**Post date:** [October 4, 2024, 7:01pm UTC](https://forum.ansible.com/t/issues-linking-parent-interface-with-netbox-device-interface-module/9690/1 "2024-10-04T19:01:47Z")

</div>

Hello,

I’m attempting to use the [netbox.netbox.netbox\_device\_interface](https://docs.ansible.com/ansible/latest/collections/netbox/netbox/netbox_device_interface_module.html) module to create an interface and assign a parent interface to it. Here are the tasks I’m using to get the ID from the API:

```auto
        - name: Get bond0 Interface
          local_action:
            module: ansible.builtin.set_fact
            interface: "{{ query('netbox.netbox.nb_lookup', 'interfaces', api_filter='name=LAG0 device=' ~ device_name) }}"

        - name: List bond0 Interface values
          ansible.builtin.debug:
            msg: "{{ interface }}"

        - name: Get bond0 Interface ID
          ansible.builtin.set_fact:
            interfaceid: "{{ interface.0.value.id }}"

```

I then set the parent interface here:

```auto
    # VLAN 407 Interface/address block
    - name: Write 407 interface and address
      block:
        - name: Write 407 VLAN interface
          local_action:
            module: netbox.netbox.netbox_device_interface
            netbox_url: "{{ lookup('env', 'NETBOX_API') }}"
            netbox_token: "{{ lookup('env', 'NETBOX_TOKEN') }}"
            data:
              name: "LAG0_VLAN407"
              label: "bond0.407"
              device: "{{ ansible_facts['hostname'] }}"
              enabled: "true"
              type: "Virtual"
              parent_interface: "{{ interfaceid }}"

```

When I attempt to run the playbook, I get the error ‘Could not resolve id of parent interface: ’. At this point I’m not sure what other value I need to provide, as I know the ID is correct when checked against the API for the parent interface and the documentation isn’t clear. Any help that can be provided is much appreciated.

---

<div class="post-metadata">

**Author:** ![sam\_karateman](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@sam\_karateman](https://forum.ansible.com/u/sam_karateman)\
**Post date:** [October 10, 2024, 7:27pm UTC](https://forum.ansible.com/t/issues-linking-parent-interface-with-netbox-device-interface-module/9690/2 "2024-10-10T19:27:26Z")

</div>

Ultimately was able to fix this by setting `jinja2_native = true` in the `ansible.cfg` file. Note that this will cause some weirdness with other data types, especially null/None/undefined vars.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 9, 2024, 7:27pm UTC](https://forum.ansible.com/t/issues-linking-parent-interface-with-netbox-device-interface-module/9690/3 "2024-11-09T19:27:58Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
