@@ -50,7 +50,24 @@ public-network = "{{ .Network }}"
5050{{if .SSHAuthorizedKeys}}ssh_authorized_keys:{{range .SSHAuthorizedKeys}}
5151- "{{.}}"{{end}}{{end}}
5252
53+ runcmd:
54+ - [hostname, {{HostNameLookup}}]
55+
5356write_files:
57+ - path: /etc/hostname
58+ owner: root:root
59+ permissions: 0644
60+ content: |
61+ {{ HostNameLookup }}
62+
63+ - path: /etc/hosts
64+ owner: root:root
65+ permissions: 0644
66+ content: |
67+ ::1 ipv6-localhost ipv6-loopback
68+ 127.0.0.1 localhost
69+ 127.0.0.1 {{HostNameLookup}}
70+
5471- path: /etc/kubernetes/pki/ca.crt
5572 encoding: "base64"
5673 owner: root:root
@@ -132,7 +149,24 @@ kubeadm:
132149{{if .SSHAuthorizedKeys}}ssh_authorized_keys:{{range .SSHAuthorizedKeys}}
133150- "{{.}}"{{end}}{{end}}
134151
152+ runcmd:
153+ - [hostname, {{HostNameLookup}}]
154+
135155write_files:
156+ - path: /etc/hostname
157+ owner: root:root
158+ permissions: 0644
159+ content: |
160+ {{ HostNameLookup }}
161+
162+ - path: /etc/hosts
163+ owner: root:root
164+ permissions: 0644
165+ content: |
166+ ::1 ipv6-localhost ipv6-loopback
167+ 127.0.0.1 localhost
168+ 127.0.0.1 {{HostNameLookup}}
169+
136170- path: /etc/kubernetes/pki/ca.crt
137171 encoding: "base64"
138172 owner: root:root
@@ -310,12 +344,7 @@ func NewControlPlane(input *ControlPlaneInput) (string, error) {
310344 return "" , errors .Wrapf (err , "ControlPlaneInput is invalid" )
311345 }
312346
313- fMap := map [string ]interface {}{
314- "Base64Encode" : templateBase64Encode ,
315- "Indent" : templateYAMLIndent ,
316- }
317-
318- userData , err := generateWithFuncs ("controlplane" , controlPlaneCloudInit , funcMap (fMap ), input )
347+ userData , err := generateWithFuncs ("controlplane" , controlPlaneCloudInit , defaultFuncMap (), input )
319348 if err != nil {
320349 return "" , errors .Wrapf (err , "failed to generate user data for new control plane machine" )
321350 }
@@ -331,12 +360,7 @@ func JoinControlPlane(input *ContolPlaneJoinInput) (string, error) {
331360 return "" , errors .Wrapf (err , "ControlPlaneInput is invalid" )
332361 }
333362
334- fMap := map [string ]interface {}{
335- "Base64Encode" : templateBase64Encode ,
336- "Indent" : templateYAMLIndent ,
337- }
338-
339- userData , err := generateWithFuncs ("controlplane" , controlPlaneJoinCloudInit , funcMap (fMap ), input )
363+ userData , err := generateWithFuncs ("controlplane" , controlPlaneJoinCloudInit , defaultFuncMap (), input )
340364 if err != nil {
341365 return "" , errors .Wrapf (err , "failed to generate user data for machine joining control plane" )
342366 }
0 commit comments