Answers: <p>Perhaps a macro might be what you are looking for.</p>
  
  <p><a href="https://docs.saltstack.com/en/latest/topics/jinja/index.html#macros" rel="nofollow noreferrer">Understanding Jinja:Macros</a></p>
  
  <p>In the lib.sls example in the link (pasted below), it sets a value contingent on the value of the if statement.  I think a similar approach could work for you.</p>
  
  <pre><code>{% macro pythonpkg(pkg) -%}
    {%- if grains['os'] == 'FreeBSD' -%}
      py27-{{ pkg }}
    {%- elif grains['os'] == 'Debian' -%}
      python-{{ pkg }}
    {%- endif -%}
  {%- endmacro %}
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2019-01-02T21:03:05.813Z
Answers: 2019-01-02T21:03:05.813Z
Answers: darnold0714
Body: <p>I have a config.jinja file with below jvm options:</p>
  
  <pre><code>`-Dappdynamics.agent.appName=AP_{{ pillar['region'] }}`
  </code></pre>
  
  <p>However the AP_{{ pillar['region'] }} varies for different environments. For Dev/Prod it can be AP_{{ pillar['region'] }} and for QA it must be AP without the pillar value.
  How can I define the appName option with multiple values to achieve above? Any suggestions?</p>
  
  <pre><code>if (pillar['region'] == QA)
     -Dappdynamics.agent.applicationName=ALIP
  else
     -Dappdynamics.agent.applicationName=ALIP_{{ pillar['region'] }}
  end-if
  </code></pre>
  
Tags: <salt><jinja>
Title: How to add multiple jvm options in a saltstack jinja?
UserDisplayName: Narasimha
ThreadText: # How to add multiple jvm options in a saltstack jinja?
  
  (Asked by: username_0 on 2019-01-02)
  
  I have a config.jinja file with below jvm options:
  
  ```
  `-Dappdynamics.agent.appName=AP_{{ pillar['region'] }}`
  
  ```
  
  However the AP\_{{ pillar['region'] }} varies for different environments. For Dev/Prod it can be AP\_{{ pillar['region'] }} and for QA it must be AP without the pillar value.
  How can I define the appName option with multiple values to achieve above? Any suggestions?
  
  ```
  if (pillar['region'] == QA)
     -Dappdynamics.agent.applicationName=ALIP
  else
     -Dappdynamics.agent.applicationName=ALIP_{{ pillar['region'] }}
  end-if
  
  ```
  
  **Tags:** salt, jinja
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-01-02. Score: 1
  
  Perhaps a macro might be what you are looking for.
  
  [Understanding Jinja:Macros](https://docs.saltstack.com/en/latest/topics/jinja/index.html#macros)
  
  In the lib.sls example in the link (pasted below), it sets a value contingent on the value of the if statement. I think a similar approach could work for you.
  
  ```
  {% macro pythonpkg(pkg) -%}
    {%- if grains['os'] == 'FreeBSD' -%}
      py27-{{ pkg }}
    {%- elif grains['os'] == 'Debian' -%}
      python-{{ pkg }}
    {%- endif -%}
  {%- endmacro %}
  
  ```
  
  
  ---
  
  