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
6de8c270
Commit
6de8c270
authored
Aug 14, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load parent groups when processing group_vars
parent
ded0c617
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
lib/ansible/inventory/__init__.py
+10
-0
lib/ansible/inventory/group.py
+3
-1
lib/ansible/playbook/play.py
+2
-1
No files found.
lib/ansible/inventory/__init__.py
View file @
6de8c270
...
...
@@ -200,6 +200,16 @@ class Inventory(object):
hosts
[
host
.
name
]
=
host
return
sorted
(
hosts
.
values
(),
key
=
lambda
x
:
x
.
name
)
def
groups_for_host
(
self
,
host
):
results
=
[]
groups
=
self
.
get_groups
()
for
group
in
groups
:
for
hostn
in
group
.
get_hosts
():
if
host
==
hostn
.
name
:
results
.
append
(
group
)
continue
return
results
def
get_groups
(
self
):
return
self
.
groups
...
...
lib/ansible/inventory/group.py
View file @
6de8c270
...
...
@@ -18,10 +18,11 @@
class
Group
(
object
):
''' a group of ansible hosts '''
__slots__
=
[
'name'
,
'hosts'
,
'vars'
,
'child_groups'
,
'parent_groups'
]
__slots__
=
[
'name'
,
'hosts'
,
'vars'
,
'child_groups'
,
'parent_groups'
,
'depth'
]
def
__init__
(
self
,
name
=
None
):
self
.
depth
=
0
self
.
name
=
name
self
.
hosts
=
[]
self
.
vars
=
{}
...
...
@@ -35,6 +36,7 @@ class Group(object):
if
self
==
group
:
raise
Exception
(
"can't add group to itself"
)
self
.
child_groups
.
append
(
group
)
group
.
depth
=
group
.
depth
+
1
group
.
parent_groups
.
append
(
self
)
def
add_host
(
self
,
host
):
...
...
lib/ansible/playbook/play.py
View file @
6de8c270
...
...
@@ -226,7 +226,8 @@ class Play(object):
if
(
host
is
not
None
):
inventory
=
self
.
playbook
.
inventory
hostrec
=
inventory
.
get_host
(
host
)
groups
=
[
g
.
name
for
g
in
hostrec
.
groups
]
groupz
=
sorted
(
inventory
.
groups_for_host
(
host
),
key
=
lambda
g
:
g
.
depth
)
groups
=
[
g
.
name
for
g
in
groupz
]
basedir
=
inventory
.
basedir
()
if
basedir
is
not
None
:
for
x
in
groups
:
...
...
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