From 247322bb16f608229136a1fb5dfec7b72cff886f Mon Sep 17 00:00:00 2001 From: Stoned Elipot Date: Mon, 8 Jul 2013 00:37:23 +0200 Subject: [PATCH] Add Jinja2 filter 'quote' to quote string for shell usage --- lib/ansible/runner/filter_plugins/core.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/ansible/runner/filter_plugins/core.py b/lib/ansible/runner/filter_plugins/core.py index 107c5e1fcb5..4aed6ed7841 100644 --- a/lib/ansible/runner/filter_plugins/core.py +++ b/lib/ansible/runner/filter_plugins/core.py @@ -20,6 +20,7 @@ import json import os.path import yaml import types +import pipes from ansible import errors def to_nice_yaml(*a, **kw): @@ -61,6 +62,10 @@ def bool(a): else: return False +def quote(a): + ''' return its argument quoted for shell usage ''' + return pipes.quote(a) + class FilterModule(object): ''' Ansible core jinja2 filters ''' @@ -93,5 +98,8 @@ class FilterModule(object): # value as boolean 'bool': bool, + + # quote string for shell usage + 'quote': quote, }