Skip to content
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

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

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open

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

wants to merge 1 commit into from

Conversation

rthomson
Copy link

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

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

Coverage Status

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

@Keyhaku
Copy link

Keyhaku commented Mar 16, 2018

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants