Fixing up serialize_args utility function
This commit is contained in:
parent
e99db078b4
commit
04da466c7b
2 changed files with 13 additions and 14 deletions
|
@ -49,7 +49,6 @@ from ansible.module_common import ModuleReplacer
|
|||
from ansible.module_utils.splitter import split_args
|
||||
from ansible.cache import FactCache
|
||||
from ansible.utils import update_hash
|
||||
from ansible.utils import OMIT_PLACE_HOLDER
|
||||
|
||||
module_replacer = ModuleReplacer(strip_comments=False)
|
||||
|
||||
|
@ -629,13 +628,8 @@ class Runner(object):
|
|||
inject['vars'] = self.module_vars
|
||||
inject['defaults'] = self.default_vars
|
||||
inject['environment'] = self.environment
|
||||
<<<<<<< HEAD
|
||||
inject['playbook_dir'] = os.path.abspath(self.basedir)
|
||||
inject['omit'] = OMIT_PLACE_HOLDER
|
||||
=======
|
||||
inject['playbook_dir'] = self.basedir
|
||||
inject['omit'] = self.omit_token
|
||||
>>>>>>> Additional fixes for the new omit parameter variable
|
||||
|
||||
# template this one is available, callbacks use this
|
||||
delegate_to = self.module_vars.get('delegate_to')
|
||||
|
|
|
@ -545,6 +545,18 @@ def parse_json(raw_data, from_remote=False, from_inventory=False):
|
|||
|
||||
return results
|
||||
|
||||
def serialize_args(args):
|
||||
'''
|
||||
Flattens a dictionary args to a k=v string
|
||||
'''
|
||||
module_args = ""
|
||||
for (k,v) in args.iteritems():
|
||||
if isinstance(v, basestring):
|
||||
module_args = "%s=%s %s" % (k, pipes.quote(v), module_args)
|
||||
elif isinstance(v, bool):
|
||||
module_args = "%s=%s %s" % (k, str(v), module_args)
|
||||
return module_args.strip()
|
||||
|
||||
def merge_module_args(current_args, new_args):
|
||||
'''
|
||||
merges either a dictionary or string of k=v pairs with another string of k=v pairs,
|
||||
|
@ -559,14 +571,7 @@ def merge_module_args(current_args, new_args):
|
|||
elif isinstance(new_args, basestring):
|
||||
new_args_kv = parse_kv(new_args)
|
||||
final_args.update(new_args_kv)
|
||||
# then we re-assemble into a string
|
||||
module_args = ""
|
||||
for (k,v) in final_args.iteritems():
|
||||
if isinstance(v, basestring):
|
||||
module_args = "%s=%s %s" % (k, pipes.quote(v), module_args)
|
||||
elif isinstance(v, bool):
|
||||
module_args = "%s=%s %s" % (k, str(v), module_args)
|
||||
return module_args.strip()
|
||||
return serialize_args(final_args)
|
||||
|
||||
def parse_yaml(data, path_hint=None):
|
||||
''' convert a yaml string to a data structure. Also supports JSON, ssssssh!!!'''
|
||||
|
|
Loading…
Reference in a new issue