All Projects → aabouzaid → Netbox As Ansible Inventory

aabouzaid / Netbox As Ansible Inventory

Licence: gpl-3.0
Ansible dynamic inventory script for Netbox.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Netbox As Ansible Inventory

Dellemc Openmanage Ansible Modules
Dell EMC OpenManage Ansible Modules
Stars: ✭ 169 (+4.97%)
Mutual labels:  automation, ansible, devops
Azure
Azure-related repository
Stars: ✭ 78 (-51.55%)
Mutual labels:  automation, ansible, devops
Ansible For Kubernetes
Ansible and Kubernetes examples from Ansible for Kubernetes Book
Stars: ✭ 389 (+141.61%)
Mutual labels:  automation, ansible, devops
Raspberry Pi Dramble
Raspberry Pi Kubernetes cluster that runs HA/HP Drupal 8
Stars: ✭ 1,317 (+718.01%)
Mutual labels:  automation, ansible, devops
Rundeck
Enable Self-Service Operations: Give specific users access to your existing tools, services, and scripts
Stars: ✭ 4,426 (+2649.07%)
Mutual labels:  automation, ansible, devops
Awx Ha Instancegroup
Build AWX clustering on Docker Standalone Installation
Stars: ✭ 106 (-34.16%)
Mutual labels:  automation, ansible, devops
Hashi Up
bootstrap HashiCorp Consul, Nomad, or Vault over SSH < 1 minute
Stars: ✭ 113 (-29.81%)
Mutual labels:  automation, devops
Macbook Playbook
Ansible playbook to prepare and maintain macOS for development and desktop use
Stars: ✭ 117 (-27.33%)
Mutual labels:  automation, ansible
Serverfarmer
Manage multiple servers with different operating systems, configurations, requirements etc. for many separate customers in an outsourcing model.
Stars: ✭ 122 (-24.22%)
Mutual labels:  ansible, devops
Tensor
Tensor - Comprehensive web-based automation framework and Centralized infrastructure management platform
Stars: ✭ 136 (-15.53%)
Mutual labels:  automation, ansible
Rhcsa8env
This is a RHCSA8 study environment built with Vagrant/Ansible
Stars: ✭ 108 (-32.92%)
Mutual labels:  automation, ansible
Pfsense Api
The missing REST API package for pfSense
Stars: ✭ 126 (-21.74%)
Mutual labels:  automation, devops
Learn Devops
🚧 Learn the craft of "DevOps" (Developer Operations) to Deploy your App and Monitor it so it stays "Up"!
Stars: ✭ 139 (-13.66%)
Mutual labels:  automation, devops
5minutes
First 5 minutes on new servers. Secure your servers with single command - Ansible playbook
Stars: ✭ 111 (-31.06%)
Mutual labels:  ansible, devops
Bootslap
☕️ bootstraps macOS to be usable
Stars: ✭ 110 (-31.68%)
Mutual labels:  ansible, devops
Terraform
Terraform automation for Cloud
Stars: ✭ 121 (-24.84%)
Mutual labels:  automation, devops
Polkadot Secure Validator
Polkadot Validator Secure Setup
Stars: ✭ 108 (-32.92%)
Mutual labels:  ansible, devops
Arkade
Open Source Kubernetes Marketplace
Stars: ✭ 2,343 (+1355.28%)
Mutual labels:  automation, devops
Syncd
syncd是一款开源的代码部署工具,它具有简单、高效、易用等特点,可以提高团队的工作效率.
Stars: ✭ 2,065 (+1182.61%)
Mutual labels:  automation, devops
Terrahub
Terraform Automation and Orchestration Tool (Open Source)
Stars: ✭ 148 (-8.07%)
Mutual labels:  automation, devops

Netbox dynamic inventory script

|PyPI Version| |Python Version| |Build Status| |Codacy Badge| |Code Health| |Coverage Status|

Please note: This project is not under active development anymore, please use NetBox community Ansible modules <https://github.com/netbox-community/ansible_modules>__.

ToC

  • Intro <#intro>__
  • Compatibility <#compatibility>__
  • Grouping <#grouping>__
  • Hosts variables <#hosts-variables>__
  • Options <#options>__
  • Usage <#usage>__

Intro

This is a Netbox dynamic inventory script for Ansible. Netbox <https://github.com/digitalocean/netbox/>__ is an IP address management (IPAM) and data center infrastructure management (DCIM) tool. It's nice, modern, and has good APIs ... so it's a pretty nice option to serve as a "Source of Truth".

You can group servers as you want and based on what you have in Netbox, you can select fields as groups or as vars for hosts. And you can use default fields or custom fields.

Compatibility

The script tested with netbox = v1.6 and netbox = v2.0.4, but most probably it will work with all netbox v1.0 and above.

Grouping

Servers could be grouped by any section in Netbox. e.g. you can group hosts by "site, "rack", "role", "platform", or any other section in Netbox. Please remember: For grouping, API names should be used not UI names.

So if you have a "site" called "US-East", in Ansible you will get a hosts group is called "US-East" has all hosts in that site.

If that section is a default section you need to put it under group_by.default if it's a custom section (custom fields), then put it under group_by.custom.

Here is an example how servers will be grouped based on their platform.

::

group_by:
   default:
       - platform

So if you have "Ubuntu" and "CentOS" as platforms in Netbox, you will have 2 groups of servers that using that systems.

Hosts variables

Netbox sections could be used as variables for hosts! e.g. you could use the IP of the host in Netbox as ansible_ssh_host, or use a custom field as well.

There are 3 sections here, first type is IP, second one is General, and finally Custom.

Variables are defined as Key: Value. The key is what will be in Ansible and value comes from Netbox.

::

hosts_vars:
    ip:
        ansible_ssh_host: primary_ip

Here primary_ip will be used as value for ansible_ssh_host.

Options

::

$ ansible-netbox-inventory -h
usage: ansible-netbox-inventory [-h] [-c CONFIG_FILE] [--list] [--host HOST]

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG_FILE, --config-file CONFIG_FILE
                        Path for script's configuration. Also
                        "NETBOX_CONFIG_FILE" could be used as env var to set
                        conf file path. (default: netbox.yml)

  --list                Print all hosts with vars as Ansible dynamic inventory
                        syntax. (default: False)
  --host HOST           Print specific host vars as Ansible dynamic inventory
                        syntax. (default: None)

You can also set config file path through environment variable NETBOX_CONFIG_FILE.

Usage

::

$ ansible all -i netbox.py -m ping

.. |Python Version| image:: https://img.shields.io/pypi/pyversions/ansible-netbox-inventory.svg :target: https://pypi.python.org/pypi/ansible-netbox-inventory .. |PyPI Version| image:: https://img.shields.io/pypi/v/ansible-netbox-inventory.svg :target: https://pypi.python.org/pypi/ansible-netbox-inventory .. |Build Status| image:: https://travis-ci.org/AAbouZaid/netbox-as-ansible-inventory.svg?branch=master :target: https://travis-ci.org/AAbouZaid/netbox-as-ansible-inventory .. |Codacy Badge| image:: https://img.shields.io/codacy/8deda33a029a45a8bc360df4dcbf8660.svg :target: https://www.codacy.com/app/AAbouZaid/netbox-as-ansible-inventory .. |Code Health| image:: https://landscape.io/github/AAbouZaid/netbox-as-ansible-inventory/master/landscape.svg?style=flat :target: https://landscape.io/github/AAbouZaid/netbox-as-ansible-inventory/master .. |Coverage Status| image:: https://coveralls.io/repos/github/AAbouZaid/netbox-as-ansible-inventory/badge.svg :target: https://coveralls.io/github/AAbouZaid/netbox-as-ansible-inventory

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].