Commit e7cabb2c authored by Pietsch, Martin's avatar Pietsch, Martin

added macros for static and dynamic network settings

parent 633f9f79
{% macro staticconf(ipvers, ifname, ip, prefix) %}
{% if ipvers == 4 %}
{{ 'ifconfig_%s="%s netmask %s"' | format(ifname, ip, '%s/%s' | format(ip, prefix) | ipaddr('netmask')) }}
{% else %}
{{ 'ifconfig_%s_ipv6="%s prefixlen %s"' | format(ifname, ip, prefix) }}
{% endif %}
{% endmacro %}
{% macro dynconf(ipvers, ifname) %}
{% if ipvers == 4 %}
{{ 'ifconfig_%s="SYNCDHCP"' | format(ifname) }}
{% else %}
{{ 'ifconfig_%s_ipv6="SYNCDHCP"' | format(ifname) }}
{% endif %}
{% endmacro %}
{% set hostobj = hostvars[hostname] %}
BSDINSTALL_DISTDIR=/tmp
BSDINSTALL_DISTSITE={{ '%s/%s/%s-RELEASE' | format(freebsd_install_local | default(freebsd_install_home_mirror), hostobj.os.architecture, hostobj.os.release) }}
......@@ -36,31 +52,31 @@ HOST="{{ hostobj.network.hostname | default(hostname) }}"
{% if ifdata.ipv4 is defined %}
{% if hostobj.network.classes[ifdata.class].dhcp is defined %}
{% if hostobj.network.classes[ifdata.class].dhcp.ipv4 is defined %}
{% if (ifdata.ipv4 | ip_in_range('%s-%s' | format(hostobj.network.classes[ifdata.class].dhcp.ipv4.from, hostobj.network.classes[ifdata.class].dhcp.ipv4.to))) == true %}
{{ 'ifconfig_%s="SYNCDHCP"' | format(ifname) }}
{% if (ifdata.ipv4 | default(False) | ip_in_range('%s-%s' | format(hostobj.network.classes[ifdata.class].dhcp.ipv4.from, hostobj.network.classes[ifdata.class].dhcp.ipv4.to))) == true and (ifdata.static | default(False)) == False %}
{{ dynconf(4, ifname) }}
{% else %}
{{ 'ifconfig_%s="%s netmask %s"' | format(ifname, ifdata.ipv4, '%s/%s' | format(ifdata.ipv4, hostobj.network.classes[ifdata.class].ipv4.prefix) | ipaddr('netmask')) }}
{{ staticconf(4, ifname, ifdata.ipv4, hostobj.network.classes[ifdata.class].ipv4.prefix) }}
{% endif %}
{% else %}
{{ 'ifconfig_%s="%s netmask %s"' | format(ifname, ifdata.ipv4, '%s/%s' | format(ifdata.ipv4, hostobj.network.classes[ifdata.class].ipv4.prefix) | ipaddr('netmask')) }}
{{ staticconf(4, ifname, ifdata.ipv4, hostobj.network.classes[ifdata.class].ipv4.prefix) }}
{% endif %}
{% else %}
{{ 'ifconfig_%s="%s netmask %s"' | format(ifname, ifdata.ipv4, '%s/%s' | format(ifdata.ipv4, hostobj.network.classes[ifdata.class].ipv4.prefix) | ipaddr('netmask')) }}
{{ staticconf(4, ifname, ifdata.ipv4, hostobj.network.classes[ifdata.class].ipv4.prefix) }}
{% endif %}
{% endif %}
{% if ifdata.ipv6 is defined %}
{% if hostobj.network.classes[ifdata.class].dhcp is defined %}
{% if hostobj.network.classes[ifdata.class].dhcp.ipv6 is defined %}
{% if (ifdata.ipv6 | ip_in_range('%s-%s' | format(hostobj.network.classes[ifdata.class].dhcp.ipv6.from, hostobj.network.classes[ifdata.class].dhcp.ipv6.to))) == true %}
{{ 'ifconfig_%s_ipv6="SYNCDHCP"' | format(ifname) }}
{% if (ifdata.ipv6 | default(False) | ip_in_range('%s-%s' | format(hostobj.network.classes[ifdata.class].dhcp.ipv6.from, hostobj.network.classes[ifdata.class].dhcp.ipv6.to))) == true and (ifdata.static | default(False)) == False %}
{{ dynconf(6, ifname) }}
{% else %}
{{ 'ifconfig_%s_ipv6="%s prefixlen %s"' | format(ifname, ifdata.ipv6, hostobj.network.classes[ifdata.class].ipv6.prefix) }}
{{ staticconf(6, ifname, ifdata.ipv6, hostobj.network.classes[ifdata.class].ipv6.prefix) }}
{% endif %}
{% else %}
{{ 'ifconfig_%s_ipv6="%s prefixlen %s"' | format(ifname, ifdata.ipv6, hostobj.network.classes[ifdata.class].ipv6.prefix) }}
{{ staticconf(6, ifname, ifdata.ipv6, hostobj.network.classes[ifdata.class].ipv6.prefix) }}
{% endif %}
{% else %}
{{ 'ifconfig_%s_ipv6="%s prefixlen %s"' | format(ifname, ifdata.ipv6, hostobj.network.classes[ifdata.class].ipv6.prefix) }}
{{ staticconf(6, ifname, ifdata.ipv6, hostobj.network.classes[ifdata.class].ipv6.prefix) }}
{% endif %}
{% endif %}
{% endfor %}
......@@ -77,10 +93,10 @@ HOST="{{ hostobj.network.hostname | default(hostname) }}"
{% endif %}
{% if ncdata.dns is defined %}
{% if ncdata.dns.nameservers.ipv4 is defined %}
{% do dnsns.append(ncdata.dns.nameservers.ipv4) %}
{% do dnsns.extend(ncdata.dns.nameservers.ipv4) %}
{% endif %}
{% if ncdata.dns.nameservers.ipv6 is defined %}
{% do dnsns.append(ncdata.dns.nameservers.ipv6) %}
{% do dnsns.extend(ncdata.dns.nameservers.ipv6) %}
{% endif %}
{% if ncdata.dns.domain is defined %}
{% do dnsdom.append(ncdata.dns.domain) %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment