Description
pynetbox version
v7.4.1
NetBox version
v4.2.1
Python version
3.12
Steps to Reproduce
Using PyNetbox is conjunction with Ansible to manage prefixes for a deployment. This worked under NetBox v4.0.8. NetBox v4.2.1 changed from prefix having a "site" field to a scope definition.
-
name: Add Prefix to Netbox
netbox.netbox.netbox_prefix:
netbox_url: "{{ netbox_url }}"
netbox_token: "{{ netbox_api_token }}"
data:
prefix: "{{ item.network }}"
site: "{{ item.site_name }}"
description: "{{ item.description }}"
tenant: WAN
prefix_role: "{{ item.role | upper }}"
vlan:
name: "VL{{ item.vlan_id }}"
site: "{{ item.site_name }}"
vlan_group: "{{ item.vlan_group }}-{{ item.site_name }}"
custom_fields:
agency: "{{ item.agency }}"
carrier_vrf: "{{ item.carrier_side_vrf | upper }}"
e911_zone: "{{ item.e911_zone }}"
tags:
- ansible_created
state: present
validate_certs: false
loop: "{{ new_csv_data }}"
tags:- prefix
When the prefix is added using the Netbox v4.0.8 "Site" definition:
failed: [localhost] (item={'site_name': 'xxxxxx', 'network': '', 'agency': 'XXXX', 'vlan_id': '999', 'vlan_group': 'sr', 'role': 'mgt', 'carrier_side_vrf': 'xxxx', 'e911_zone': '', 'description': 'xxxxxx'}) => {"ansible_loop_var": "item", "changed": false, "item": {"agency": "XXXX", "carrier_side_vrf": "xxxx", "description": "xxxxxx", "e911_zone": "", "network": "", "role": "mgt", "site_name": "xxxxxx", "vlan_group": "sr", "vlan_id": "999"}, "msg": "site does not exist on existing object. Check to make sure valid field."}
- prefix
-
name: Add Prefix to Netbox
netbox.netbox.netbox_prefix:
netbox_url: "{{ netbox_url }}"
netbox_token: "{{ netbox_api_token }}"
data:
prefix: "{{ item.network }}"
scope_type: dcim.site
scope:
site: "{{ item.site_name }}"
description: "{{ item.description }}"
tenant: WAN
prefix_role: "{{ item.role | upper }}"
vlan:
name: "VL{{ item.vlan_id }}"
site: "{{ item.site_name }}"
vlan_group: "{{ item.vlan_group }}-{{ item.site_name }}"
custom_fields:
agency: "{{ item.agency }}"
carrier_vrf: "{{ item.carrier_side_vrf | upper }}"
e911_zone: "{{ item.e911_zone }}"
tags:
- ansible_created
state: present
validate_certs: false
loop: "{{ new_csv_data }}"
tags:- prefix
When the same prefix is added using the new "Scope" based definition:
failed: [localhost] (item={'site_name': 'xxxxxx', 'network': '', 'agency': 'XXXX', 'vlan_id': '999', 'vlan_group': 'sr', 'role': 'mgt', 'carrier_side_vrf': 'xxxx', 'e911_zone': '', 'description': 'xxxxxx'}) => {"ansible_loop_var": "item", "changed": false, "item": {"agency": "XXXX", "carrier_side_vrf": "xxxx", "description": "xxxxxx", "e911_zone": "", "network": "", "role": "mgt", "site_name": "xxxxxx", "vlan_group": "sr", "vlan_id": "999"}, "msg": "Unsupported parameters for (netbox.netbox.netbox_prefix) module: data.scope, data.scope_type. Supported parameters include: comments, custom_fields, description, family, is_pool, mark_utilized, parent, prefix, prefix_length, prefix_role, site, status, tags, tenant, vlan, vrf."}
- prefix
Expected Behavior
The prefixes should add to NetBox with site association through one of those two methods.
Observed Behavior
"Unsupported parameters for (netbox.netbox.netbox_prefix) module: data.scope, data.scope_type. Supported parameters include: comments, custom_fields, description, family, is_pool, mark_utilized, parent, prefix, prefix_length, prefix_role, site, status, tags, tenant, vlan, vrf."