Dynamic Ansible inventory via OpenNebula API.
go get -u
go build -o one-inv main.go
See opennebula-inventory.example.yaml.
one-inv --list
one-inv --debug --list
one-inv --host=foo
not implemented yet.
Any non-flag CLI args must be passed with an equals sign.
The inventory tool assumes that any role or group membership is sufficiently encoded in (and can thus be deduced from) the VM name (or another, explicitly configured hostname field). It does not inspect additional attributes for determining group association (although this may change in the future).
go test ./...
# for each package
go test ./... -coverprofile=coverage.out
go tool cover -html=coverage.out
Given VMs with names db-staging-west, web-staging-west, db-production-east and the following config,
static_group_filters:
web: "^web"
database: "^db"
east: "-east$"
west: "-west$"
dynamic_group_filters:
pattern: ".+-(staging|production)-(east|west)"
prefix: ""
infix: "-"
suffix: ""
pattern_replace: "-(we|ea)st"
the output will look like this:
{
"database": [
"db-production-east",
"db-staging-east"
],
"east": [
"db-production-east",
"db-staging-east"
],
"production": [
"db-production-east"
],
"staging": [
"db-staging-east"
],
"web": [
"web-staging-west"
],
"west": [
"web-staging-west"
]
}
godoc -http=:6060
See