mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Add code to flag legacy templating like $foo.{bar} as deprecated in favor of Jinja2 {{ foo.bar }} so we
can remove the legacy system at a later date.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
import os
|
||||
|
||||
from ansible import utils
|
||||
from ansible import template
|
||||
from ansible import errors
|
||||
from ansible.runner.return_data import ReturnData
|
||||
import base64
|
||||
@@ -54,7 +55,7 @@ class ActionModule(object):
|
||||
if 'first_available_file' in inject:
|
||||
found = False
|
||||
for fn in inject.get('first_available_file'):
|
||||
fn = utils.template(self.runner.basedir, fn, inject)
|
||||
fn = template.template(self.runner.basedir, fn, inject)
|
||||
fn = utils.path_dwim(self.runner.basedir, fn)
|
||||
if not os.path.exists(fn) and '_original_file' in inject:
|
||||
fn = utils.path_dwim_relative(inject['_original_file'], 'files', fn, self.runner.basedir, check=False)
|
||||
@@ -77,7 +78,7 @@ class ActionModule(object):
|
||||
f.close()
|
||||
source = tmp_content
|
||||
else:
|
||||
source = utils.template(self.runner.basedir, source, inject)
|
||||
source = template.template(self.runner.basedir, source, inject)
|
||||
if '_original_file' in inject:
|
||||
source = utils.path_dwim_relative(inject['_original_file'], 'files', source, self.runner.basedir)
|
||||
else:
|
||||
|
||||
@@ -19,6 +19,7 @@ import os
|
||||
import shlex
|
||||
|
||||
import ansible.constants as C
|
||||
from ansible.utils import template
|
||||
from ansible import utils
|
||||
from ansible import errors
|
||||
from ansible.runner.return_data import ReturnData
|
||||
@@ -39,7 +40,7 @@ class ActionModule(object):
|
||||
source = tokens[0]
|
||||
# FIXME: error handling
|
||||
args = " ".join(tokens[1:])
|
||||
source = utils.template(self.runner.basedir, source, inject)
|
||||
source = template.template(self.runner.basedir, source, inject)
|
||||
source = utils.path_dwim(self.runner.basedir, source)
|
||||
|
||||
# transfer the file to a remote tmp location
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
import os
|
||||
import pipes
|
||||
from ansible.utils import template
|
||||
from ansible import utils
|
||||
from ansible import errors
|
||||
from ansible.runner.return_data import ReturnData
|
||||
@@ -56,7 +57,7 @@ class ActionModule(object):
|
||||
|
||||
found = False
|
||||
for fn in self.runner.module_vars.get('first_available_file'):
|
||||
fnt = utils.template(self.runner.basedir, fn, inject)
|
||||
fnt = template.template(self.runner.basedir, fn, inject)
|
||||
fnd = utils.path_dwim(self.runner.basedir, fnt)
|
||||
if not os.path.exists(fnd) and '_original_file' in inject:
|
||||
fnd = utils.path_dwim_relative(inject['_original_file'], 'templates', fnd, self.runner.basedir, check=False)
|
||||
@@ -68,7 +69,7 @@ class ActionModule(object):
|
||||
result = dict(failed=True, msg="could not find src in first_available_file list")
|
||||
return ReturnData(conn=conn, comm_ok=False, result=result)
|
||||
else:
|
||||
source = utils.template(self.runner.basedir, source, inject)
|
||||
source = template.template(self.runner.basedir, source, inject)
|
||||
|
||||
if '_original_file' in inject:
|
||||
source = utils.path_dwim_relative(inject['_original_file'], 'templates', source, self.runner.basedir)
|
||||
@@ -82,7 +83,7 @@ class ActionModule(object):
|
||||
|
||||
# template the source data locally & get ready to transfer
|
||||
try:
|
||||
resultant = utils.template_from_file(self.runner.basedir, source, inject)
|
||||
resultant = template.template_from_file(self.runner.basedir, source, inject)
|
||||
except Exception, e:
|
||||
result = dict(failed=True, msg=str(e))
|
||||
return ReturnData(conn=conn, comm_ok=False, result=result)
|
||||
|
||||
Reference in New Issue
Block a user