1 {{- define "machine.networkData" -}}
2 {{- if .networkData -}}
5 {{- $local := dict "first" true -}}
6 {{- range $name, $link := .networkData.links.ethernets }}
7 {{- if not $local.first }}
12 {{- $_ := set $local "first" false }}
13 "id": "{{ $name }}_nic",
14 "ethernet_mac_address": "{{ $link.macAddress }}",
20 {{- $local := dict "first" true -}}
21 {{- range $name, $network := .networkData.networks.ipv4DHCP }}
22 {{- if not $local.first }}
27 {{- $_ := set $local "first" false }}
29 "link": "{{ $network.link | default $name }}_nic",
32 {{- range $name, $network := .networkData.networks.ipv4 }}
35 "link": "{{ $network.link | default $name }}_nic",
36 "type": "ipv4"{{- if $network.ipAddress }},
37 "ip_address": "{{ $network.ipAddress }}"{{- end }}{{- if $network.gateway }},
38 "gateway": "{{ $network.gateway }}"{{- end }}
40 {{- range $name, $network := .networkData.networks.ipv6DHCP }}
43 "link": "{{ $network.link | default $name }}_nic",
46 {{- range $name, $network := .networkData.networks.ipv6 }}
49 "link": "{{ $network.link | default $name }}_nic",
50 "type": "ipv6"{{- if $network.ipAddress }},
51 "ip_address": "{{ $network.ipAddress }}"{{- end }}{{- if $network.gateway }},
52 "gateway": "{{ $network.gateway }}"{{- end }}
57 {{- $local := dict "first" true -}}
58 {{- range $address := .networkData.services.dns }}
59 {{- if not $local.first }}
64 {{- $_ := set $local "first" false }}
66 "address": "{{ $address }}"