netbox-as-ansible-inventory
netbox-as-ansible-inventory copied to clipboard
Basic support for slugs, names and labels in group_by and host_vars
Implements a very simple method for using slug
, name
and label
fields from netbox API for group_by or host_vars as discussed in #4 and #22.
This is not likely to be the "best" approach as it requires authors of the netbox.yml
configuration file to know which fields they want to group_by or use for host_vars are of which type.
This should be backwards compatible with existing YAML configurations.
Here's an example netbox.yml
configuration using names, slugs and labels:
netbox:
main:
api_url: 'https://localhost/api/virtualization/virtual-machines/'
api_token: '1234567890'
group_by:
names:
- cluster
slugs:
- platform
custom:
- ansible_groups
hosts_vars:
ip:
netbox_primary_ip: primary_ip
ansible_host: primary_ip
names:
netbox_cluster: cluster
netbox_vcpus: vcpus
netbox_memory: memory
netbox_disk: disk
netbox_tenant: tenant
slugs:
netbox_role: role
netbox_platform: platform
labels:
netbox_status: status
custom:
ansible_user: ansible_user
ansible_port: ansible_port
netbox_ansible_configure: ansible_configure
Coverage remained the same at 100.0% when pulling 3d551e95647d57fbe0dfc7afdb4b8f7af717d30d on rthomson:slugs-names-labels into b5e053db300f02177aba7889c87567dbd1e324be on AAbouZaid:devel.
Coverage remained the same at 100.0% when pulling 3d551e95647d57fbe0dfc7afdb4b8f7af717d30d on rthomson:slugs-names-labels into b5e053db300f02177aba7889c87567dbd1e324be on AAbouZaid:devel.
Hello,
I think there is a little error in labels
key map,
self.key_map = {
...
"labels": "value",
shouldn't it be ?
self.key_map = {
...
"labels": "label",
If I'm correct, this should fix #17