GithubHelp home page GithubHelp logo

moreinhardt / vbox-inventory Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anomalousmaterials/vbox-inventory

0.0 0.0 0.0 4 KB

A dynamic inventory script for Ansible and VirtualBox.

License: ISC License

Python 100.00%

vbox-inventory's Introduction

vbox-inventory

A dynamic inventory script for Ansible and VirtualBox.

What it does

Lets you run Ansible against virtual machines without having to check addresses or maintain the Ansible hosts file.

How it works

The script uses VBoxManage to fetch the name and IP address of each currently running VM and provides these in a JSON format palatable to Ansible.

How to use it

Here's one way to set up a combination of static and dynamic inventories:

  • Create a directory to hold your host data:

      mkdir ~/ansible_inventory
    
  • Add this line to your .bash_profile:

      export ANSIBLE_HOSTS=~/ansible_inventory
    
  • Put your static host file(s) and the script in ~/ansible_inventory

  • Make the script executable:

      chmod 0755 ~/ansible_inventory/vbox_inventory.py
    
  • Test:

      ~/ansible_inventory/vbox_inventory.py --list
      ansible all --list-hosts
    

Limitations

  • Gets the address of the first interface, multihomed hosts may not work as expected.
  • Only running VMs are listed.
  • Guest additions need to be installed.

Customizing

  • The default group name is vbox. Modify the value of constant VBOX_GROUP to change it.

  • You can add host variables to constant HOSTVAR_TEMPLATE. For example, to use the root account to log in:

      HOSTVAR_TEMPLATE = {'ansible_ssh_user': 'root'}
    

vbox-inventory's People

Contributors

drprofesq avatar anomalousmaterials avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.