Skip to main content

Ansible dynamic inventory for bosh deployments

Project description

# bosh-ansible-inventory
Ansible dynamic inventory

# Usage

You can install it by running `setup.py`:
```
$ python setup.py install
```

Also, you can copy and run it directly by calling the program
`bosh_inventory.py` instead of `bosh-inventory`.


Once it is installed:

```
$ bosh-inventory --help
usage: bosh-inventory [-h] [--list]

Program to create an ansible inventory from all the deployments, jobs and
instances managed by a BOSH Director.

optional arguments:
-h, --help show this help message and exit
--list Enable JSON output for dynamic ansible inventory

In order to use it, you have to define BOSH_CONFIG environment variable
pointing to the configuration file used by Bosh. It will read the credentials
from the file. You can define additional inventory parameters with
BOSH_ANSIBLE_INVENTORY_PARAMS environment variable, for example:
BOSH_ANSIBLE_INVENTORY_PARAMS="ansible_user=vcap ansible_ssh_pass=blabla"

The program will include the IP of each vm if DNS is not defined. To force
always the inclusion of the IP in the inventory, just define the variable
BOSH_ANSIBLE_INVENTORY_IP as a positive integer indicating the index (starting
from 1) of the IP which will be taken (for VMs with multiple IPs), 0 will
disable the feature.

You can also limit the inventory to one deployment by setting the value
of the environment variable BOSH_ANSIBLE_DEPLOYMENT to the name of it.

0.2.0, 2016 Jose Riguera <jose.riguera@springer-sbm.com>
```

To use it, just point the env variable `BOSH_CONFIG` to your
bosh configuration. It will read all parameters from there.


By default, it will return an INI format inventory:
```
$ export BOSH_CONFIG=~/.bosh-dev
$ bosh-inventory > ansible-inventory
```

Or using directly with ansible:
```
$ export BOSH_CONFIG=~/.bosh-dev
$ export BOSH_ANSIBLE_INVENTORY_PARAMS="ansible_user=vcap"
$ ansible -vvvv firehose-to-syslog-0 -i bosh-inventory.py -m ping
```

You can also point to one deployment by using `BOSH_ANSIBLE_DEPLOYMENT`,
and only those instances will appear:
```
$ export BOSH_ANSIBLE_DEPLOYMENT=concourse
$ bosh-inventory
[all:children]
concourse

[concourse:children]
web
worker
db

[web]
web-0 ansible_host=10.10.10.64 ansible_user=vcap

[worker]
worker-0 ansible_host=10.10.10.66 ansible_user=vcap
worker-1 ansible_host=10.10.10.67 ansible_user=vcap

[db]
db-0 ansible_host=10.10.10.65 ansible_user=vcap

```


# Author
Jose Riguera Lopez (jose.riguera@springer.com)

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

bosh_inventory-0.2.0.tar.gz (6.3 kB view details)

Uploaded Source

File details

Details for the file bosh_inventory-0.2.0.tar.gz.

File metadata

File hashes

Hashes for bosh_inventory-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3686f9f9e0ba02c7b01f949a7bd1f69834ebb674144943ab3a3880bd75ce610d
MD5 9a654356a2d921d2597bb6a7eb46616a
BLAKE2b-256 64a604a1153348d605b6c186c65771db40e65fcc4781da2df19d5228b3269237

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