Support Questions
Find answers, ask questions, and share your expertise

Ambari Blueprint - Dynamic Evaluation

Ambari Blueprint - Dynamic Evaluation

New Contributor


let me describe my case and what I am trying to achieve. I will demonstrate it on a simple example.


I need to modify log4j configuration of my Kafka instance deployed via Ambari blueprint. Originally my blueprint did not contain the "kafka-log4j" specification. The Advanced kafka-log4j section of Kafka service configuration tab looked like the screenshot below, note the 4 text boxes and the expressions with curly braces in kafka-log4j template content:


2019-10-25 11_46_12-Ambari - dev-cluster.png

If I understand it correctly the key inside the curly braces will be dynamically replaced by the number corresponding to that key present in one of the text boxes above.


My case is that I need to modify the contents of the file and therefore I have added this section to my Ambari blueprint:


"kafka-log4j" : {
"properties" : {
"content" : "\n#\n#\n# Licensed to the Apache Software Foundation (ASF) ..."

I wanted to preserve the curly braces construct shown above so I tried to escape the curly braces in the content to make sure the key will not get evaluated upon blueprint upload to Ambari via its REST API. I tried to follow jinja2 documentation: but to no avail.


The string is always evaluated as an expression and the blueprint upload always requires presence of the variable/key in my values yaml file.


I have tried following escaping approaches yet without any success:

log4j.appender.kafkaAppender.MaxFileSize = {{ '{{' }} kafka_log_maxfilesize {{ '}}' }}MB

log4j.appender.kafkaAppender.MaxFileSize = {% raw %} {{ kafka_log_maxfilesize }} {% endraw %}MB


When I supply values for these variables in yaml file then my blueprint is successfully uploaded via Ambari REST, but the text boxes in Ambari UI do not have an effect on the content of the file any more. The kafka-log4j template contains values instead of curly braces expressions:

2019-10-25 11_40_54-Ambari - feature-fi....png


So here is my question: how can I escape the {{ }} in Ambari blueprint so that the template still contains the variable {{ key }} expressions and the functionality of Ambari UI is preserved?



Jan Pridal