~egtann/inv2config

inventory.json to srp config.json conversion utility
f27c93b9 — Evan Tann a month ago
rename module to inv2config, remove up dependency
7f1bf9ed — Evan Tann 4 months ago
update module path
1a840f34 — Evan Tann 4 months ago
use openbsd isc license

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:

{"10.128.0.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:

inventory2config -i inventory.json -c config_service.json > 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.