You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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:
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."}
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:
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."}
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."
The text was updated successfully, but these errors were encountered: