ansible_modules icon indicating copy to clipboard operation
ansible_modules copied to clipboard

[Bug]: netbox_vm_interface module doesn't accept mac_address anymore

Open rletocart opened this issue 11 months ago • 4 comments

Ansible NetBox Collection version

v3.19.1

Ansible version

ansible [core 2.17.1]
  config file = /Users/raph/dev/ansible/netbox/ansible.cfg
  configured module search path = ['/Users/raph/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/raph/dev/ansible/netbox/lib/python3.12/site-packages/ansible
  ansible collection location = /Users/raph/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/raph/dev/ansible/netbox/bin/ansible
  python version = 3.12.8 (main, Dec  3 2024, 18:42:41) [Clang 16.0.0 (clang-1600.0.26.4)] (/Users/raph/dev/ansible/netbox/bin/python3)
  jinja version = 3.1.4
  libyaml = True

NetBox version

v4.2.2

Python version

3.11

Steps to Reproduce

- name: "ADD VM INTERFACES TO NETBOX"
  netbox.netbox.netbox_vm_interface:
    netbox_url: "{{ NETBOX_ENDPOINT }}"
    netbox_token: "{{ NETBOX_TOKEN }}"
    data:
      virtual_machine: "{{ inventory_hostname }}"
      name: "{{ item  }}"
      enabled: "true"
      mac_address: "{{ ansible_facts[item].macaddress | ansible.utils.hwaddr | upper }}"
    state: present
  loop: "{{ ansible_interfaces | list }}"

Expected Behavior

Virtual machine net interfaces are created in netbox WITH a MAC address. This was working before v4.2.1

Observed Behavior

MAC address seems simply ignored. I didn't get any error in ansible.

rletocart avatar Jan 31 '25 05:01 rletocart

Can confirm this behavior on our side as well on v4.2.2.

I currently think that this might be fixed with this commit in the ansible-collection repo: https://github.com/netbox-community/ansible_modules/commit/fa4c44b5323e3a99e925a1cd296b82e7cb8e4ff5

However there's currently no new release so manual patching might be required.

raphis avatar Jan 31 '25 10:01 raphis

If there will be a new module for the 4.2 MAC address support, shouldn't the parameters name be mac_addresses in plural so that it doesn't need to be changed later when the actual multiple MAC address support lands?

bluikko avatar Feb 07 '25 07:02 bluikko

Can confirm this behavior on our side as well on v4.2.2.

I currently think that this might be fixed with this commit in the ansible-collection repo: fa4c44b

However there's currently no new release so manual patching might be required.

If you want to test it before a new release is made you can always install it from the git branch - https://docs.ansible.com/ansible/latest/collections_guide/collections_installing.html#installing-a-collection-from-a-git-repository

rodvand avatar Feb 07 '25 21:02 rodvand

The netbox_mac_address module helped..

For me it was a 3 or 4 step process to define a NIC and get a Mac address assigned.

Working example here

https://github.com/lanefu/ansible-collection-armlab/blob/1ea25031944f00ef8d6306413cb7e04bf2569df8/roles/netbox_register_vm/tasks/register.yml

lanefu avatar Sep 01 '25 16:09 lanefu