file_from_remote_template
Build a file from a template on the Rudder server.
⚙️ Compatible targets: Linux
Parameters
Name | Documentation |
---|---|
source_template | Source file containing a template to be expanded (absolute path on the server). This parameter is required. |
destination | Destination file (absolute path on the target node). This parameter is required. |
template_type | Template type (jinja2 or mustache). Choices:
This parameter is required. |
Outcome conditions
You need to replace ${destination}
with its actual canonified value.
- ✅ Ok:
file_from_remote_template_${destination}_ok
- ☑️ Already compliant:
file_from_remote_template_${destination}_kept
- 🟨 Repaired:
file_from_remote_template_${destination}_repaired
- ☑️ Already compliant:
- ❌ Error:
file_from_remote_template_${destination}_error
Example
method: file_from_remote_template
params:
source_template: VALUE
destination: VALUE
template_type: jinja2
Documentation
Write a file based on a template on the Rudder server and data available on the node
Usage
To use this method, you need to have:
- a template on the Rudder server shared folder
- data to fill this template
The template needs to be located in the shared-files folder and can be accessed with:
/var/rudder/configuration-repository/shared-files/PATH_TO_YOUR_FILE
The data that will be used while expanding the template is the data available in the agent at the time of expansion. That means:
- Agent's system variables (
${sys.*}
, ...) and conditions (linux
, ...) - data defined during execution (result conditions of generic methods, ...)
- conditions based on
condition_
generic methods - data defined using
variable_*
generic methods, which allow for example to load data from local json or yaml files.
Template types
Supported templating languages:
- mustache templates, which are documented in file_from_template_mustache
- jinja2 templates, which are documented in file_from_template_jinja2
Reporting
This method will provide extra log_warning
message if the template was not updated, but the destination
file is modified.