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
d4cc8dc2
Commit
d4cc8dc2
authored
May 19, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix hosts being in multiple groups, and duplicate host references in the same inventory file.
parent
5672d561
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
3 deletions
+27
-3
lib/ansible/inventory_parser.py
+7
-1
test/TestInventory.py
+2
-2
test/complex_hosts
+18
-0
No files found.
lib/ansible/inventory_parser.py
View file @
d4cc8dc2
...
...
@@ -37,6 +37,7 @@ class InventoryParser(object):
fh
=
open
(
filename
)
self
.
lines
=
fh
.
readlines
()
self
.
groups
=
{}
self
.
hosts
=
{}
self
.
_parse
()
def
_parse
(
self
):
...
...
@@ -81,7 +82,12 @@ class InventoryParser(object):
tokens2
=
hostname
.
split
(
":"
)
hostname
=
tokens2
[
0
]
port
=
tokens2
[
1
]
host
=
Host
(
name
=
hostname
,
port
=
port
)
host
=
None
if
hostname
in
self
.
hosts
:
host
=
self
.
hosts
[
hostname
]
else
:
host
=
Host
(
name
=
hostname
,
port
=
port
)
self
.
hosts
[
hostname
]
=
host
if
len
(
tokens
)
>
1
:
for
t
in
tokens
[
1
:]:
(
k
,
v
)
=
t
.
split
(
"="
)
...
...
test/TestInventory.py
View file @
d4cc8dc2
...
...
@@ -128,9 +128,9 @@ class TestInventory(unittest.TestCase):
print
vars
expected
=
dict
(
a
=
'1'
,
b
=
'2'
,
c
=
'3'
,
d
=
'100002'
,
a
=
'1'
,
b
=
'2'
,
c
=
'3'
,
d
=
'100002'
,
rga
=
'1'
,
rgb
=
'2'
,
rgc
=
'3'
,
inventory_hostname
=
'rtp_a'
,
group_names
=
[
'eastcoast'
,
'nc'
,
'rtp'
,
'us'
]
group_names
=
[
'eastcoast'
,
'nc'
,
'r
edundantgroup'
,
'redundantgroup2'
,
'redundantgroup3'
,
'r
tp'
,
'us'
]
)
print
vars
print
expected
...
...
test/complex_hosts
View file @
d4cc8dc2
...
...
@@ -12,6 +12,24 @@ florida
[us:children]
eastcoast
[redundantgroup]
rtp_a
[redundantgroup2]
rtp_a
[redundantgroup3:children]
rtp
[redundantgroup:vars]
rga=1
[redundantgroup2:vars]
rgb=2
[redundantgroup3:vars]
rgc=3
[nc:vars]
b=10000
c=10001
...
...
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