Skip to content

Commit e8685a6

Browse files
committed
Trust systemd unit template
With ansible 2.19 jinja templating changes, data that can contain templates will require explicit trust via trust_as_template to be allowed to render. Signed-off-by: rabi <[email protected]>
1 parent 977ed63 commit e8685a6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

plugins/action/container_systemd.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525

2626
from ansible.errors import AnsibleActionFail
2727
from ansible.plugins.action import ActionBase
28+
try:
29+
from ansible.template import trust_as_template
30+
except ImportError:
31+
def trust_as_template(data):
32+
return data
2833
from ansible.utils.display import Display
2934

3035

@@ -200,11 +205,10 @@ def _get_unit_template(self):
200205
'systemd-service.j2'
201206
)
202207
if not os.path.exists(source):
203-
raise AnsibleActionFail('Template {} was '
204-
'not found'.format(source))
208+
raise AnsibleActionFail('Template {} was not found'.format(source))
205209
with open(source) as template_file:
206210
data = template_file.read()
207-
return data
211+
return trust_as_template(data)
208212

209213
def _create_units(self, container_config, task_vars):
210214
"""Create system units and get list of changed services

0 commit comments

Comments
 (0)