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
82cca242
Commit
82cca242
authored
Jul 24, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use AnsibleError so that if there is an error it does not print a traceback
parent
8fa4dc39
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
lib/ansible/inventory/expand_hosts.py
+5
-3
No files found.
lib/ansible/inventory/expand_hosts.py
View file @
82cca242
...
@@ -31,6 +31,8 @@ Note that when beg is specified with left zero padding, then the length of
...
@@ -31,6 +31,8 @@ Note that when beg is specified with left zero padding, then the length of
end must be the same as that of beg, else a exception is raised.
end must be the same as that of beg, else a exception is raised.
'''
'''
from
ansible
import
errors
def
detect_range
(
line
=
None
):
def
detect_range
(
line
=
None
):
'''
'''
A helper function that checks a given host line to see if it contains
A helper function that checks a given host line to see if it contains
...
@@ -70,19 +72,19 @@ def expand_hostname_range(line = None):
...
@@ -70,19 +72,19 @@ def expand_hostname_range(line = None):
(
head
,
nrange
,
tail
)
=
line
.
replace
(
'['
,
'|'
)
.
replace
(
']'
,
'|'
)
.
split
(
'|'
)
(
head
,
nrange
,
tail
)
=
line
.
replace
(
'['
,
'|'
)
.
replace
(
']'
,
'|'
)
.
split
(
'|'
)
bounds
=
nrange
.
split
(
":"
)
bounds
=
nrange
.
split
(
":"
)
if
len
(
bounds
)
!=
2
:
if
len
(
bounds
)
!=
2
:
raise
Valu
eError
(
"host range incorrectly specified"
)
raise
errors
.
Ansibl
eError
(
"host range incorrectly specified"
)
beg
=
bounds
[
0
]
beg
=
bounds
[
0
]
end
=
bounds
[
1
]
end
=
bounds
[
1
]
if
not
beg
:
if
not
beg
:
beg
=
"0"
beg
=
"0"
if
not
end
:
if
not
end
:
raise
Valu
eError
(
"host range end value missing"
)
raise
errors
.
Ansibl
eError
(
"host range end value missing"
)
if
beg
[
0
]
==
'0'
and
len
(
beg
)
>
1
:
if
beg
[
0
]
==
'0'
and
len
(
beg
)
>
1
:
rlen
=
len
(
beg
)
# range length formatting hint
rlen
=
len
(
beg
)
# range length formatting hint
else
:
else
:
rlen
=
None
rlen
=
None
if
rlen
>
1
and
rlen
!=
len
(
end
):
if
rlen
>
1
and
rlen
!=
len
(
end
):
raise
Valu
eError
(
"host range format incorrectly specified!"
)
raise
errors
.
Ansibl
eError
(
"host range format incorrectly specified!"
)
for
_
in
range
(
int
(
beg
),
int
(
end
)
+
1
):
for
_
in
range
(
int
(
beg
),
int
(
end
)
+
1
):
if
rlen
:
if
rlen
:
...
...
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