Conditioning

Learn how to use Conditioning in SecuRA.

SecuRA supports condition-based Templating using “if”, “if else” and “if elif else” conditional statements:

  1. "If" Condition
  2.   {% if Runtime.interface_name == "GigabitEthernet0/0" %}
                                IP address 192.168.1.1 255.0.0.0
                                no shutdown
                            {% endif %}
                    
  3. "If else" Condition
  4.   
                      {% if Runtime.interface_name == "GigabitEthernet0/0" %}
                          IP address 192.168.1.1 255.0.0.0
                          no shutdown
                      {% else %}
                          IP address 192.168.2.1 255.0.0.0
                          no shutdown
                      {% endif %}
                    
  5. "If elif else" Condition
  6.   
                       {% if Runtime.interface_name == "GigabitEthernet0/0" %}
                            IP address 192.168.1.1 255.0.0.0
                            no shutdown
                      {% elif Runtime.interface_name == "GigabitEthernet0/1" %}
                            IP address 192.168.1.1 255.0.0.0
                            no shutdown
                      {% else %}
                            IP address 192.168.2.1 255.0.0.0
                            no shutdown
                      {% endif %}
    
                    

See how to use Looping in SecuRA

Substitution, Conditioning, Looping in Template should be in Jinja2 standard. Refer http://jinja.pocoo.org/docs/2.10/ for more tutorials.
Points to Remember:

Always enclose the commands within {% %} for "if" and "for", "while" conditional statements.

Always enclose the variables inside {{ }} for substitution.