-
Notifications
You must be signed in to change notification settings - Fork 273
/
tinkerbelltemplateconfig_defaults.go
130 lines (122 loc) Β· 3.1 KB
/
tinkerbelltemplateconfig_defaults.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package v1alpha1
import (
"github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell"
"github.com/aws/eks-anywhere/release/api/v1alpha1"
)
const (
netplan = `network:
version: 2
renderer: networkd
ethernets:
eno1:
dhcp4: true
`
cloudInit = `datasource:
Ec2:
metadata_urls: []
strict_id: false
system_info:
default_user:
name: tink
groups: [wheel, adm]
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
shell: /bin/bash
manage_etc_hosts: localhost
warnings:
dsid_missing_source: off
`
)
func GetDefaultActionsFromBundle(b v1alpha1.VersionsBundle) []ActionOpt {
return []ActionOpt{
withStreamImageAction(b),
withNetplanAction(b),
withTinkCloudInitAction(b),
withDsCloudInitAction(b),
withKexecAction(b),
}
}
func withStreamImageAction(b v1alpha1.VersionsBundle) ActionOpt {
return func(a *[]tinkerbell.Action) {
*a = append(*a, tinkerbell.Action{
Name: "stream-image",
Image: b.Tinkerbell.TinkerbellStack.Actions.ImageToDisk.URI,
Timeout: 360,
Environment: map[string]string{
"IMG_URL": b.EksD.Raw.Ubuntu.URI,
"DEST_DISK": "/dev/sda",
"COMPRESSED": "true",
},
})
}
}
func withNetplanAction(b v1alpha1.VersionsBundle) ActionOpt {
return func(a *[]tinkerbell.Action) {
*a = append(*a, tinkerbell.Action{
Name: "write-netplan",
Image: b.Tinkerbell.TinkerbellStack.Actions.WriteFile.URI,
Timeout: 90,
Environment: map[string]string{
"DEST_DISK": "/dev/sda2",
"FS_TYPE": "ext4",
"DEST_PATH": "/etc/netplan/config.yaml",
"CONTENTS": netplan,
"UID": "0",
"GID": "0",
"MODE": "0644",
"DIRMODE": "0755",
},
})
}
}
func withTinkCloudInitAction(b v1alpha1.VersionsBundle) ActionOpt {
return func(a *[]tinkerbell.Action) {
*a = append(*a, tinkerbell.Action{
Name: "add-tink-cloud-init-config",
Image: b.Tinkerbell.TinkerbellStack.Actions.WriteFile.URI,
Timeout: 90,
Environment: map[string]string{
"DEST_DISK": "/dev/sda2",
"FS_TYPE": "ext4",
"DEST_PATH": "/etc/cloud/cloud.cfg.d/10_tinkerbell.cfg",
"CONTENTS": cloudInit,
"UID": "0",
"GID": "0",
"MODE": "0600",
"DIRMODE": "0700",
},
})
}
}
func withDsCloudInitAction(b v1alpha1.VersionsBundle) ActionOpt {
return func(a *[]tinkerbell.Action) {
*a = append(*a, tinkerbell.Action{
Name: "add-tink-cloud-init-ds-config",
Image: b.Tinkerbell.TinkerbellStack.Actions.WriteFile.URI,
Timeout: 90,
Environment: map[string]string{
"DEST_DISK": "/dev/sda2",
"FS_TYPE": "ext4",
"DEST_PATH": "/etc/cloud/ds-identify.cfg",
"CONTENTS": "datasource: Ec2\n",
"UID": "0",
"GID": "0",
"MODE": "0600",
"DIRMODE": "0700",
},
})
}
}
func withKexecAction(b v1alpha1.VersionsBundle) ActionOpt {
return func(a *[]tinkerbell.Action) {
*a = append(*a, tinkerbell.Action{
Name: "kexec-image",
Image: b.Tinkerbell.TinkerbellStack.Actions.Kexec.URI,
Timeout: 90,
Pid: "host",
Environment: map[string]string{
"BLOCK_DEVICE": "/dev/sda2",
"FS_TYPE": "ext4",
},
})
}
}