-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow reading config context data from a file on disk #9073
Comments
Related: #8505 |
For a true CI/CD environment, what about having the ability to specify a Github repository & resulting file? One of my hesitations to using config contexts in automation against my devices is there's no peer review process. An integration with Github would allow us to store the config contexts there and require a PR etc. If Netbox then had a supportable API, you could configure a webhook on the GH repository to trigger Netbox to pull the latest versions on a successful merge. |
You can certainly do that, although the revision tracking function (e.g. git) can operate outside of NetBox. (Given the support for remote storage, it can even happen on some other system entirely.) You would just define in NetBox the path to a file that happens to live in a git repo. |
I would like to see this type of git remote file. The issue I see here is related to how the change logging inside netbox would appear when changes in the config context data are made outside netbox I would like to have a better view of what changed in the configuration context information also within the change log of netbox |
This would be tracked by e.g. git, not NetBox. NetBox would track only changes to the ConfigContext object itself (such as if the file path is modified). This ensures a clear delineation of revision control. |
Yea I think this makes sense. Have got track the file and have netbox be able to reference git. |
For me that makes sense to have this separation for revision control well defined and I not against it I would like to have only a easy way to show the information that git has for that object in the user interface. |
Currently we are aggregating config context data as part of the database query, which is not possible when dealing with data from files. We have two options for implementing this:
Personally I strongly prefer the first option, however I'm concerned about performance. The second option, a hybrid approach, would work but assumes that an organization uses predominantly one type or the other. Attempting to keep the database data in sync with the source files is likely to be extremely unreliable (as well as inefficient). |
After talking about this a little, it feels like the feature needs to be fleshed out a little. A couple of items I am thinking about off the bat:
As more items come to mind about gaps OR how to approach this, I will comment. I just rather get the discussion going before going to far down a thought on my own. Since nautobot constantly lifts ideas from NetBox, I am listing some references form their implementation: |
I think I like the idea of allowing a user to specify a generic "source" URL for a config context. This would point to either a local file (e.g. Regarding the aggregation of data (see my comment above), the most efficient approach is likely to be copying the source data into the database, where it can be aggregated just like "native" config contexts. There are various mechanisms by which we can effect this replication: a UI button, a REST API endpoint, a scheduled task, etc. Ultimately it will be up to the user to determine when this data is replicated, but we should ensures options are available for both automatic and manual synchronizations. |
Given that there hasn't been a ton of interest in this proposal, I'm going to shelve it for now. We may want to spend more time considering how we might use this same pattern elsewhere in NetBox and plan accordingly. |
This would be useful for more than just config context. I can envision some scripts, reports, plugins that I would build to either read from the latest git commit or push commits to git. One example would be for configuration compliance. I would connect to the following git repos:
|
Marking this as blocked by #11558, which seeks to implement support for remote data replication in a more abstract sense. |
Happy to report that #11558 has been completed and work on this feature can now move forward. |
NetBox version
v3.2.0
Feature type
New functionality
Proposed functionality
Currently, when creating a config context, the user must JSON populate data on the object, which gets stored in the database. This issues proposes providing the option of instead specifying the path to a file on disk (within one of the configured directories) from which data can be read. This will take the place of locally-stored data; a config context instance can define local data or a source file, but not both.
Data from a file will be read at initialization of the config context instance and retained until its deletion. Some degree of caching may also be supported, but further research is needed to determine its impact and feasibility.
Implementation will likely involve the addition of a new configuration parameter to define the permitted file paths.
Use case
This approach allows users to reference external data where necessary e.g. to better accommodate a change control process, while still empowering users to store data locally where sufficient.
Database changes
An optional
data_file
FilePath field will be added to the ConfigContext model, and the existingdata
field will become optional. Model validation will ensure that one of these two fields has been populated on save. Additionally, model validation will handle validating the source data upon save.External dependencies
No response
The text was updated successfully, but these errors were encountered: