-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Closed
Copy link
Labels
severity: mediumResults in substantial degraded or broken functionality for specfic workflowsResults in substantial degraded or broken functionality for specfic workflowsstatus: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
NetBox version
v3.6.1
Python version
3.11.4
Steps to Reproduce
- Start from a fresh NetBox instance, configure an API token and configure these 2 environment variables:
TOKEN=mynetboxtoken
NETBOX_URL=http://my.netbox.url
Please replace with values relevant to your NetBox instance.
- Create
/etc/netbox/templatesdirectory on the NetBox instance and create a trivial Jinja2 template to the NetBox instance in it:
mkdir -p /etc/netbox/templates
echo 'This is a simple Jinja2 template.' > /etc/netbox/templates/basic.j2
- Provision a new local data source using the REST API:
curl -X POST \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
$NETBOX_URL/api/core/data-sources/ \
--data '{
"name": "templates",
"type": "local",
"source_url": "file:///etc/netbox/templates",
"enabled": true
}'
Make sure it is correctly created and note down its id:
DATASOURCE_ID=1
Please replace with the id of the created object.
- Sync this new local data source using the REST API:
curl -X POST \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
$NETBOX_URL/api/core/data-sources/$DATASOURCE_ID/sync/ \
- Provision a new config template based on the
basic.j2Jinja2 template in this local data source using the REST API:
curl -X POST \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
$NETBOX_URL/api/extras/config-templates/ \
--data '{
"name": "basic",
"template_code": "Will be overwritten after data_file is synced",
"data_source": {"name": "templates"},
"data_file": {"path": "basic.j2"}
}'
Make sure it is correctly created and note down its id:
CONFIGTEMPLATE_ID=1
Please replace with the id of the created object.
- Sync this new config template:
curl -X POST \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
$NETBOX_URL/api/extras/config-templates/$CONFIGTEMPLATE_ID/sync/
Now, the config template can be used on a device or device-role.
Expected Behavior
At step 6, I expect data_file to be correctly populated in the JSON data of the POST response. I should get:
{
...
"data_file": {
...
"path": "basic.j2"
},
...
}
Observed Behavior
At step 6, the JSON data I'm really receiving in the POST response is:
{
...
"data_file": null,
...
}
Metadata
Metadata
Assignees
Labels
severity: mediumResults in substantial degraded or broken functionality for specfic workflowsResults in substantial degraded or broken functionality for specfic workflowsstatus: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application