Skip to main content

GitLab export to Ansible Inventory for NetBox

Project description

GitLab export to Ansible Inventory for NetBox

Compatibility

This plugin in compatible with NetBox 2.8 and later.

Installation

First, add netbox_gitlab to your /opt/netbox/local_requirements.txt file. Create it if it doesn't exist.

If you are using a local version of the plugin, for example for development, add -e /opt/path/to/plugin instead.

Then enable the plugin in /opt/netbox/netbox/netbox/configuration.py, like:

PLUGINS = [
    'netbox_gitlab',
]

The plugin needs to be configured. The following settings are required:

PLUGINS_CONFIG = {
    'netbox_gitlab': {
        'url': 'https://gitlab.example.com',
        'private_token': 'aBcDeFgHiJkLmNoPqRsTuVwXyZ',
        'project_path': 'group/project',
    },
}

This example would correspond to the project at https://gitlab.example.com/group/project.

And finally run /opt/netbox/upgrade.sh. This will download and install the plugin and update the database when necessary. Don't forget to run sudo systemctl restart netbox netbox-rq like upgrade.sh tells you!

Usage

This plugin uses NetBox export templates to generate the files that are put into the git repository. The output of these templates is parsed as YAML, but JSON output is also accepted (as all valid JSON is also valid YAML). Generating JSON can be more convenient because of the more relaxed parsing of indentation.

By default this plugin looks for these export templates:

Content type Name Purpose
dcim > device Ansible Inventory A single file listing all devices
dcim > device Ansible Device One file per device with device-level configuration
dcim > interface Ansible Interfaces One file per device with its interface configurations

The output sent to GitLab for the inventory is exactly what the export template produces. The output sent to GitLab for device and interface configurations is always YAML with all the empty variables omitted. This makes it easier when writing export templates while still keeping the output compact. This in turn helps to keep Ansible a bit faster by reducing the time spent on parsing the YAML.

For the devices export template this plugin expects the generated YAML/JSON to be a mapping with the device name as the key. When a device is part of a virtual chassis all members of the virtual chassis will be included.

For the interfaces export template this plugin expects the generated YAML/JSON to be a mapping with the interface name as the key.

Examples of export templates are provided in the git repository of this plugin.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netbox_gitlab-0.6.1.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

netbox_gitlab-0.6.1-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file netbox_gitlab-0.6.1.tar.gz.

File metadata

  • Download URL: netbox_gitlab-0.6.1.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for netbox_gitlab-0.6.1.tar.gz
Algorithm Hash digest
SHA256 099202dd6d7117c5e613d46194de16ce0ae779453293e95ac78520d7751acd05
MD5 f6d660929b747b69487e8777a344c11e
BLAKE2b-256 cee841ff3c13b697fb2e52f46686fac8d17577d5f5054c0fb72528b9ecd820ec

See more details on using hashes here.

File details

Details for the file netbox_gitlab-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: netbox_gitlab-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 29.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for netbox_gitlab-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 41d172d26bc49e13063240c779c7aaee7ce44b54a26119a04b4fd4431fa64b55
MD5 e595cf1d6635617ef05e5e845b12b93a
BLAKE2b-256 6f1778d947c31a780e3e9d2047cd087bb5d030e2092dcb7b52afce78e99a1fb4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page