sown / ansible

Role-based Ansible configuration
MIT License
0 stars 1 forks source link

use netbox for inventory, closes #3 #6

Closed TimStallard closed 4 years ago

TimStallard commented 4 years ago

Annoyingly this requires a token - but it reads from the NETBOX_TOKEN / NETBOX_API_KEY env vars, so we can avoid storing it in the repo.

TimStallard commented 4 years ago

Yep, it picks up everything marked as active in netbox:

tim@sown-auth2:~/ansible$ ansible-inventory -i ./hosts.yml --graph
@all:
  |--@device_roles_Backup Server:
  |  |--BACKUP2
  |  |--BACKUP3
  |--@device_roles_Development Server:
  |  |--backup-test
  |--@device_roles_KVM:
  |  |--KVM
  |--@device_roles_Monitoring Probe:
  |  |--odroid
  |--@device_roles_Patch Panel:
  |  |--Patch Pannel
  |--@device_roles_Router:
  |  |--GW
  |  |--GW2
  |--@device_roles_Server:
  |  |--ADMIN-DEV
  |  |--AUTH2
  |  |--BUILDROOT
  |  |--BUILDROOT-DEV
  |  |--DATA1
  |  |--EXTERNAL-MONITOR
  |  |--JUMPBOX
  |  |--MARCONI
  |  |--MONITOR
  |  |--MONITOR2
  |  |--NETBOX
  |  |--TUNNELBROKER
  |  |--VMS
  |  |--VMS-B53-1
  |  |--VPN
  |  |--VPN-TEST
  |  |--WIFIMON
  |  |--WWW
  |  |--ZEPLER-WEBSDR
  |  |--vault-b53-1
  |--@device_roles_Switch:
  |  |--Old Switch
  |  |--Switch
  |--@tags_Backup:
  |  |--AUTH2
  |  |--GW
  |  |--GW2
  |  |--JUMPBOX
  |  |--MONITOR2
  |  |--NETBOX
  |  |--VMS-B53-1
  |  |--VPN
  |  |--WIFIMON
  |--@tags_Production:
  |  |--AUTH2
  |  |--EXTERNAL-MONITOR
  |  |--vault-b53-1
  |--@tags_RAID:
  |  |--VMS
  |  |--VMS-B53-1
  |--@ungrouped:
TimStallard commented 4 years ago

Hmm, though that does pick up a bunch of non-server stuff; I guess we'll need to filter based on roles similarly to how the monitoring code does.