ansible/ansible — pull request #6379 by sergevanginderachter (2014-03-10 20:33:49+00:00)
Title: Various fixes in the Inventory; also make it a proper tree.

As discussed in https://groups.google.com/forum/#!searchin/ansible-devel/ascii/ansible-devel/mEovLhqWTV0/Oed0z9SdOjQJ

This patch set addresses several small bugs in the inventory. I left each of them as a separate commit, as each of them has a specific issue it addresses by its own, which should be easier to review.

Short summary:
- avoiding several duplicates in both hosts and group lists within the Group object, especially coming from the dir parser.
- finally fixing group depth, by checking depth on all child groups
- fixing the difference between direct parents and *all* ancestors
- only adding groups to the default *all* group, that are direct childs of it ( == groups with depth 1)
- don't add child groups to the parent ancestors

I have been running this patch set in my own production for the last couple of days, and didn't encounter any issues. Obviously there might be corner cases I couldn't cover.

The patch to the script parser - as I don't use the script api myself atm - was tested by dumping my dir+ini inventory in the right format, and loading it through a "cat json" script. I managed to get exact identical results here.There's more on this alternative way on parsing host/group vars, but I'll come back to that later.

The last patch - Inventory: raise error when adding a group that already exists - is more of a failsafe to the Inventory object. I never had any real issue here, but this might trigger possible issues with later, bad patches.