-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
package main
import (
"fmt"
"github.com/crc-org/macadam/pkg/machine"
"github.com/crc-org/macadam/pkg/vmconfigs"
"github.com/machinefile/machinefile/executor"
)
func main() {
// Create/init and start VM
vmName := "fedora-output"
baseImage := "fedora-cloud.qcow2"
macadamVM, err := machine.InitVM(vmName, baseImage, /*...options*/)
if err != nil {
panic(err)
}
err = macadamVM.Start()
if err != nil {
panic(err)
}
// Extract SSH config
sshConfig := macadamVM.SSH // type: vmconfigs.SSHConfig
// Use machinefile executor
mf := executor.New(machinefilePath)
err = mf.RunOverSSH(sshConfig.RemoteUsername, "localhost", sshConfig.Port, sshConfig.IdentityPath)
if err != nil {
panic(err)
}
fmt.Println("VM built and provisioned successfully!")
}