multifile templates for network configs

This commit is contained in:
Christian Goll
2022-03-16 21:12:00 +01:00
parent e18e98e743
commit 2967148084
3 changed files with 36 additions and 12 deletions

View File

@@ -1,9 +0,0 @@
DEVICE={{$.NetDevs.default.Device}}
NAME=default
BOOTPROTO=static
DEVTIMEOUT=10
IPADDR={{$.NetDevs.default.Ipaddr}}
NETMASK={{$.NetDevs.default.Netmask}}
GATEWAY={{$.NetDevs.default.Gateway}}
HWADDR={{$.NetDevs.default.Hwaddr}}
ONBOOT=yes

View File

@@ -0,0 +1,20 @@
{{- $host := .BuildHost }}
{{- $time := .BuildTime }}
{{- $source := .BuildSource }}
{{range $devname, $netdev := .NetDevs -}}
{{- $filename := print "ifcfg-" $devname ".conf" }}
{{- file $filename }}
# This file is autogenerated by warewulf
# Host: {{ $host }}
# Time: {{ $time }}
# Source: {{ $source }}
DEVICE={{ $netdev.Device }}
NAME=default
BOOTPROTO=static
DEVTIMEOUT=10
IPADDR={{ $netdev.Ipaddr }}
NETMASK={{ $netdev.Netmask }}
GATEWAY={{ $netdev.Gateway }}
HWADDR={{ $netdev.Hwaddr }}
ONBOOT=yes
{{- end}} {{/* end for each network device */

View File

@@ -1,5 +1,17 @@
{{- $host := .BuildHost }}
{{- $time := .BuildTime }}
{{- $source := .BuildSource }}
{{range $devname, $netdev := .NetDevs -}}
{{- $filename := print "ifcfg-" $devname ".xml" }}
{{- file $filename }}
<!--
This file is autogenerated by warewulf
Host: {{ $host }}
Time: {{ $time }}
Source: {{ $source }}
-->
<interface origin="static generated warewulf config">
<name>{{.NetDevs.default.Device}}</name>
<name>{{$netdev.Device}}</name>
<control>
<mode>boot</mode>
</control>
@@ -11,11 +23,11 @@
</ipv4>
<ipv4:static>
<address>
<local>{{$.NetDevs.default.IpCIDR}}</local>
<local>{{$netdev.IpCIDR}}</local>
</address>
<route>
<nexthop>
<gateway>{{$.NetDevs.default.Gateway}}</gateway>
<gateway>{{$netdev.Gateway}}</gateway>
</nexthop>
</route>
</ipv4:static>
@@ -25,3 +37,4 @@
<accept-redirects>false</accept-redirects>
</ipv6>
</interface>
{{- end }}