Skip to content

Commit 9d279d6

Browse files
authored
Update custom TinkerbellTemplateConfig to use new static IPAM logic (#10338)
The custom template in TestTinkerbellCustomTemplateRefSimpleFlow was using the deprecated STATIC_NETPLAN environment variable approach which was removed in PR #10163. That PR changed the templating logic to directly configure IPAM using netplan or NetworkManager by referencing the Hardware object's network metadata. This commit updates the custom template to: - Remove STATIC_NETPLAN environment variable - Add CONTENTS with Go template expressions that access network details directly from .Hardware.Interfaces[0].DHCP fields - Support both VLAN and non-VLAN configurations using conditional logic - Use netmaskToCIDR template function for proper CIDR notation - Maintain the custom cexec action for test validation The updated template now follows the same pattern as the default template generation in NewDefaultTinkerbellTemplateConfigCreate, specifically mirroring the withNetplanAction() function for Ubuntu OS family. Ref: #10163
1 parent 50960c9 commit 9d279d6

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

test/framework/testdata/tinkerbell/custom_config.yaml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,50 @@ spec:
1717
name: stream image to disk
1818
timeout: 600
1919
- environment:
20+
CONTENTS: |
21+
{{ if (index .Hardware.Interfaces 0).DHCP.VLANID }}network:
22+
version: 2
23+
renderer: networkd
24+
ethernets:
25+
mainif:
26+
match:
27+
macaddress: {{ (index .Hardware.Interfaces 0).DHCP.MAC }}
28+
set-name: mainif
29+
30+
vlans:
31+
vlan{{ (index .Hardware.Interfaces 0).DHCP.VLANID }}:
32+
id: {{ (index .Hardware.Interfaces 0).DHCP.VLANID }}
33+
link: mainif
34+
addresses:
35+
- {{ (index .Hardware.Interfaces 0).DHCP.IP.Address }}/{{ netmaskToCIDR (index .Hardware.Interfaces 0).DHCP.IP.Netmask }}
36+
nameservers:
37+
addresses: [{{ range $i, $ns := (index .Hardware.Interfaces 0).DHCP.NameServers }}{{if $i}}, {{end}}{{$ns}}{{end}}]
38+
{{- if (index .Hardware.Interfaces 0).DHCP.IP.Gateway }}
39+
routes:
40+
- to: default
41+
via: {{ (index .Hardware.Interfaces 0).DHCP.IP.Gateway }}
42+
{{- end }}
43+
{{ else }}network:
44+
version: 2
45+
renderer: networkd
46+
ethernets:
47+
id0:
48+
match:
49+
macaddress: {{ (index .Hardware.Interfaces 0).DHCP.MAC }}
50+
addresses:
51+
- {{ (index .Hardware.Interfaces 0).DHCP.IP.Address }}/{{ netmaskToCIDR (index .Hardware.Interfaces 0).DHCP.IP.Netmask }}
52+
nameservers:
53+
addresses: [{{ range $i, $ns := (index .Hardware.Interfaces 0).DHCP.NameServers }}{{if $i}}, {{end}}{{$ns}}{{end}}]
54+
routes:
55+
- to: default
56+
via: {{ (index .Hardware.Interfaces 0).DHCP.IP.Gateway }}
57+
{{ end }}
2058
DEST_DISK: '{{ formatPartition ( index .Hardware.Disks 0 ) 2 }}'
2159
DEST_PATH: /etc/netplan/config.yaml
2260
DIRMODE: "0755"
2361
FS_TYPE: ext4
2462
GID: "0"
2563
MODE: "0644"
26-
STATIC_NETPLAN: "true"
2764
UID: "0"
2865
image: 127.0.0.1/embedded/writefile
2966
name: write netplan config
@@ -54,11 +91,11 @@ spec:
5491
CONTENTS: |
5592
datasource:
5693
Ec2:
57-
metadata_urls: [http://__TINKERBELL_LOCAL_IP__:50061,http://__TINKERBELL_LB_IP__:50061]
94+
metadata_urls: [http://__TINKERBELL_LOCAL_IP__:50061, http://__TINKERBELL_LB_IP__:50061]
5895
strict_id: false
5996
manage_etc_hosts: localhost
6097
warnings:
61-
dsid_missing_source: off
98+
dsid_missing_source: off
6299
DEST_DISK: '{{ formatPartition ( index .Hardware.Disks 0 ) 2 }}'
63100
DEST_PATH: /etc/cloud/cloud.cfg.d/10_tinkerbell.cfg
64101
DIRMODE: "0700"
@@ -70,8 +107,7 @@ spec:
70107
name: add cloud-init config
71108
timeout: 90
72109
- environment:
73-
CONTENTS: |
74-
datasource: Ec2
110+
CONTENTS: "datasource: Ec2\n"
75111
DEST_DISK: '{{ formatPartition ( index .Hardware.Disks 0 ) 2 }}'
76112
DEST_PATH: /etc/cloud/ds-identify.cfg
77113
DIRMODE: "0700"

0 commit comments

Comments
 (0)