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
1170a453
Commit
1170a453
authored
Aug 27, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12114 from ilya-epifanov/devel
fixed hostvars access in conjunction with --limit usage
parents
ef594f70
81bf88b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
lib/ansible/inventory/__init__.py
+10
-8
lib/ansible/vars/hostvars.py
+1
-1
No files found.
lib/ansible/inventory/__init__.py
View file @
1170a453
...
@@ -178,7 +178,7 @@ class Inventory(object):
...
@@ -178,7 +178,7 @@ class Inventory(object):
return
[
x
for
x
in
term
.
findall
(
pattern
)
if
x
]
return
[
x
for
x
in
term
.
findall
(
pattern
)
if
x
]
def
get_hosts
(
self
,
pattern
=
"all"
):
def
get_hosts
(
self
,
pattern
=
"all"
,
ignore_limits_and_restrictions
=
False
):
"""
"""
Takes a pattern or list of patterns and returns a list of matching
Takes a pattern or list of patterns and returns a list of matching
inventory host names, taking into account any active restrictions
inventory host names, taking into account any active restrictions
...
@@ -196,14 +196,16 @@ class Inventory(object):
...
@@ -196,14 +196,16 @@ class Inventory(object):
patterns
=
self
.
_split_pattern
(
pattern
)
patterns
=
self
.
_split_pattern
(
pattern
)
hosts
=
self
.
_evaluate_patterns
(
patterns
)
hosts
=
self
.
_evaluate_patterns
(
patterns
)
# exclude hosts not in a subset, if defined
# mainly useful for hostvars[host] access
if
self
.
_subset
:
if
not
ignore_limits_and_restrictions
:
subset
=
self
.
_evaluate_patterns
(
self
.
_subset
)
# exclude hosts not in a subset, if defined
hosts
=
[
h
for
h
in
hosts
if
h
in
subset
]
if
self
.
_subset
:
subset
=
self
.
_evaluate_patterns
(
self
.
_subset
)
hosts
=
[
h
for
h
in
hosts
if
h
in
subset
]
# exclude hosts mentioned in any restriction (ex: failed hosts)
# exclude hosts mentioned in any restriction (ex: failed hosts)
if
self
.
_restriction
is
not
None
:
if
self
.
_restriction
is
not
None
:
hosts
=
[
h
for
h
in
hosts
if
h
in
self
.
_restriction
]
hosts
=
[
h
for
h
in
hosts
if
h
in
self
.
_restriction
]
return
hosts
return
hosts
...
...
lib/ansible/vars/hostvars.py
View file @
1170a453
...
@@ -43,7 +43,7 @@ class HostVars(collections.Mapping):
...
@@ -43,7 +43,7 @@ class HostVars(collections.Mapping):
# in inventory
# in inventory
restriction
=
inventory
.
_restriction
restriction
=
inventory
.
_restriction
inventory
.
remove_restriction
()
inventory
.
remove_restriction
()
hosts
=
inventory
.
get_hosts
()
hosts
=
inventory
.
get_hosts
(
ignore_limits_and_restrictions
=
True
)
inventory
.
restrict_to_hosts
(
restriction
)
inventory
.
restrict_to_hosts
(
restriction
)
# check to see if localhost is in the hosts list, as we
# check to see if localhost is in the hosts list, as we
...
...
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