mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 20:01:25 -07: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:
parent
b8c4bb9e6e
commit
cc948f339c
9 changed files with 79 additions and 29 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue