Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Group depths are incorrectly assigned by the default inventory parser #2016

zsolt-erl opened this Issue · 3 comments

3 participants

@zsolt-erl incorrectly calculates group depth. This can cause groups on different levels to have the same depth. In turn this can result in reading the files under 'group_vars/' in the wrong order which means that a higher level group can overwrite a lower level group variable.

Here's the fix for

diff --git a/lib/ansible/inventory/ b/lib/ansible/inventory/
index a460b48..88231a4 100644
--- a/lib/ansible/inventory/
+++ b/lib/ansible/inventory/
@@ -36,7 +36,10 @@ class Group(object):
         if self == group:
             raise Exception("can't add group to itself")
-        group.depth = group.depth + 1
+        group.depth = self.depth + 1

     def add_host(self, host):

Hi @zsolt-erl can you submit this as a pull request?

I'd like to include attribution to you in the source.

See if you need help!


Note that it should be max([group.depth, self.depth + 1]) to get the correct value.


Committed 0ad6ac4 per @dhozac's suggestion

Thanks folks!

@mpdehaan mpdehaan closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.