ansible_modules icon indicating copy to clipboard operation
ansible_modules copied to clipboard

It's not possible to allocate the next available vlan from a vlan_group.

Open pertoft opened this issue 1 year ago • 2 comments

Ansible NetBox Collection version

v3.10.0

Ansible version

ansible [core 2.16.1]
  config file = /Users/pto/.ansible.cfg
  configured module search path = ['/Users/pto/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/9.1.0/libexec/lib/python3.12/site-packages/ansible
  ansible collection location = /Users/pto/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.12.1 (main, Dec  7 2023, 20:45:44) [Clang 15.0.0 (clang-1500.0.40.1)] (/opt/homebrew/Cellar/ansible/9.1.0/libexec/bin/python)
  jinja version = 3.1.3
  libyaml = True

NetBox version

v3.7.0

Python version

3.9

Steps to Reproduce

The following playbook is expected to create a new vlan in the vlan_group: vlan_group1 with the next available vlan.

- name: "Test NetBox modules"
  connection: local
  hosts: localhost
  gather_facts: False

  tasks:
    - name: Create vlan within NetBox with only required information
      netbox_vlan:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          name: Test VLAN
          vlan_group: vlan_group1
        state: present

However, this is not the case as the Netbox API will report:

    "msg": "{\"vid\":[\"This field is required.\"]}"

This is because the endpoint /ipam/ipam_vlan_groups_available_vlans_create should be used to alocate a vlan, when vid is not defined. It would be really nice with this feature in ansible.

Expected Behavior

A new vlan should be create with the next available vlan id from the vlan group.

Observed Behavior

Netbox API throws this error: "msg": "{"vid":["This field is required."]}" This is because the correct endpoint is not used to allocate a new vlan.

pertoft avatar Feb 22 '24 09:02 pertoft