Project

General

Profile

Actions

Bug #18906

closed

Add advanced jinja2 template example for main IP address

Added by Alexis Mousset about 3 years ago. Updated about 3 years ago.

Status:
Released
Priority:
N/A
Category:
Documentation
Target version:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
0
Name check:
To do
Fix check:
Checked
Regression:

Description

Add an example of template logic to chose an IP by interface name priority.

{%- if   'bond0' in vars.sys.interfaces %}
    # 'bond0' in vars.sys.interfaces
    {%- set my_ip = vars.sys['ipv4[bond0]'] %}
{%- elif 'eth0' in vars.sys.interfaces %}
    # Found eth0 as default interface
    {%- set my_ip = vars.sys['ipv4[eth0]'] %}
{%- else %}
    # Not found bond0 or eth0, using default sys.ipv4
    {%- set my_ip = vars.sys.ipv4 %}
{%- endif %}
Actions

Also available in: Atom PDF