misc cleanup in the runner module, splitting some things out into utils, breaking up functions into smaller functions.

This commit is contained in:
Michael DeHaan 2012-03-21 23:39:09 -04:00
commit 6a7aac38c5
3 changed files with 259 additions and 337 deletions

View file

@ -272,6 +272,9 @@ def template(text, vars):
template = jinja2.Template(text)
return template.render(vars)
def double_template(text, vars):
return template(template(text, vars), vars)
def template_from_file(path, vars):
''' run a file through the templating engine '''
data = file(path).read()
@ -287,4 +290,12 @@ def parse_yaml_from_file(path):
raise errors.AnsibleError("file not found: %s" % path)
return parse_yaml(data)
def parse_kv(args):
''' convert a string of key/value items to a dict '''
options = {}
for x in args:
if x.find("=") != -1:
k, v = x.split("=")
options[k]=v
return options