generate ascii graph of topology based on inventory

I finally finished my patch set into a PR:

https://github.com/ansible/ansible/pull/6379

/me dances fully dressed around the trees

Trevor: with this patch set you should be able to build some nice graphs or treeviews. Keep us posted!

Serge

Before we review the above, are there any assumptions that the inventory is actually a tree, seeing I see that in the information?

(It’s technically a graph, not a tree)

​Not really, saying the inventory is more of a group of mixed trees. would
put it better, than talking about "a tree", which, yes, makes it a graph.

By stressing the word *tree* I'm really only talking about making sure the
parent-child relation between groups and their respective depth is fully
correct.

​ Serge​

Multiple groups of trees might be a forrest :slight_smile:

But the branches can grow back together – this is the behavior that I want to make sure is supported, and why I say “graph”.

Further, it’s really not multiple disconnected graphs, because everything should connect at the “all” group.

It is important that this continue to be a thing.

So if nothing has changed, it’s still a graph, and life is good.

If something insists it’s a tree or does not allow graphishness, we could break some inventories.

​Multiple groups of trees might be a forrest :)​

​We need to find an excuse to think of it as cattle.​

But the branches can grow back together -- this is the behavior that I want

to make sure is supported, and why I say "graph".

It certainly still is.​​ I think my patches are small and concise enough
when you'' look at it.

Further, it's really not multiple disconnected graphs, because everything

should connect at the "all" group.

Also, still is, only difference now we have a proper distinction between
"direct parent" and "all ancestors", the latter still are parent-wise
connecting to "all".​​

It is important that this continue to be a thing.

Very obviously.​​

excellent

I’ve had a crack at generating graphviz dot files from inventory.

It’s quite opinionated, but it does work for the simple example I chose (I’m sure Serge can break it)

http://willthames.github.io/2014/04/03/an-ansible-inventory-grapher.html
https://github.com/willthames/ansible-inventory-grapher

Once any wrinkles are ironed out I’d be perfectly happy for it to go into examples/

Will

Cool stuff!

One of my hosts with default ansible: http://oi57.tinypic.com/282kq4n.jpg
Same with my improved inventory patch: http://oi61.tinypic.com/4sbsox.jpg

Which shows me I still have a bug, as group ‘1’ should not be member of ‘all’ here neither…

BTW, my graphviz dot didn’t accept shape=record; so I left that out
dot - graphviz version 2.26.3 (20100126.1600)
Found a bug too, will make you a PR for that

Thanks!

Serge

Excellent, glad to hear it works with other peoples inventory.

That’s quite an old dot, it’s four years old! (judging by version date - I’m on dot - graphviz version 2.36.0 (20140111.2315))

Better styling customisation will be good to have all round (people probably want different fonts) etc., shame dot doesn’t just have something like CSS classes (or maybe it does).

PRs welcome, just merged my first third-party one (the default filenames had quotes in it, oops)

Will

That's quite an old dot, it's four years old! (judging by version date -
I'm on dot - graphviz version 2.36.0 (20140111.2315))

​Blame Ubuntu 13.10 :frowning: or the debian upstream​

Better styling customisation will be good to have all round (people

probably want different fonts) etc., shame dot doesn't just have something
like CSS classes (or maybe it does).

​I'd love to generate a graph of my full inventory :slight_smile: Thinking of options
to limit depth, showing opnly groups, etc.

Serge

This was nice to see.

As I’ve mentioned, if you want to add a pull request to https://github.com/ansible/ansible/tree/devel/examples/scripts we’d be happy to include it.

I think graphviz usually breaks down for a large large number of things - but for simpler configs (or just showing groups, not all the hosts in them) this is definitely neat.

Did my reply to this get deleted? Please get in touch via other methods if there is a problem with my content. I can’t see anything objectionable in my message (any mention of culling links back to the all group was related to the graph, not the inventory internals code)

The script now has templating and there is a branch that reduces number of graph edges.

It’s pretty much ready to go into examples/scripts if that’s still desirable.

Will

Glad you like it. Still ironing out a few things (I really want to add
templating) and then I'll submit it into core.

I'm curious as to what people think about culling links back to the 'all'
group so that only groups without other parents link to all.

​​That's something I fixed in my patches to optimize the inventory, so
hopefully something you wouldn't need to address in your script.