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
9f9e9759
Commit
9f9e9759
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
d9fb9437
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
lib/ansible/inventory/__init__.py
+15
-8
No files found.
lib/ansible/inventory/__init__.py
View file @
9f9e9759
...
...
@@ -150,17 +150,24 @@ class Inventory(object):
def
_match
(
self
,
str
,
pattern_str
):
if
pattern_str
.
startswith
(
'~'
):
return
re
.
search
(
pattern_str
[
1
:],
str
)
else
:
return
fnmatch
.
fnmatch
(
str
,
pattern_str
)
try
:
if
pattern_str
.
startswith
(
'~'
):
return
re
.
search
(
pattern_str
[
1
:],
str
)
else
:
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
):
results
=
[]
if
not
pattern_str
.
startswith
(
'~'
):
pattern
=
re
.
compile
(
fnmatch
.
translate
(
pattern_str
))
else
:
pattern
=
re
.
compile
(
pattern_str
[
1
:])
try
:
if
not
pattern_str
.
startswith
(
'~'
):
pattern
=
re
.
compile
(
'^'
+
fnmatch
.
translate
(
pattern_str
))
else
:
pattern
=
re
.
compile
(
pattern_str
[
1
:])
except
Exception
,
e
:
raise
errors
.
AnsibleError
(
'invalid host pattern:
%
s'
%
pattern_str
)
for
item
in
items
:
if
pattern
.
search
(
getattr
(
item
,
item_attr
)):
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