mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Allow including files through variables
$FILE{file} will be replaced with the contents of "file"
$PIPE{cat file} will be replaced with the output of "cat file"
This commit is contained in:
@@ -16,7 +16,7 @@ class TestUtils(unittest.TestCase):
|
||||
}
|
||||
}
|
||||
|
||||
res = ansible.utils._varLookup('data.who', vars)
|
||||
res = ansible.utils.varLookup('${data.who}', vars)
|
||||
|
||||
assert sorted(res) == sorted(vars['data']['who'])
|
||||
|
||||
@@ -209,10 +209,24 @@ class TestUtils(unittest.TestCase):
|
||||
'person': 'one',
|
||||
}
|
||||
|
||||
res = ansible.utils.template(template, vars)
|
||||
res = ansible.utils.template(None, template, vars)
|
||||
|
||||
assert res == u'hello oh great one'
|
||||
|
||||
def test_varReplace_include(self):
|
||||
template = 'hello $FILE{world}'
|
||||
|
||||
res = ansible.utils.template("test", template, {})
|
||||
|
||||
assert res == u'hello world\n'
|
||||
|
||||
def test_varReplace_include_script(self):
|
||||
template = 'hello $PIPE{echo world}'
|
||||
|
||||
res = ansible.utils.template("test", template, {})
|
||||
|
||||
assert res == u'hello world\n'
|
||||
|
||||
#####################################
|
||||
### Template function tests
|
||||
|
||||
|
||||
Reference in New Issue
Block a user