Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
cc8efb4a
Commit
cc8efb4a
authored
Mar 05, 2014
by
Serge van Ginderachter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inventory groups: make sure group.depth is updated on all grandchildren
parent
1c869098
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletions
+11
-1
lib/ansible/inventory/dir.py
+0
-1
lib/ansible/inventory/group.py
+11
-0
No files found.
lib/ansible/inventory/dir.py
View file @
cc8efb4a
...
@@ -68,7 +68,6 @@ class InventoryDirectory(object):
...
@@ -68,7 +68,6 @@ class InventoryDirectory(object):
self
.
groups
[
name
]
=
group
self
.
groups
[
name
]
=
group
else
:
else
:
# group is already there, copy variables
# group is already there, copy variables
# note: depth numbers on duplicates may be bogus
for
k
,
v
in
group
.
get_variables
()
.
iteritems
():
for
k
,
v
in
group
.
get_variables
()
.
iteritems
():
self
.
groups
[
name
]
.
set_variable
(
k
,
v
)
self
.
groups
[
name
]
.
set_variable
(
k
,
v
)
for
host
in
group
.
hosts
:
for
host
in
group
.
hosts
:
...
...
lib/ansible/inventory/group.py
View file @
cc8efb4a
...
@@ -40,8 +40,13 @@ class Group(object):
...
@@ -40,8 +40,13 @@ class Group(object):
# don't add if it's already there
# don't add if it's already there
if
not
group
in
self
.
child_groups
:
if
not
group
in
self
.
child_groups
:
self
.
child_groups
.
append
(
group
)
self
.
child_groups
.
append
(
group
)
# update the depth of the child
group
.
depth
=
max
([
self
.
depth
+
1
,
group
.
depth
])
group
.
depth
=
max
([
self
.
depth
+
1
,
group
.
depth
])
# update the depth of the grandchildren
group
.
_check_children_depth
()
# now add self to child's parent_groups list, but only if there
# now add self to child's parent_groups list, but only if there
# isn't already a group with the same name
# isn't already a group with the same name
if
not
self
.
name
in
[
g
.
name
for
g
in
group
.
parent_groups
]:
if
not
self
.
name
in
[
g
.
name
for
g
in
group
.
parent_groups
]:
...
@@ -49,6 +54,12 @@ class Group(object):
...
@@ -49,6 +54,12 @@ class Group(object):
self
.
clear_hosts_cache
()
self
.
clear_hosts_cache
()
def
_check_children_depth
(
self
):
for
group
in
self
.
child_groups
:
group
.
depth
=
max
([
self
.
depth
+
1
,
group
.
depth
])
group
.
_check_children_depth
()
def
add_host
(
self
,
host
):
def
add_host
(
self
,
host
):
self
.
hosts
.
append
(
host
)
self
.
hosts
.
append
(
host
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment