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
44279ce3
Commit
44279ce3
authored
Oct 03, 2013
by
Martynas Mickevicius
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow leading ranges in the inventory host entries.
parent
64809451
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
3 deletions
+11
-3
lib/ansible/inventory/expand_hosts.py
+1
-2
lib/ansible/inventory/ini.py
+1
-1
test/TestInventory.py
+6
-0
test/inventory/test_leading_range
+3
-0
No files found.
lib/ansible/inventory/expand_hosts.py
View file @
44279ce3
...
...
@@ -41,8 +41,7 @@ def detect_range(line = None):
Returnes True if the given line contains a pattern, else False.
'''
if
(
not
line
.
startswith
(
"["
)
and
line
.
find
(
"["
)
!=
-
1
and
if
(
line
.
find
(
"["
)
!=
-
1
and
line
.
find
(
":"
)
!=
-
1
and
line
.
find
(
"]"
)
!=
-
1
and
line
.
index
(
"["
)
<
line
.
index
(
":"
)
<
line
.
index
(
"]"
)):
...
...
lib/ansible/inventory/ini.py
View file @
44279ce3
...
...
@@ -65,7 +65,7 @@ class InventoryParser(object):
active_group_name
=
'ungrouped'
for
line
in
self
.
lines
:
if
line
.
startswith
(
"["
):
if
line
.
startswith
(
"["
)
and
line
.
strip
()
.
endswith
(
"]"
)
:
active_group_name
=
line
.
split
(
" #"
)[
0
]
.
replace
(
"["
,
""
)
.
replace
(
"]"
,
""
)
.
strip
()
if
line
.
find
(
":vars"
)
!=
-
1
or
line
.
find
(
":children"
)
!=
-
1
:
active_group_name
=
active_group_name
.
rsplit
(
":"
,
1
)[
0
]
...
...
test/TestInventory.py
View file @
44279ce3
...
...
@@ -294,6 +294,12 @@ class TestInventory(unittest.TestCase):
expected_hosts
=
[
'host1A'
,
'host2A'
,
'host1B'
,
'host2B'
]
assert
sorted
(
hosts
)
==
sorted
(
expected_hosts
)
def
test_leading_range
(
self
):
i
=
Inventory
(
os
.
path
.
join
(
self
.
test_dir
,
'inventory'
,
'test_leading_range'
))
hosts
=
i
.
list_hosts
(
'test'
)
expected_hosts
=
[
'1.host'
,
'2.host'
,
'A.host'
,
'B.host'
]
assert
sorted
(
hosts
)
==
sorted
(
expected_hosts
)
###################################################
### Inventory API tests
...
...
test/inventory/test_leading_range
0 → 100644
View file @
44279ce3
[test]
[1:2].host
[A:B].host
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