cloudinit

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cloudinit provides utilities for generating cloud-init configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateMetadata

func GenerateMetadata(hostname string) []byte

GenerateMetadata generates cloud-init metadata YAML content for the given hostname.

func MarshalToYAML

func MarshalToYAML(config *Config) ([]byte, error)

MarshalToYAML serializes the given cloud-init Config to YAML format.

func WriteDataFiles

func WriteDataFiles(
	ctx opctx.Ctx, dir string, hostname string, config *Config,
) (metaDataPath, userDataPath string, err error)

WriteDataFiles writes the cloud-init meta-data and user-data files to the specified directory. Returns the paths to the created meta-data and user-data files.

Types

type Config

type Config struct {
	ChangePasswords       *PasswordConfig `yaml:"chpasswd,omitempty"`
	EnableSSHPasswordAuth *bool           `yaml:"ssh_pwauth,omitempty"`
	DisableRootUser       *bool           `yaml:"disable_root,omitempty"`
	Users                 []UserConfig    `yaml:"users,omitempty"`
}

Config represents the cloud-init configuration. N.B. Minimal definition with what we're using.

type PasswordConfig

type PasswordConfig struct {
	List   string `yaml:"list,omitempty"`
	Expire *bool  `yaml:"expire,omitempty"`
}

PasswordConfig contains password change configuration for cloud-init. N.B. Minimal definition with what we're using.

type UserConfig

type UserConfig struct {
	Description           string   `yaml:"gecos,omitempty"`
	EnableSSHPasswordAuth *bool    `yaml:"ssh_pwauth,omitempty"`
	Groups                []string `yaml:"groups,omitempty"`
	LockPassword          *bool    `yaml:"lock_passwd,omitempty"`
	Name                  string   `yaml:"name,omitempty"`
	PlainTextPassword     string   `yaml:"plain_text_passwd,omitempty"`
	Shell                 string   `yaml:"shell,omitempty"`
	SSHAuthorizedKeys     []string `yaml:"ssh_authorized_keys,omitempty"`
	Sudo                  []string `yaml:"sudo,omitempty"`
}

UserConfig contains user configuration for cloud-init. N.B. Minimal definition with what we're using.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL