Skip to content

Instantly share code, notes, and snippets.

@gaelcolas
Created April 22, 2021 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaelcolas/ca8bc14b5846ab72f446961ea0a9dde1 to your computer and use it in GitHub Desktop.
Save gaelcolas/ca8bc14b5846ab72f446961ea0a9dde1 to your computer and use it in GitHub Desktop.
basic jinja composite with explicit parameters
Configuration MyComposite {
Params (
$TemplateFilePath = 'MyJinja2Template.tpl',
$parameter1,
$parameter2
)
$tempParamFile = [io.Path]::GetTempFileName()
@{
Param1 = $parameter1
Param2 = $parameter2
} | ConvertTo-Json | out-file -FilePath $tempParamFile -Force
# if you're in Datum, you can just get the RSOP (resultant set of policy) of the data for the current node, and export to JSON.
$jinja2Result = jinja2 @($TemplateFilePath,$tempParamFile,'--format=json')
nxFile MyConfigFile {
DestinationPath = '/etc/myconfig'
Contents = $tempParamFile
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment