Skip to content
Custom simple opinionated ansible inventory plugin for digitla ocean netbox system
Python Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Custom Simple Netbox Inventory Plugin

This Inventory plugin was developed for a friend, and it is a quite opinionated simple version of the ansible netbox inventory plugin to return only the needed values for a faster inventory result

  • Device Role filtering
  • Support removal of domain names
  • Custom tag prefix
  • Site filtering


  • Copy ansible/inventory_plugins/ in your custom inventory_plugins directory

  • Create a new an_netbox_inventory.yml in your inventory folder like /ansible/inventory/an_netbox_inventory.yml

    plugin: an_netbox
    netbox_api_key: 7a096c1182f928637a6441c23119ecee042439b2
    # device_role slug to filter, if not defined it will be 'server
    device_role: server
    # if not defined it tag_prefx will be 'tag_'
    tag_prefix: "tag_"
    # if true it will cutout the domainname and pass only ansiblehost=<device_name>
    cut_domain_name: true
    # filter out a specific webfaction_site
    filter_site: Interxion
  • Ensure inventoryplug is enabled in your ansible.cfg

    enable_plugins = an_netbox


netbox_server_url - Required

Url to connect to netbox api

netbox_api_key - Required

API Key to use for the autorization


Device Role to filter for ( Slug Name)

Device Role typical in a Netbox Installation

  • access-switch
  • console-server
  • core-switch
  • distribution-switch
  • firewall
  • management-switch
  • pdu
  • router
  • server

Default: server


Host Group Prefix for each device tag

Default: tag_


Cut out Domains from device name will be linux1

Default: True


Will filter devices of a specific site

If not defined it will return all netbox devices and virtualmachines

You can’t perform that action at this time.