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
f48fa375
Commit
f48fa375
authored
Aug 14, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix host pattern matching and enhance error detection
Fixes #8614
parent
a01d97f1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletions
+8
-1
lib/ansible/inventory/__init__.py
+8
-1
No files found.
lib/ansible/inventory/__init__.py
View file @
f48fa375
...
@@ -150,17 +150,24 @@ class Inventory(object):
...
@@ -150,17 +150,24 @@ class Inventory(object):
def
_match
(
self
,
str
,
pattern_str
):
def
_match
(
self
,
str
,
pattern_str
):
try
:
if
pattern_str
.
startswith
(
'~'
):
if
pattern_str
.
startswith
(
'~'
):
return
re
.
search
(
pattern_str
[
1
:],
str
)
return
re
.
search
(
pattern_str
[
1
:],
str
)
else
:
else
:
return
fnmatch
.
fnmatch
(
str
,
pattern_str
)
return
fnmatch
.
fnmatch
(
str
,
pattern_str
)
except
Exception
,
e
:
raise
errors
.
AnsibleError
(
'invalid host pattern:
%
s'
%
pattern_str
)
def
_match_list
(
self
,
items
,
item_attr
,
pattern_str
):
def
_match_list
(
self
,
items
,
item_attr
,
pattern_str
):
results
=
[]
results
=
[]
try
:
if
not
pattern_str
.
startswith
(
'~'
):
if
not
pattern_str
.
startswith
(
'~'
):
pattern
=
re
.
compile
(
fnmatch
.
translate
(
pattern_str
))
pattern
=
re
.
compile
(
'^'
+
fnmatch
.
translate
(
pattern_str
))
else
:
else
:
pattern
=
re
.
compile
(
pattern_str
[
1
:])
pattern
=
re
.
compile
(
pattern_str
[
1
:])
except
Exception
,
e
:
raise
errors
.
AnsibleError
(
'invalid host pattern:
%
s'
%
pattern_str
)
for
item
in
items
:
for
item
in
items
:
if
pattern
.
search
(
getattr
(
item
,
item_attr
)):
if
pattern
.
search
(
getattr
(
item
,
item_attr
)):
results
.
append
(
item
)
results
.
append
(
item
)
...
...
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