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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for netbox_gitlab-0.6.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41d172d26bc49e13063240c779c7aaee7ce44b54a26119a04b4fd4431fa64b55 |
|
MD5 | e595cf1d6635617ef05e5e845b12b93a |
|
BLAKE2b-256 | 6f1778d947c31a780e3e9d2047cd087bb5d030e2092dcb7b52afce78e99a1fb4 |