From d00a89afd46e2e1a84eba3d11ffe8fcfb5cf5513 Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Fri, 24 May 2013 16:24:45 -0600 Subject: [PATCH] Parse kwargs with YAML, Fix #5224 --- salt/minion.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/salt/minion.py b/salt/minion.py index 10715cfd8c..7fba958847 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -134,10 +134,10 @@ def detect_kwargs(func, args, data=None): # Invalid kwarg pass elif has_kwargs: - kwargs[comps[0]] = '='.join(comps[1:]) + kwargs[comps[0]] = yamlify_arg('='.join(comps[1:])) continue elif comps[0] in kwarg_spec: - kwargs[comps[0]] = '='.join(comps[1:]) + kwargs[comps[0]] = yamlify_arg('='.join(comps[1:])) continue _args.append(arg) if has_kwargs and isinstance(data, dict): @@ -147,6 +147,18 @@ def detect_kwargs(func, args, data=None): return _args, kwargs +def yamlify_arg(arg): + ''' + yaml.safe_load the arg unless it has a newline in it + ''' + try: + if '\n' not in arg: + return yaml.safe_load(arg) + except Exception: + pass + return arg + + class SMinion(object): ''' Create an object that has loaded all of the minion module functions,