ansible

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InventoryFormatINI     = "ini"
	InventoryFormatYAML    = "yaml"
	InventoryStyleCompact  = "compact"
	InventoryStyleExpanded = "expanded"
)

Variables

This section is empty.

Functions

func NormalizeInventoryFormat

func NormalizeInventoryFormat(format string) string

NormalizeInventoryFormat validates and canonicalizes inventory format.

func NormalizeInventoryStyle

func NormalizeInventoryStyle(style string) string

NormalizeInventoryStyle validates and canonicalizes inventory style.

func SaveInventory

func SaveInventory(path, content string) error

SaveInventory writes inventory text to a user-selected path.

Types

type CommandResult

type CommandResult struct {
	Command  string
	Output   string
	Duration time.Duration
	Err      error
}

CommandResult stores process execution details.

type InventoryDefaults

type InventoryDefaults struct {
	NodeSSHUser       string
	VMSSHUser         string
	SSHPrivateKeyFile string
	DefaultPassword   string
	InventoryVars     map[string]string
	Style             string
}

InventoryDefaults defines default SSH users for inventory generation.

type InventoryHost

type InventoryHost struct {
	Alias      string
	Target     string
	GroupNames []string
	Vars       map[string]string
}

InventoryHost captures one generated host entry.

type InventoryResult

type InventoryResult struct {
	Format string
	Text   string
	Hosts  []InventoryHost
}

InventoryResult contains the final inventory text and generated host metadata.

func BuildInventory

func BuildInventory(nodes []*api.Node, guests []*api.VM, defaults InventoryDefaults) InventoryResult

BuildInventory renders an INI-style Ansible inventory from Proxmox nodes and guests.

func BuildInventoryWithFormat

func BuildInventoryWithFormat(nodes []*api.Node, guests []*api.VM, defaults InventoryDefaults, format string) InventoryResult

BuildInventoryWithFormat renders an inventory in the requested format.

type OutputLineHandler

type OutputLineHandler func(line string)

OutputLineHandler receives a single line of command output.

type PlaybookOptions

type PlaybookOptions struct {
	PlaybookPath string
	Limit        string
	ExtraArgs    []string
	CheckMode    bool
}

PlaybookOptions describes ansible-playbook invocation options.

type Runner

type Runner struct{}

Runner executes local ansible commands.

func NewRunner

func NewRunner() *Runner

NewRunner creates a new command runner.

func (*Runner) CheckAvailability

func (r *Runner) CheckAvailability() error

CheckAvailability verifies that required ansible binaries are available in PATH.

func (*Runner) RunPing

func (r *Runner) RunPing(ctx context.Context, inventoryText, inventoryFormat, limit string, extraArgs []string) CommandResult

RunPing executes `ansible -m ping` using the generated inventory.

func (*Runner) RunPingStream

func (r *Runner) RunPingStream(
	ctx context.Context,
	inventoryText,
	inventoryFormat,
	limit string,
	extraArgs []string,
	handler OutputLineHandler,
) CommandResult

RunPingStream executes `ansible -m ping` and streams output lines when handler is provided.

func (*Runner) RunPlaybook

func (r *Runner) RunPlaybook(ctx context.Context, inventoryText, inventoryFormat string, opts PlaybookOptions) CommandResult

RunPlaybook executes ansible-playbook with a generated temporary inventory.

func (*Runner) RunPlaybookStream

func (r *Runner) RunPlaybookStream(
	ctx context.Context,
	inventoryText,
	inventoryFormat string,
	opts PlaybookOptions,
	handler OutputLineHandler,
) CommandResult

RunPlaybookStream executes ansible-playbook and streams output lines when handler is provided.

Jump to

Keyboard shortcuts

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