aabouzaid / netbox-as-ansible-inventory

Ansible dynamic inventory script for Netbox.
GNU General Public License v3.0
174 stars 54 forks source link

Config context #36

Closed FragmentedPacket closed 6 years ago

FragmentedPacket commented 6 years ago

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

hosts_vars: context: variable_name: config_context

Sample 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"]}

FragmentedPacket commented 6 years ago

It appears it is only failing due to an issue with the Python3.5 TravisCI test: The command "python setup.py requirements -t" failed and exited with 1 during .

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-9.4%) to 90.566% when pulling 16805b86602c9de131da6fa09d190ee6ff2103de on FragmentedPacket:config-context into 095cfb162fff9eeb7fc4aadfaf015d472f2484ba on AAbouZaid:devel.

FragmentedPacket commented 6 years ago

To-do:

FragmentedPacket commented 6 years ago

@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.