file_from_remote_template

Build a file from a template on the Rudder server.

⚙️ Compatible targets: Linux

Parameters

NameDocumentation
source_templateSource file containing a template to be expanded (absolute path on the server).

This parameter is required.
destinationDestination file (absolute path on the target node).

This parameter is required.
template_typeTemplate type (jinja2 or mustache).

Choices:
  • jinja2
  • mustache

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
  • ❌ Error: file_from_remote_template_${destination}_error

Example

method: file_from_remote_template
params:
  destination: VALUE
  template_type: jinja2
  source_template: VALUE

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:

Reporting

This method will provide extra log_warning message if the template was not updated, but the destination file is modified.