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
7fbb7e07
Commit
7fbb7e07
authored
Dec 16, 2012
by
Junegunn Choi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix hostname expansion bug in inventory parser
parent
23f2a7fc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
20 deletions
+32
-20
lib/ansible/inventory/ini.py
+16
-20
test/TestInventory.py
+11
-0
test/complex_hosts
+5
-0
No files found.
lib/ansible/inventory/ini.py
View file @
7fbb7e07
...
...
@@ -93,28 +93,24 @@ class InventoryParser(object):
hostname
=
tokens2
[
0
]
port
=
tokens2
[
1
]
host
=
None
_all_hosts
=
[]
if
hostname
in
self
.
hosts
:
host
=
self
.
hosts
[
hostname
]
_all_hosts
.
append
(
host
)
hostnames
=
[]
if
detect_range
(
hostname
):
hostnames
=
expand_hostname_range
(
hostname
)
else
:
if
detect_range
(
hostname
):
_hosts
=
expand_hostname_range
(
hostname
)
for
_
in
_host
s
:
host
=
Host
(
name
=
_
,
port
=
port
)
self
.
hosts
[
_
]
=
host
_all_hosts
.
append
(
host
)
hostnames
=
[
hostname
]
for
hn
in
hostname
s
:
host
=
None
if
hn
in
self
.
hosts
:
host
=
self
.
hosts
[
hn
]
else
:
host
=
Host
(
name
=
hostname
,
port
=
port
)
self
.
hosts
[
hostname
]
=
host
_all_hosts
.
append
(
host
)
if
len
(
tokens
)
>
1
:
for
t
in
tokens
[
1
:]:
(
k
,
v
)
=
t
.
split
(
"="
)
host
.
set_variable
(
k
,
v
)
for
_
in
_all_hosts
:
self
.
groups
[
active_group_name
]
.
add_host
(
_
)
host
=
Host
(
name
=
hn
,
port
=
port
)
self
.
hosts
[
hn
]
=
host
if
len
(
tokens
)
>
1
:
for
t
in
tokens
[
1
:]:
(
k
,
v
)
=
t
.
split
(
"="
)
host
.
set_variable
(
k
,
v
)
self
.
groups
[
active_group_name
]
.
add_host
(
host
)
# [southeast:children]
# atlanta
...
...
test/TestInventory.py
View file @
7fbb7e07
...
...
@@ -150,6 +150,17 @@ class TestInventory(unittest.TestCase):
print
expected
assert
vars
==
expected
def
test_complex_group_names
(
self
):
inventory
=
self
.
complex_inventory
()
tests
=
{
'host1'
:
[
'role1'
],
'host2'
:
[
'role1'
,
'role2'
],
'host3'
:
[
'role2'
]
}
for
host
,
roles
in
tests
.
iteritems
():
group_names
=
inventory
.
get_variables
(
host
)[
'group_names'
]
assert
sorted
(
group_names
)
==
sorted
(
roles
)
def
test_complex_exclude
(
self
):
inventory
=
self
.
complex_inventory
()
hosts
=
inventory
.
list_hosts
(
"nc:florida:!triangle:!orlando"
)
...
...
test/complex_hosts
View file @
7fbb7e07
...
...
@@ -73,4 +73,9 @@ d=100002
[us:vars]
c=1000000
[role1]
host[1:2]
[role2]
host[2:3]
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