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
ee6ea974
Commit
ee6ea974
authored
May 31, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3082 from pol/devel
Handle '#' in var strings by splitting on ' #'
parents
4a5b567f
4432c01c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
4 deletions
+4
-4
lib/ansible/inventory/ini.py
+2
-2
test/TestInventory.py
+1
-1
test/inventory_dir/3comments
+1
-1
No files found.
lib/ansible/inventory/ini.py
View file @
ee6ea974
...
...
@@ -65,7 +65,7 @@ class InventoryParser(object):
for
line
in
self
.
lines
:
if
line
.
startswith
(
"["
):
active_group_name
=
line
.
split
(
"#"
)[
0
]
.
replace
(
"["
,
""
)
.
replace
(
"]"
,
""
)
.
strip
()
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
]
if
active_group_name
not
in
self
.
groups
:
...
...
@@ -78,7 +78,7 @@ class InventoryParser(object):
elif
line
.
startswith
(
"#"
)
or
line
==
''
:
pass
elif
active_group_name
:
tokens
=
shlex
.
split
(
line
.
split
(
"#"
)[
0
])
tokens
=
shlex
.
split
(
line
.
split
(
"
#"
)[
0
])
if
len
(
tokens
)
==
0
:
continue
hostname
=
tokens
[
0
]
...
...
test/TestInventory.py
View file @
ee6ea974
...
...
@@ -302,4 +302,4 @@ class TestInventory(unittest.TestCase):
assert
vars
==
{
'inventory_hostname'
:
'zeus'
,
'inventory_hostname_short'
:
'zeus'
,
'group_names'
:
[
'greek'
,
'major-god'
,
'ungrouped'
],
'var_a'
:
'1'
}
'var_a'
:
'1
#2
'
}
test/inventory_dir/3comments
View file @
ee6ea974
[major-god] # group with inline comments
zeus var_a=
1 # host with inline comments
zeus var_a=
"1#2" # host with inline comments and "#" in the var string
# A comment
thor
...
...
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