~egtann/inv2config

inventory.json to srp config.json conversion utility
e6e17fe2 — Evan Tann 2 months ago
support new inventory.json format
f27c93b9 — Evan Tann 6 months ago
rename module to inv2config, remove up dependency
7f1bf9ed — Evan Tann 9 months ago
update module path

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~egtann/inv2config
read/write
git@git.sr.ht:~egtann/inv2config

You can also use your local clone with git send-email.

#inventory2config

Takes an inventory.json and a service-based SRP config file as inputs and outputs an SRP config file pointing at specific IPs.

Example inventory.json:

{
	"gcp:my-project:us-central1:us-central1-b": {
		"internal": {"10.128.0.1": ["my-app"]},
		"external": {"100.10.1.1": ["my-app"]}
	}
}

Example service-based SRP config file:

{
	"Services": {
		"www.example.com": {
			"HealthPath": "/health",
			"Service": "my-app",
			"Port": 3000
		},
		"www-example.internal": {
			"HealthPath": "/health",
			"Service": "my-app",
			"Port": 3001
		}
	}
}

To use:

inv2config \
	-i inventory.json \
	-c config_service.json \
	-p "gcp:my-project:us-central1:us-central1-b" > config.json

This outputs a config.json with backends populated with the correct ip:port combinations like so:

{
	"Services": {
		"www.example.com": {
			"HealthPath": "/health",
			"Service": "my-app",
			"Port": 3000,
			"Backends": ["10.128.0.1:3000"]
		},
		"www-example.internal": {
			"HealthPath": "/health",
			"Service": "my-app",
			"Port": 3001,
			"Backends": ["10.128.0.1:3001"]
		}
	}
}

SRP will ignore the Service and Port. They are added for this tool only.