ansible/roles/network/templates/ifcfg-eth.j2

35 lines
986 B
Django/Jinja

DEVICE="{{ item.device }}"
{% for line in interface_uuid.stdout_lines %}
{% if line.split()[0] == item.device %}
UUID="{{ line.split()[1] }}"
{% elif line.split()[2] == item.device %}
UUID="{{ line.split()[1] }}"
{% endif %}
{% endfor %}
{% if item.mac is defined %}
HWADDR="{{ item.mac }}"
{% elif lookup('vars', 'ansible_' + item.device, default=undefined) is undefined %}
HWADDR="{{ lookup('vars', 'ansible_' + item.device + '["macaddress"]') }}
{% endif %}
ONBOOT=yes
{% if item.proto is not defined or item.proto == 'dhcp' %}
NETBOOT=yes
BOOTPROTO=dhcp
{% elif item.proto == 'static' %}
IPADDR="{{ item.ipaddr }}"
NETMASK="{{ item.netmask }}"
{% if item.gateway is defined %}
GATEWAY="{{ item.gateway }}"
{% endif %}
{% elif proto == 'none' %}
BOOTPROTO=none
{% endif %}
{% if item.ip6addr is defined and item.ip6addr != 'none' %}
IPV6INIT=yes
{% if item.ip6addr != 'auto' %}
IPV6ADDR="{{ item.ip6addr }}"
{% endif %}
{% else %}
IPV6INIT=no
{% endif %}
TYPE=Ethernet