mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-27 01:21:11 +02:00
feat(initramfs): set the platform explicitly (#124)
This commit is contained in:
parent
b48884b037
commit
ca93edeb4a
@ -108,7 +108,7 @@ DEFAULT Dianemo
|
|||||||
LABEL Dianemo
|
LABEL Dianemo
|
||||||
KERNEL /boot/vmlinuz
|
KERNEL /boot/vmlinuz
|
||||||
INITRD /boot/initramfs.xz
|
INITRD /boot/initramfs.xz
|
||||||
APPEND ip=dhcp consoleblank=0 console=tty0 console=ttyS0,9600 dianemo.autonomy.io/root=${DIANEMO_ROOT} dianemo.autonomy.io/userdata=${DIANEMO_USERDATA}
|
APPEND ip=dhcp consoleblank=0 console=tty0 console=ttyS0,9600 dianemo.autonomy.io/root=${DIANEMO_ROOT} dianemo.autonomy.io/userdata=${DIANEMO_USERDATA} dianemo.autonomy.io/platform=${DIANEMO_PLATFORM}
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +122,7 @@ function cleanup {
|
|||||||
|
|
||||||
DIANEMO_ROOT="sda"
|
DIANEMO_ROOT="sda"
|
||||||
DIANEMO_USERDATA=""
|
DIANEMO_USERDATA=""
|
||||||
|
DIANEMO_PLATFORM="bare-metal"
|
||||||
RAW_IMAGE="/out/image.raw"
|
RAW_IMAGE="/out/image.raw"
|
||||||
VMDK_IMAGE="/out/image.vmdk"
|
VMDK_IMAGE="/out/image.vmdk"
|
||||||
ISO_IMAGE="/out/image.iso"
|
ISO_IMAGE="/out/image.iso"
|
||||||
@ -131,7 +132,7 @@ RAW=false
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
image)
|
image)
|
||||||
shift
|
shift
|
||||||
while getopts "b:flt:u:" opt; do
|
while getopts "b:flt:p:u:" opt; do
|
||||||
case ${opt} in
|
case ${opt} in
|
||||||
b )
|
b )
|
||||||
DEVICE=${OPTARG}
|
DEVICE=${OPTARG}
|
||||||
@ -148,6 +149,10 @@ case "$1" in
|
|||||||
RAW=true
|
RAW=true
|
||||||
echo "Using loop device ${RAW_IMAGE} as installation media"
|
echo "Using loop device ${RAW_IMAGE} as installation media"
|
||||||
;;
|
;;
|
||||||
|
p )
|
||||||
|
DIANEMO_PLATFORM=${OPTARG}
|
||||||
|
echo "Using kernel parameter dianemo.autonomy.io/platform=${DIANEMO_PLATFORM}"
|
||||||
|
;;
|
||||||
t )
|
t )
|
||||||
DIANEMO_ROOT=${OPTARG}
|
DIANEMO_ROOT=${OPTARG}
|
||||||
echo "Using kernel parameter dianemo.autonomy.io/root=${DIANEMO_ROOT}"
|
echo "Using kernel parameter dianemo.autonomy.io/root=${DIANEMO_ROOT}"
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
"sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable\"",
|
"sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable\"",
|
||||||
"sudo apt-get -y update",
|
"sudo apt-get -y update",
|
||||||
"sudo apt-get -y install docker-ce",
|
"sudo apt-get -y install docker-ce",
|
||||||
"sudo docker run --privileged --volume /dev:/dev autonomy/dianemo:{{ user `version` }} image -b /dev/xvdf -t /dev/xvda -f -u none"
|
"sudo docker run --privileged --volume /dev:/dev autonomy/dianemo:{{ user `version` }} image -b /dev/xvdf -t /dev/xvda -f -p aws -u none"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -9,6 +9,10 @@ const (
|
|||||||
// to the user data.
|
// to the user data.
|
||||||
KernelParamUserData = "dianemo.autonomy.io/userdata"
|
KernelParamUserData = "dianemo.autonomy.io/userdata"
|
||||||
|
|
||||||
|
// KernelParamPlatform is the kernel parameter name for specifying the
|
||||||
|
// platform.
|
||||||
|
KernelParamPlatform = "dianemo.autonomy.io/platform"
|
||||||
|
|
||||||
// NewRoot is the path where the switchroot target is mounted.
|
// NewRoot is the path where the switchroot target is mounted.
|
||||||
NewRoot = "/root"
|
NewRoot = "/root"
|
||||||
|
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
package platform
|
package platform
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/autonomy/dianemo/src/initramfs/cmd/init/pkg/constants"
|
||||||
|
"github.com/autonomy/dianemo/src/initramfs/cmd/init/pkg/kernel"
|
||||||
"github.com/autonomy/dianemo/src/initramfs/cmd/init/pkg/platform/baremetal"
|
"github.com/autonomy/dianemo/src/initramfs/cmd/init/pkg/platform/baremetal"
|
||||||
"github.com/autonomy/dianemo/src/initramfs/cmd/init/pkg/platform/cloud/aws"
|
"github.com/autonomy/dianemo/src/initramfs/cmd/init/pkg/platform/cloud/aws"
|
||||||
"github.com/autonomy/dianemo/src/initramfs/pkg/userdata"
|
"github.com/autonomy/dianemo/src/initramfs/pkg/userdata"
|
||||||
@ -17,11 +21,23 @@ type Platform interface {
|
|||||||
|
|
||||||
// NewPlatform is a helper func for discovering the current platform.
|
// NewPlatform is a helper func for discovering the current platform.
|
||||||
func NewPlatform() (p Platform, err error) {
|
func NewPlatform() (p Platform, err error) {
|
||||||
if aws.IsEC2() {
|
arguments, err := kernel.ParseProcCmdline()
|
||||||
p = &aws.AWS{}
|
if err != nil {
|
||||||
} else {
|
return
|
||||||
p = &baremetal.BareMetal{}
|
}
|
||||||
|
if platform, ok := arguments[constants.KernelParamPlatform]; ok {
|
||||||
|
switch platform {
|
||||||
|
case "aws":
|
||||||
|
if aws.IsEC2() {
|
||||||
|
p = &aws.AWS{}
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("failed to verify EC2 PKCS7 signature")
|
||||||
|
}
|
||||||
|
case "bare-metal":
|
||||||
|
p = &baremetal.BareMetal{}
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("no platform specified")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user