@@ -28,7 +28,24 @@ const (
2828{{if .SSHAuthorizedKeys}}ssh_authorized_keys:{{range .SSHAuthorizedKeys}}
2929- "{{.}}"{{end}}{{end}}
3030
31+ runcmd:
32+ - [hostname, {{HostNameLookup}}]
33+
3134write_files:
35+ - path: /etc/hostname
36+ owner: root:root
37+ permissions: 0644
38+ content: |
39+ {{ HostNameLookup }}
40+
41+ - path: /etc/hosts
42+ owner: root:root
43+ permissions: 0644
44+ content: |
45+ ::1 ipv6-localhost ipv6-loopback
46+ 127.0.0.1 localhost
47+ 127.0.0.1 {{HostNameLookup}}
48+
3249- path: /etc/kubernetes/pki/ca.crt
3350 encoding: "base64"
3451 owner: root:root
@@ -110,7 +127,24 @@ kubeadm:
110127{{if .SSHAuthorizedKeys}}ssh_authorized_keys:{{range .SSHAuthorizedKeys}}
111128- "{{.}}"{{end}}{{end}}
112129
130+ runcmd:
131+ - [hostname, {{HostNameLookup}}]
132+
113133write_files:
134+ - path: /etc/hostname
135+ owner: root:root
136+ permissions: 0644
137+ content: |
138+ {{ HostNameLookup }}
139+
140+ - path: /etc/hosts
141+ owner: root:root
142+ permissions: 0644
143+ content: |
144+ ::1 ipv6-localhost ipv6-loopback
145+ 127.0.0.1 localhost
146+ 127.0.0.1 {{HostNameLookup}}
147+
114148- path: /etc/kubernetes/pki/ca.crt
115149 encoding: "base64"
116150 owner: root:root
@@ -275,12 +309,7 @@ func NewControlPlane(input *ControlPlaneInput) (string, error) {
275309 return "" , errors .Wrapf (err , "ControlPlaneInput is invalid" )
276310 }
277311
278- fMap := map [string ]interface {}{
279- "Base64Encode" : templateBase64Encode ,
280- "Indent" : templateYAMLIndent ,
281- }
282-
283- userData , err := generateWithFuncs ("controlplane" , controlPlaneCloudInit , funcMap (fMap ), input )
312+ userData , err := generateWithFuncs ("controlplane" , controlPlaneCloudInit , defaultFuncMap (), input )
284313 if err != nil {
285314 return "" , errors .Wrapf (err , "failed to generate user data for new control plane machine" )
286315 }
@@ -296,12 +325,7 @@ func JoinControlPlane(input *ContolPlaneJoinInput) (string, error) {
296325 return "" , errors .Wrapf (err , "ControlPlaneInput is invalid" )
297326 }
298327
299- fMap := map [string ]interface {}{
300- "Base64Encode" : templateBase64Encode ,
301- "Indent" : templateYAMLIndent ,
302- }
303-
304- userData , err := generateWithFuncs ("controlplane" , controlPlaneJoinCloudInit , funcMap (fMap ), input )
328+ userData , err := generateWithFuncs ("controlplane" , controlPlaneJoinCloudInit , defaultFuncMap (), input )
305329 if err != nil {
306330 return "" , errors .Wrapf (err , "failed to generate user data for machine joining control plane" )
307331 }
0 commit comments