netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
16.34k stars 2.6k forks source link

Custom field for tags #16080

Open fprina opened 6 months ago

fprina commented 6 months ago

NetBox version

v3.7.8

Feature type

New functionality

Proposed functionality

Permits extending tag information with custom fields, as is done with other object types.

Use case

I use tags in Ansible playbook/templates and it would be great to add extra information based on them.

In the specific:

I create firewall host groups using Netbox tags, but I don't need to create groups for all the tags. I've implemented a filter in Ansible based on tag colors to distinguish them. However, it's clear that this solution isn't well-designed.

Adding custom fields also to tags could offer more flexibility and maybe permit me to add different logics.

Database changes

No response

External dependencies

No response

jeffgdotorg commented 6 months ago

Thank you for your interest in improving NetBox. We need more detail before we can consider implementing this request.

Please edit the issue body to expand your use case with Ansible usage examples showing how the proposed functionality would be used. The YAML example from the netbox.netbox.netbox_tag module docs might make a good starting point, but examples adapted from your own plays are also great.

jeffgdotorg commented 6 months ago

@fprina the revisions are a good start and I thank you for making them, but I need you to make a more concrete case. You need to sell a developer on the idea of spending an hour or two doing this work. Perhaps use a sanitized version of one of your existing plays as a starting point, and show how you imagine this enhancement would improve things and make your life (and other users' lives!) easier.

fprina commented 6 months ago

@jeffgdotorg, I understand your point, but in this case, I don't really have concrete details able to sell the idea.

My playbook is quite basic, just a lookup like {{ query('netbox.netbox.nb_lookup', 'tags', api_endpoint=netbox_url, token=netbox_token, api_filter='color=00bcd4' ) }}

but it would be better to use a clearer filter.

For example, a boolean like cf_firewall_group=true would be great. Or maybe I could extend my implementation adding a text field with the firewall group name.

The recap is: looks like the only object type without CF are tag so would be nice have them. nothing more nothing less.

jeffgdotorg commented 6 months ago

The completeness argument suffices to move your issue along to needs owner status. If you would like to volunteer to work it through to a PR, please indicate and a maintainer will assign the issue to you. Otherwise, another developer with the requisite skills and capacity can pick it up.

jeremystretch commented 6 months ago

This would effect an API change for the Tag model, and therefore needs a milestone designation.

goteamkor commented 4 months ago

This would be a great addition. The ability to add custom fields to tags might also address the need for the following plugin : https://plugin-ideas.netbox.dev/ideas/PLUGINS-I-31

Rather than needing to create the plugin at all, or add a bunch of new models, you could simply 'tag' a device with a "contract" then add what ever custom fields for that tag that are appropriate for your environment/use case.