Use split_args directly to check for omitted params
This commit is contained in:
parent
04da466c7b
commit
a6ad374668
1 changed files with 18 additions and 10 deletions
|
@ -46,7 +46,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.module_utils.splitter import split_args
|
from ansible.module_utils.splitter import split_args, unquote
|
||||||
from ansible.cache import FactCache
|
from ansible.cache import FactCache
|
||||||
from ansible.utils import update_hash
|
from ansible.utils import update_hash
|
||||||
|
|
||||||
|
@ -896,16 +896,24 @@ class Runner(object):
|
||||||
except jinja2.exceptions.UndefinedError, e:
|
except jinja2.exceptions.UndefinedError, e:
|
||||||
raise errors.AnsibleUndefinedVariable("One or more undefined variables: %s" % str(e))
|
raise errors.AnsibleUndefinedVariable("One or more undefined variables: %s" % str(e))
|
||||||
|
|
||||||
def not_omitted(item):
|
# filter omitted arguments out from complex_args
|
||||||
return item[1] != self.omit_token
|
if complex_args:
|
||||||
|
complex_args = dict(filter(lambda x: x[1] != self.omit_token, complex_args.iteritems()))
|
||||||
|
|
||||||
if module_name not in ['shell', 'command', 'include_vars']:
|
# Filter omitted arguments out from module_args.
|
||||||
# filter omitted arguments out from complex_args
|
# We do this with split_args instead of parse_kv to ensure
|
||||||
complex_args = dict(filter(not_omitted, complex_args.iteritems()))
|
# that things are not unquoted/requoted incorrectly
|
||||||
# filter omitted arguments out from module_args
|
args = split_args(module_args)
|
||||||
module_kv = utils.parse_kv(module_args)
|
final_args = []
|
||||||
module_kv = dict(filter(not_omitted, module_kv.iteritems()))
|
for arg in args:
|
||||||
module_args = utils.serialize_args(module_kv)
|
if '=' in arg:
|
||||||
|
k,v = arg.split('=', 1)
|
||||||
|
if unquote(v) != self.omit_token:
|
||||||
|
final_args.append(arg)
|
||||||
|
else:
|
||||||
|
# not a k=v param, append it
|
||||||
|
final_args.append(arg)
|
||||||
|
module_args = ' '.join(final_args)
|
||||||
|
|
||||||
result = handler.run(conn, tmp, module_name, module_args, inject, complex_args)
|
result = handler.run(conn, tmp, module_name, module_args, inject, complex_args)
|
||||||
# Code for do until feature
|
# Code for do until feature
|
||||||
|
|
Loading…
Reference in a new issue