relex / aini Goto Github PK
View Code? Open in Web Editor NEWGo library for Parsing Ansible inventory files
License: MIT License
Go library for Parsing Ansible inventory files
License: MIT License
Hi.
Is there any chance to get a possibility of parsing YAML files instead of INIs?
Thanks in advance!
[EDITED] This is about Inventories in YAML format.
I'm on a mainstream release that only supports Go 1.15. It seems that your library has a go 1.16 dependency somewhere given the error when trying to get the library installed:
go get github.com/relex/aini
package io/fs: unrecognized import path "io/fs": import path does not begin with hostname
Can you consider making the library compatible to Go versions < 1.16?
(not sure how much you depend on io/fs, but if you could remove the dependency without huge effort would be great?)
Hi,
great library!
For my use case I don't need "all" and "ungrouped" - so its not a major thing for me BUT...
I am iterating over the groups and outputting all group names and their respective hosts, I noticed that ungrouped is output with all hosts. According to the docs at ansible, ungrouped should only contain hosts that don't belong to any other group.
Here is a short sample of my quick and dirty method for demonstrating..
for _, g := range inventory.Groups {
_, _ = datawriter.WriteString("[" + g.Name + "]\n")
for _, h := range g.Hosts {
_, _ = datawriter.WriteString(h.Name + "\n")
.....
So basically I get a list of groups and their respective hosts, works great! But I also get an "ungrouped" group but it contains ALL hosts
Is this correct? I would have suspected that it should be empty as all my hosts belong to another group.
Thanks in advance
As i test it, this library does not parse these folders with yaml files.
Why?
hi
this package have the feature what is InventoryData to yaml or ini ,json
I stumbled upon your library when working on a little inventory CLI and I think I found an error.
To illustrate I wrote a minimal example:
package main
import (
"fmt"
"strings"
"github.com/relex/aini"
)
func main() {
// Load from string example
inventoryReader := strings.NewReader(`foo-[1:2]-[a:c]-bar`)
inventory, _ := aini.Parse(inventoryReader)
for host, _ := range inventory.Hosts {
fmt.Println(host)
}
}
The output of this when run through go run main.go
is as follows:
foo-1-[a:c]-bar
foo-2-[a:c]-bar
I think this is incorrect and should result in this output instead:
foo-1-a-bar
foo-1-b-bar
foo-1-c-bar
foo-2-a-bar
foo-2-b-bar
foo-2-c-bar
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.