Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

Basic support for slugs, names and labels in group_by and host_vars - #23

Open
rthomson wants to merge 1 commit into
aabouzaid:develfrom
rthomson:slugs-names-labels
Open

Basic support for slugs, names and labels in group_by and host_vars#23
rthomson wants to merge 1 commit into
aabouzaid:develfrom
rthomson:slugs-names-labels

Conversation

@rthomson

Copy link
Copy Markdown

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.

@rthomson

Copy link
Copy Markdown
Author

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

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 3d551e9 on rthomson:slugs-names-labels into b5e053d on AAbouZaid:devel.

1 similar comment
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 3d551e9 on rthomson:slugs-names-labels into b5e053d on AAbouZaid:devel.

@Keyhaku

Keyhaku commented Mar 16, 2018

Copy link
Copy Markdown

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants