mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #3464 from stoned/filterquote
Add Jinja2 filter 'quote' to quote string for shell usage
This commit is contained in:
commit
279247dfac
1 changed files with 8 additions and 0 deletions
|
@ -20,6 +20,7 @@ import json
|
||||||
import os.path
|
import os.path
|
||||||
import yaml
|
import yaml
|
||||||
import types
|
import types
|
||||||
|
import pipes
|
||||||
from ansible import errors
|
from ansible import errors
|
||||||
|
|
||||||
def to_nice_yaml(*a, **kw):
|
def to_nice_yaml(*a, **kw):
|
||||||
|
@ -61,6 +62,10 @@ def bool(a):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def quote(a):
|
||||||
|
''' return its argument quoted for shell usage '''
|
||||||
|
return pipes.quote(a)
|
||||||
|
|
||||||
class FilterModule(object):
|
class FilterModule(object):
|
||||||
''' Ansible core jinja2 filters '''
|
''' Ansible core jinja2 filters '''
|
||||||
|
|
||||||
|
@ -93,5 +98,8 @@ class FilterModule(object):
|
||||||
|
|
||||||
# value as boolean
|
# value as boolean
|
||||||
'bool': bool,
|
'bool': bool,
|
||||||
|
|
||||||
|
# quote string for shell usage
|
||||||
|
'quote': quote,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue