-
Notifications
You must be signed in to change notification settings - Fork 54
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
Config context #36
Closed
FragmentedPacket
wants to merge
19
commits into
aabouzaid:devel
from
FragmentedPacket:config-context
Closed
Config context #36
FragmentedPacket
wants to merge
19
commits into
aabouzaid:devel
from
FragmentedPacket:config-context
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tested code and verified it is working as intended. I tested without host_vars.context existing and it works as it did previously and tested with and it add the context data from each host.
It appears it is only failing due to an issue with the Python3.5 TravisCI test: |
I was using id as a variable which is a builtin varable - changed to device_id
To-do:
|
@aabouzaid Do you see this as a benefit? I've never worked on creating tests and want to make sure my code, etc. makes sense before I continue on and learn how to write the tests. |
Testing to see if this works as it should, but I may have my tests setup incorrectly.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since config contexts are new as of 2.4 I figured it'd be nice to be able to use those as host vars.
I'm not sure if this implementation is the best way so additional tweaks may be needed.
Overview
context:
underhosts_vars
in netbox.ymlhosts_vars: context: variable_name: config_context
context:
is configured underhosts_vars
it will gather the context data for a single device or all devicesSample data
./netbox.py --host switch2 {"ansible_ssh_host": "192.168.1.1", "serial": "awadawd21254", "asset-tag": "1001", "config_context": {"ntp2": "192.168.1.2", "ntp1": "192.168.1.1"}}
./netbox.py --list {"_meta": {"hostvars": {"switch1": {"serial": "cisco-serial", "asset_tag": "1234", "config_context": {"radius": {"radius03": "10.0.0.3", "radius02": "10.0.0.2", "radius01": "10.0.0.1"}, "tacacs": {"acs03": "10.0.0.3", "acs02": "10.0.0.2", "acs01": "10.0.0.1"}, "ntp-servers": {"ntp2": "192.168.1.2", "ntp1": "192.168.1.1"} "10": ["permit 10.0.0.0 0.0.0.255", "permit 172.16.0.0 0.0.255.255"]}} "switch2": {"ansible_ssh_host": "192.168.1.1", "serial": "awadawd21254", "asset-tag": "1001", "config_context": {"ntp2": "192.168.1.2", "ntp1": "192.168.1.1"}}, "group1": ["switch1"], "group2": ["switch2"]}