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
e6fa50a3
Commit
e6fa50a3
authored
Jul 29, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move splitter to module_utils so modules can use it and fix command arg splitting
Fixes #8338
parent
912674bd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
9 additions
and
11 deletions
+9
-11
lib/ansible/module_utils/splitter.py
+0
-0
lib/ansible/playbook/play.py
+3
-2
lib/ansible/runner/__init__.py
+1
-1
lib/ansible/utils/__init__.py
+1
-1
library/commands/command
+3
-6
test/units/TestUtils.py
+1
-1
No files found.
lib/ansible/utils/splitter.py
→
lib/ansible/
module_
utils/splitter.py
View file @
e6fa50a3
File moved
lib/ansible/playbook/play.py
View file @
e6fa50a3
...
@@ -21,6 +21,7 @@ from ansible.utils.template import template
...
@@ -21,6 +21,7 @@ from ansible.utils.template import template
from
ansible
import
utils
from
ansible
import
utils
from
ansible
import
errors
from
ansible
import
errors
from
ansible.playbook.task
import
Task
from
ansible.playbook.task
import
Task
from
ansible.module_utils.splitter
import
split_args
,
unquote
import
ansible.constants
as
C
import
ansible.constants
as
C
import
pipes
import
pipes
import
shlex
import
shlex
...
@@ -524,7 +525,7 @@ class Play(object):
...
@@ -524,7 +525,7 @@ class Play(object):
task_vars
[
'_original_file'
]
=
original_file
task_vars
[
'_original_file'
]
=
original_file
if
'include'
in
x
:
if
'include'
in
x
:
tokens
=
utils
.
splitter
.
split_args
(
str
(
x
[
'include'
]))
tokens
=
split_args
(
str
(
x
[
'include'
]))
included_additional_conditions
=
list
(
additional_conditions
)
included_additional_conditions
=
list
(
additional_conditions
)
include_vars
=
{}
include_vars
=
{}
for
k
in
x
:
for
k
in
x
:
...
@@ -573,7 +574,7 @@ class Play(object):
...
@@ -573,7 +574,7 @@ class Play(object):
mv
=
task_vars
.
copy
()
mv
=
task_vars
.
copy
()
for
t
in
tokens
[
1
:]:
for
t
in
tokens
[
1
:]:
(
k
,
v
)
=
t
.
split
(
"="
,
1
)
(
k
,
v
)
=
t
.
split
(
"="
,
1
)
v
=
u
tils
.
splitter
.
u
nquote
(
v
)
v
=
unquote
(
v
)
mv
[
k
]
=
template
(
self
.
basedir
,
v
,
mv
)
mv
[
k
]
=
template
(
self
.
basedir
,
v
,
mv
)
dirname
=
self
.
basedir
dirname
=
self
.
basedir
if
original_file
:
if
original_file
:
...
...
lib/ansible/runner/__init__.py
View file @
e6fa50a3
...
@@ -47,7 +47,7 @@ import connection
...
@@ -47,7 +47,7 @@ import connection
from
return_data
import
ReturnData
from
return_data
import
ReturnData
from
ansible.callbacks
import
DefaultRunnerCallbacks
,
vv
from
ansible.callbacks
import
DefaultRunnerCallbacks
,
vv
from
ansible.module_common
import
ModuleReplacer
from
ansible.module_common
import
ModuleReplacer
from
ansible.utils.splitter
import
split_args
from
ansible.
module_
utils.splitter
import
split_args
module_replacer
=
ModuleReplacer
(
strip_comments
=
False
)
module_replacer
=
ModuleReplacer
(
strip_comments
=
False
)
...
...
lib/ansible/utils/__init__.py
View file @
e6fa50a3
...
@@ -29,7 +29,7 @@ from ansible import __version__
...
@@ -29,7 +29,7 @@ from ansible import __version__
from
ansible.utils.display_functions
import
*
from
ansible.utils.display_functions
import
*
from
ansible.utils.plugins
import
*
from
ansible.utils.plugins
import
*
from
ansible.callbacks
import
display
from
ansible.callbacks
import
display
from
ansible.utils.splitter
import
split_args
,
unquote
from
ansible.
module_
utils.splitter
import
split_args
,
unquote
import
ansible.constants
as
C
import
ansible.constants
as
C
import
ast
import
ast
import
time
import
time
...
...
library/commands/command
View file @
e6fa50a3
...
@@ -186,6 +186,7 @@ def main():
...
@@ -186,6 +186,7 @@ def main():
# import module snippets
# import module snippets
from
ansible.module_utils.basic
import
*
from
ansible.module_utils.basic
import
*
from
ansible.module_utils.splitter
import
*
# only the command module should ever need to do this
# only the command module should ever need to do this
# everything else should be simple key=value
# everything else should be simple key=value
...
@@ -211,18 +212,14 @@ class CommandModule(AnsibleModule):
...
@@ -211,18 +212,14 @@ class CommandModule(AnsibleModule):
args
=
args
.
replace
(
"#USE_SHELL"
,
""
)
args
=
args
.
replace
(
"#USE_SHELL"
,
""
)
params
[
'shell'
]
=
True
params
[
'shell'
]
=
True
# use shlex to split up the args, while being careful to preserve
items
=
split_args
(
args
)
# single quotes so they're not removed accidentally
lexer
=
shlex
.
shlex
(
args
)
lexer
.
whitespace
=
'
\t
'
lexer
.
whitespace_split
=
True
items
=
list
(
lexer
)
for
x
in
items
:
for
x
in
items
:
quoted
=
x
.
startswith
(
'"'
)
and
x
.
endswith
(
'"'
)
or
x
.
startswith
(
"'"
)
and
x
.
endswith
(
"'"
)
quoted
=
x
.
startswith
(
'"'
)
and
x
.
endswith
(
'"'
)
or
x
.
startswith
(
"'"
)
and
x
.
endswith
(
"'"
)
if
'='
in
x
and
not
quoted
:
if
'='
in
x
and
not
quoted
:
# check to see if this is a special parameter for the command
# check to see if this is a special parameter for the command
k
,
v
=
x
.
split
(
'='
,
1
)
k
,
v
=
x
.
split
(
'='
,
1
)
v
=
unquote
(
v
)
# because we're not breaking out quotes in the shlex split
# because we're not breaking out quotes in the shlex split
# above, the value of the k=v pair may still be quoted. If
# above, the value of the k=v pair may still be quoted. If
# so, remove them.
# so, remove them.
...
...
test/units/TestUtils.py
View file @
e6fa50a3
...
@@ -17,7 +17,7 @@ import ansible.utils
...
@@ -17,7 +17,7 @@ import ansible.utils
import
ansible.errors
import
ansible.errors
import
ansible.constants
as
C
import
ansible.constants
as
C
import
ansible.utils.template
as
template2
import
ansible.utils.template
as
template2
from
ansible.utils.splitter
import
split_args
from
ansible.
module_
utils.splitter
import
split_args
from
ansible
import
__version__
from
ansible
import
__version__
...
...
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