template
Purpose: render a template file stored next to the recipe and publish the
result at path on the target.
Synopsis
Section titled “Synopsis”- id: app_conf type: template with: path: /etc/myapp/config.ini source: templates/config.ini mode: "0640" vars: listen_port: 8080[server]listen = {{ template.listen_port }}hostname = {{ facts.hostname }}Parameters
Section titled “Parameters”| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
path |
yes | string (absolute path) | — | Destination on the target. |
source |
yes | string | — | Controller-side template, resolved relative to the recipe file. |
state |
no | string | present |
present or absent. |
vars |
no | map | — | Template-local values, exposed as template.<name>. |
owner |
no | string | — | Owner name. |
group |
no | string | — | Group name. |
mode |
no | string | — | Quoted four-digit octal. |
Expected behavior
Section titled “Expected behavior”- The template is rendered on the controller and published atomically like
file. - Template expressions may read
vars.*,facts.*,registers.*, andtemplate.*.template.*names never shadow the other namespaces. contentis not supported — template resources always usesource.- Only
{{ expression }}is rendered. Write\{{for a literal{{, and{{ "{%" }}for a literal{%. Jinja statement ({% ... %}) and comment ({# ... #}) tags are not supported and are an error (see below), never copied silently. Only an opener followed by its own closer (%}for{%,#}for{#) is a tag. An opener with no closer, and a{#right after$(shell${#var}), are plain text and are published as written. - A template output that really changes a systemd manager input (a unit file, drop-in,
alias/mask/
.wants/.requireslink, orsystem.conf) makes Sinter runsystemctl daemon-reloadautomatically before the next service or handler that needs it, and at the end of a successful apply. See service.
Idempotency
Section titled “Idempotency”Fully idempotent — unchanged rendered output produces no mutation and triggers no handler notification.
Failure behavior
Section titled “Failure behavior”- Missing
sourcefile or template evaluation errors (e.g. undefined variables) fail at validation/apply with a descriptive error — sensitive values are redacted from the message. - A Jinja tag (
{% if ... %},{% for ... %},{# ... #}) fails validation (exit 2) with the resource, the source file, and the line and column of the tag. To publish such a file unchanged, use afileresource withsourceinstead. - Same filesystem safety rules as
file(trust boundary, symlink rejection, atomic publication).
Platform notes
Section titled “Platform notes”Applies to all supported targets.