Automatically set Asset Tag on created Devices #18683
-
When a new dcim.device is created in our NetBox, I'd like the Asset Tag to be set to I think I can maybe use an "Event Rule" to trigger a "Script" to do this, but the documentation is not very clear on how this works. I'd assume that if I create an Event Rule that triggers when a Device is created, it would send all info about the created device to the script, but that seems to not be the case upon further reading. What I want is basically this logic:
How can I most easily achieve this? The docs are not clear at all about what info is sent from the Event Rule to the Script. Also not clear at all about what is possible inside the script. Like here fx, I would assume that I can pass the created device via "Action Data" but there is just no info about Action Data really: https://netboxlabs.com/docs/netbox/en/stable/models/extras/eventrule/ All it says is "An optional dictionary of JSON data to pass when executing the rule. This can be useful to include additional context data, e.g. when transmitting a webhook." Docs I have read:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
The Event Rule sends an dict with some info (the "data" object/variable), where the object id of the device is one. An example to attach to an Create Event Rule:
|
Beta Was this translation helpful? Give feedback.
The Event Rule sends an dict with some info (the "data" object/variable), where the object id of the device is one.
An example to attach to an Create Event Rule: