Documentation
¶
Overview ¶
Package bootstrap provides the main public API for VM bootstrapping.
Index ¶
- func DeleteNode(ctx context.Context, cfg *VMConfig) error
- func NodeExists(ctx context.Context, cfg *VMConfig) (bool, error)
- func UpgradeTalosNode(ctx context.Context, cfg *TalosNodeUpdateConfig) error
- type TalosNodeUpdateConfig
- type TalosProfile
- type UbuntuProfile
- type VM
- func Bootstrap(ctx context.Context, cfg *VMConfig) (*VM, error)
- func BootstrapWithLogger(ctx context.Context, cfg *VMConfig, logger *slog.Logger) (*VM, error)
- func CreateNode(ctx context.Context, cfg *VMConfig) (*VM, error)
- func CreateNodeWithLogger(ctx context.Context, cfg *VMConfig, logger *slog.Logger) (*VM, error)
- func CreateTalosNodeFromOVA(ctx context.Context, cfg *VMConfig, logger *slog.Logger) (*VM, error)
- func RecreateNode(ctx context.Context, cfg *VMConfig) (*VM, error)
- func RecreateNodeWithLogger(ctx context.Context, cfg *VMConfig, logger *slog.Logger) (*VM, error)
- type VMConfig
- func (cfg *VMConfig) EffectiveOSSchematicID() string
- func (cfg *VMConfig) EffectiveOSVersion() string
- func (cfg *VMConfig) EffectiveProfile() string
- func (cfg *VMConfig) EffectiveTalosVersion() string
- func (cfg *VMConfig) EffectiveUbuntuVersion() string
- func (cfg *VMConfig) SetDefaults()
- func (cfg *VMConfig) Validate() error
- type VMProfiles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteNode ¶ added in v0.2.0
DeleteNode deletes an existing node by cfg.Name from vCenter. It is idempotent: if the node does not exist, it returns nil.
func NodeExists ¶ added in v0.2.0
NodeExists reports whether a node with cfg.Name exists in cfg.Datacenter.
func UpgradeTalosNode ¶ added in v0.2.0
func UpgradeTalosNode(ctx context.Context, cfg *TalosNodeUpdateConfig) error
UpgradeTalosNode upgrades a Talos node using talosctl.
Types ¶
type TalosNodeUpdateConfig ¶ added in v0.2.0
type TalosNodeUpdateConfig struct {
NodeIP string
Endpoint string
Version string
Talosconfig string
TalosctlPath string
Preserve bool
Insecure bool
AdditionalArgs []string
}
TalosNodeUpdateConfig controls talosctl-based node upgrades.
type TalosProfile ¶ added in v0.2.0
TalosProfile contains Talos-specific settings for profile mode.
type UbuntuProfile ¶ added in v0.2.0
type UbuntuProfile struct {
Version string
}
UbuntuProfile contains Ubuntu-specific settings for profile mode.
type VM ¶
type VM struct {
Name string // VM name
IPAddress string // Assigned IP address
MACAddress string // Assigned MAC address (auto or static)
ManagedObject types.ManagedObjectReference // govmomi VM reference
SSHReady bool // SSH port 22 accessible
Hostname string // Configured hostname
// vCenter connection data for post-create operations (Verify/PowerOn/PowerOff/Delete).
// These fields are intentionally not serialized.
VCenterHost string `json:"-"`
VCenterPort int `json:"-"`
VCenterUser string `json:"-"`
VCenterPass string `json:"-"`
VCenterInsecure bool `json:"-"`
}
VM represents a bootstrapped virtual machine.
func Bootstrap ¶
Bootstrap creates and configures a complete VM in vCenter. Returns VM object ONLY after: - VM created in vCenter - Profile provisioning completed - Optional SSH verification completed (Ubuntu profile)
func BootstrapWithLogger ¶
BootstrapWithLogger creates and configures a VM with custom logger.
func CreateNode ¶ added in v0.2.0
CreateNode provisions a new node using the selected OS profile.
func CreateNodeWithLogger ¶ added in v0.2.0
CreateNodeWithLogger provisions a new node with a custom logger.
func CreateTalosNodeFromOVA ¶ added in v0.2.0
CreateTalosNodeFromOVA deploys a Talos VMware OVA and powers the VM on.
func RecreateNode ¶ added in v0.2.0
RecreateNode deletes the existing node (if present) and creates it again.
func RecreateNodeWithLogger ¶ added in v0.2.0
RecreateNodeWithLogger deletes the existing node (if present) and creates it again.
type VMConfig ¶
type VMConfig struct {
// === vCenter Connection ===
VCenterHost string // vCenter hostname or IP (e.g., "vcenter.example.com")
VCenterUsername string // vCenter username (e.g., "[email protected]")
VCenterPassword string // vCenter password (encrypted/plain - user's responsibility)
VCenterPort int // vCenter port (default: 443)
VCenterInsecure bool // Skip TLS verification (not recommended for production)
// === VM Specifications ===
Name string // VM name (e.g., "web-server-01")
CPUs int // Number of CPUs (e.g., 4)
MemoryMB int // Memory in MB (e.g., 8192)
DiskSizeGB int // OS disk size in GB (e.g., 40)
DataDiskSizeGB *int // Optional data disk size in GB (e.g., 500) - nil = not created
DataDiskMountPath string // Mount point for data disk (e.g., "/data") - required if DataDiskSizeGB set
// === Network Configuration ===
NetworkName string // Network name (e.g., "LAN_Management")
NetworkInterface string // Guest NIC name (e.g., "ens192")
MACAddress string // Optional static MAC address (e.g., "00:50:56:aa:bb:cc")
IPAddress string // Static IP address (e.g., "192.168.1.10")
Netmask string // Network mask (e.g., "255.255.255.0")
Gateway string // Default gateway (e.g., "192.168.1.1")
DNS []string // DNS servers (e.g., ["8.8.8.8", "8.8.4.4"])
// === VM Placement ===
Datacenter string // Datacenter name (e.g., "DC1")
Folder string // VM folder path (e.g., "Production/WebServers")
ResourcePool string // Resource pool path (e.g., "WebTier")
Datastore string // VM datastore name (e.g., "VMwareSSD01")
ISODatastore string // Datastore for ISO uploads (e.g., "VMwareStorage01"); falls back to Datastore if empty
// vCenter Content Library used for Talos OVA cache/deploy.
// Name is used when ID is empty; ID is preferred when both are set.
ContentLibrary string
ContentLibraryID string
// === OS & User Configuration ===
// OS profile used for VM provisioning (default: "ubuntu").
Profile string
// Profile-specific options.
Profiles VMProfiles
Username string // SSH user to create (e.g., "sysadmin")
SSHPublicKeys []string // SSH public keys (one or more)
Password string // Optional plain text password (auto-hashed with bcrypt before use)
PasswordHash string // Optional pre-computed password hash (bcrypt); overrides Password if both set
// Allow SSH password authentication (default: false). Requires Password or PasswordHash.
AllowPasswordSSH bool
// Skip SSH verification during bootstrap (default: false).
SkipSSHVerify bool
// Keep VM/ISO on bootstrap failure for debugging (default: false).
SkipCleanupOnError bool
// === Advanced Options ===
Timezone string // System timezone (default: "UTC")
Locale string // System locale (default: "en_US.UTF-8")
SwapSizeGB *int // Swap size in GB (default from configs/defaults.yaml)
Firmware string // Firmware type: "bios" or "efi" (default: "bios")
}
VMConfig defines the complete configuration for VM bootstrap.
func (*VMConfig) EffectiveOSSchematicID ¶ added in v0.2.0
EffectiveOSSchematicID returns schematic/build identifier for selected OS profile.
func (*VMConfig) EffectiveOSVersion ¶ added in v0.2.0
EffectiveOSVersion returns OS version for the selected profile.
func (*VMConfig) EffectiveProfile ¶ added in v0.2.0
EffectiveProfile returns normalized profile name.
func (*VMConfig) EffectiveTalosVersion ¶ added in v0.2.0
EffectiveTalosVersion returns Talos version from profile config.
func (*VMConfig) EffectiveUbuntuVersion ¶ added in v0.2.0
EffectiveUbuntuVersion returns Ubuntu version from profile config.
func (*VMConfig) SetDefaults ¶
func (cfg *VMConfig) SetDefaults()
SetDefaults sets default values for optional fields from configs/defaults.yaml.
type VMProfiles ¶ added in v0.2.0
type VMProfiles struct {
Ubuntu UbuntuProfile
Talos TalosProfile
}
VMProfiles contains profile-specific settings.