Documentation
¶
Index ¶
- Variables
- func ChangeCWDToPlaybookDir(playbookPath string) (string, error)
- func CheckIfVariableIsUnused(s string) bool
- func ClearSourceFSForCLI()
- func ConvertOutputToFactsMap(output ModuleOutput) interface{}
- func EvaluateExpression(s string, closure *Closure) (interface{}, error)
- func ExecuteGraph(executor GraphExecutor, graph *Graph, inventoryFile string, cfg *config.Config, ...) error
- func ExecuteGraphWithLimit(executor GraphExecutor, graph *Graph, inventoryFile string, cfg *config.Config, ...) error
- func GenerateUnifiedDiff(filePath, originalContent, newContent string) (string, error)
- func GetContextForRun(inventory *Inventory, graph *Graph, cfg *config.Config) (map[string]*HostContext, error)
- func GetHostContexts(inventory *Inventory, graph *Graph, cfg *config.Config) (map[string]*HostContext, error)
- func GetOrderedGraph(cfg *config.Config, graph *Graph) ([][]GraphNode, error)
- func GetVariableUsageFromModule(input ConcreteModuleInputProvider) ([]string, error)
- func GetVariableUsageFromTemplate(s string) []string
- func Indent(n int) string
- func IsAnsibleVaultString(yamlContent string) bool
- func JinjaStringToStringList(jinjaStr string) ([]string, error)
- func ListRegisteredModules() map[string]BaseModule
- func MapToSyncMap(m map[string]interface{}) *sync.Map
- func ParsePlayAttributes(blocks []map[string]interface{}) (map[string]interface{}, error)
- func ProcessRecursive(originalVal reflect.Value, closure *Closure) (reflect.Value, error)
- func ReadLocalFile(filename string) (string, error)
- func ReadSourceFile(filename string) (string, error)
- func ReadTemplateFile(filename string) (string, error)
- func RegisterMetaModule(name string, module MetaModule)
- func RegisterModule(name string, module Module)
- func RegisterVariableIfNeeded(result TaskResult, task Task, c *Closure)
- func ReportPlayCompletion(client *daemon.Client) error
- func ReportPlayError(client *daemon.Client, err error) error
- func ReportPlayStart(client *daemon.Client, playbook, inventory, executor string) error
- func ReportTaskCompletion(client *daemon.Client, task Task, result TaskResult, hostName string, ...) error
- func ReportTaskSkipped(client *daemon.Client, taskId int, taskName, hostName string, ...) error
- func ReportTaskStart(client *daemon.Client, taskId int, taskName, hostName string, ...) error
- func ResolveExecutionLevel(task GraphNode, taskNameMapping map[string]GraphNode, ...) map[int]int
- func SetSourceFSForCLI(fsys fs.FS)
- func ShouldShowDiff(closure *Closure) bool
- func TemplateString(s string, closure *Closure) (string, error)
- func WaitForPendingReportsWithTimeout(timeout time.Duration) error
- type AnsibleVaultString
- type BaseModule
- type Closure
- type ConcreteModuleInputProvider
- type FactProvider
- type GenericMapOutput
- type GenericOutput
- type Graph
- func (g Graph) CheckForRequiredInputs(hostContexts map[string]*HostContext) error
- func (g Graph) MarshalJSON() ([]byte, error)
- func (g Graph) ParallelTasks() [][]GraphNode
- func (g Graph) SaveToFile(path string) error
- func (g Graph) SequentialTasks() [][]GraphNode
- func (g Graph) String() string
- func (g Graph) ToCode() string
- func (g *Graph) UnmarshalJSON(data []byte) error
- type GraphExecutor
- type GraphNode
- type Group
- type HandlerTracker
- func (ht *HandlerTracker) GetAllHandlers() []GraphNode
- func (ht *HandlerTracker) GetNotifiedHandlers() []GraphNode
- func (ht *HandlerTracker) GetStats() map[string]interface{}
- func (ht *HandlerTracker) IsExecuted(handlerName string) bool
- func (ht *HandlerTracker) IsNotified(handlerName string) bool
- func (ht *HandlerTracker) MarkExecuted(handlerName string)
- func (ht *HandlerTracker) NotifyHandler(handlerName string)
- func (ht *HandlerTracker) NotifyHandlers(handlerNames []string)
- func (ht *HandlerTracker) Reset()
- type HasParams
- type Host
- type HostContext
- func (c *HostContext) Close() error
- func (c *HostContext) Copy(src, dst string) error
- func (c *HostContext) GetOrCreateSSHPool() (*desopssshpool.Pool, error)
- func (c *HostContext) GetOrCreateSftpClient() (*runtime.SftpClient, error)
- func (c *HostContext) InitializeHandlerTracker(handlers []GraphNode)
- func (c *HostContext) ReadFile(filename string, username string) (string, error)
- func (c *HostContext) ReadFileBytes(filename string, username string) ([]byte, error)
- func (c *HostContext) RunCommand(command, username string) (int, string, string, error)
- func (c *HostContext) RunCommandWithShell(command, username string, useShell bool) (int, string, string, error)
- func (c *HostContext) SetFileMode(path, mode, username string) error
- func (c *HostContext) Stat(path string, follow bool) (os.FileInfo, error)
- func (c *HostContext) WriteFile(filename, contents, username string) error
- type IgnoredTaskError
- type Inventory
- func LoadInventory(path string, cfg *config.Config) (*Inventory, error)
- func LoadInventoryWithLimit(path string, limitPattern string, cfg *config.Config) (*Inventory, error)
- func LoadInventoryWithPaths(path string, inventoryPaths string, workingDir string, limitPattern string, ...) (*Inventory, error)
- type JinjaExpression
- func (e JinjaExpression) Evaluate(closure *Closure) (any, error)
- func (e JinjaExpression) IsEmpty() bool
- func (e JinjaExpression) IsTruthy(closure *Closure) bool
- func (e JinjaExpression) String() string
- func (e JinjaExpression) ToCode() string
- func (e *JinjaExpression) UnmarshalJSON(data []byte) error
- func (e *JinjaExpression) UnmarshalYAML(unmarshal func(interface{}) error) error
- type JinjaExpressionList
- func (el JinjaExpressionList) IsEmpty() bool
- func (el JinjaExpressionList) IsTruthy(closure *Closure) bool
- func (el JinjaExpressionList) ToCode() string
- func (el *JinjaExpressionList) UnmarshalJSON(data []byte) error
- func (el *JinjaExpressionList) UnmarshalYAML(unmarshal func(interface{}) error) error
- type MemFS
- type MetaModule
- type MetaTask
- func (mt *MetaTask) ConstructClosure(c *HostContext, cfg *config.Config) *Closure
- func (mt *MetaTask) ExecuteModule(closure *Closure) chan TaskResult
- func (mt *MetaTask) GetId() int
- func (mt *MetaTask) GetIsHandler() bool
- func (mt *MetaTask) GetName() string
- func (mt *MetaTask) GetTags() []string
- func (mt *MetaTask) GetVariableUsage() ([]string, error)
- func (mt *MetaTask) MarshalJSON() ([]byte, error)
- func (mt *MetaTask) Params() *TaskParams
- func (mt *MetaTask) RevertModule(closure *Closure) chan TaskResult
- func (mt *MetaTask) SetId(id int)
- func (mt *MetaTask) ShouldExecute(closure *Closure) (bool, error)
- func (mt *MetaTask) String() string
- func (mt *MetaTask) ToCode() string
- func (mt *MetaTask) UnmarshalJSON(data []byte) error
- type Module
- type ModuleDocProvider
- type ModuleInput
- type ModuleOutput
- type ParameterDoc
- type ParameterDocsProvider
- type RevertableChange
- type Task
- func (t Task) ConstructClosure(c *HostContext, cfg *config.Config) *Closure
- func (t Task) ExecuteModule(closure *Closure) chan TaskResult
- func (t Task) GetId() int
- func (t Task) GetIsHandler() bool
- func (t Task) GetName() string
- func (t Task) GetTags() []string
- func (t Task) GetVariableUsage() ([]string, error)
- func (t Task) MarshalJSON() ([]byte, error)
- func (t Task) Params() *TaskParams
- func (t Task) RevertModule(closure *Closure) chan TaskResult
- func (t *Task) SetId(id int)
- func (t Task) ShouldExecute(closure *Closure) (bool, error)
- func (t Task) String() string
- func (t Task) ToCode() string
- func (t *Task) UnmarshalJSON(data []byte) error
- type TaskParams
- type TaskResult
- type TaskRunner
- type TaskStatus
Constants ¶
This section is empty.
Variables ¶
var AllowedFacts = map[string]struct{}{
"platform": {},
"user": {},
"inventory_hostname": {},
"ssh_host_pub_keys": {},
"inventory_hostname_short": {},
"ansible_distribution": {},
"ansible_distribution_major_version": {},
"ansible_os_family": {},
}
Facts that can be gathered by the setup module
var SpecialVars = []string{
"previous",
}
Don't look for dependencies for these vars
Functions ¶
func ChangeCWDToPlaybookDir ¶ added in v1.0.0
func CheckIfVariableIsUnused ¶ added in v1.0.0
CheckIfVariableIsUnused returns true if the template string uses the default() pattern anywhere. This allows treating variables inside such expressions as optional (no graph dependency).
func ClearSourceFSForCLI ¶ added in v1.0.0
func ClearSourceFSForCLI()
func ConvertOutputToFactsMap ¶
func ConvertOutputToFactsMap(output ModuleOutput) interface{}
func EvaluateExpression ¶
func ExecuteGraph ¶
func ExecuteGraphWithLimit ¶ added in v1.0.0
func GenerateUnifiedDiff ¶ added in v1.0.0
GenerateUnifiedDiff creates a unified diff string between two text contents.
func GetContextForRun ¶ added in v1.0.0
func GetHostContexts ¶
func GetHostContexts(inventory *Inventory, graph *Graph, cfg *config.Config) (map[string]*HostContext, error)
Execute implements the main execution loop for a Spage graph.
func GetOrderedGraph ¶
func GetVariableUsageFromModule ¶
func GetVariableUsageFromModule(input ConcreteModuleInputProvider) ([]string, error)
func IsAnsibleVaultString ¶ added in v1.0.0
func JinjaStringToStringList ¶ added in v1.0.0
JinjaStringToStringList Evaluate string list "['abc', 'def']" into Golang []string{"abc", "def"}
func ListRegisteredModules ¶ added in v1.0.0
func ListRegisteredModules() map[string]BaseModule
ListRegisteredModules returns a copy of the registered modules map. This function is useful for tooling like documentation generators that need to introspect available modules without mutating the registry.
func MapToSyncMap ¶
Helper function to convert map[string]interface{} to *sync.Map
func ParsePlayAttributes ¶ added in v1.0.0
func ProcessRecursive ¶ added in v1.0.0
ProcessRecursive is the core recursive function that creates a new reflect.Value based on originalVal, with string fields templated. It returns a new reflect.Value representing the copied and processed value, or an error.
func ReadLocalFile ¶
func ReadSourceFile ¶ added in v1.0.0
ReadSourceFile reads a file that may be part of the source bundle FS (if configured), falling back to the local filesystem.
func ReadTemplateFile ¶
func RegisterMetaModule ¶ added in v1.0.0
func RegisterMetaModule(name string, module MetaModule)
RegisterModule allows modules to register themselves by name.
func RegisterModule ¶
RegisterModule allows modules to register themselves by name.
func RegisterVariableIfNeeded ¶
func RegisterVariableIfNeeded(result TaskResult, task Task, c *Closure)
func ReportPlayCompletion ¶ added in v1.0.0
func ReportPlayStart ¶ added in v1.0.0
func ReportTaskCompletion ¶ added in v1.0.0
func ReportTaskCompletion(client *daemon.Client, task Task, result TaskResult, hostName string, executionLevel int) error
ReportTaskCompletion reports the completion of a task with metrics
func ReportTaskSkipped ¶ added in v1.0.0
func ReportTaskStart ¶ added in v1.0.0
func ReportTaskStart(client *daemon.Client, taskId int, taskName, hostName string, executionLevel int) error
ReportTaskStart reports the start of a task execution
func ResolveExecutionLevel ¶
func SetSourceFSForCLI ¶ added in v1.0.0
Exported wrappers used by CLI without exposing internals elsewhere
func ShouldShowDiff ¶ added in v1.0.0
ShouldShowDiff determines if diff output should be displayed based on: 1. Global ansible_diff setting (set by --diff flag or task level setting) 2. Task-level diff setting (overrides global setting)
func TemplateString ¶
TemplateString processes a Jinja2 template string with provided variables.
func WaitForPendingReportsWithTimeout ¶ added in v1.0.0
WaitForPendingReportsWithTimeout waits for all pending daemon reports to complete with a timeout to prevent indefinite hanging
Types ¶
type AnsibleVaultString ¶ added in v1.0.0
type AnsibleVaultString struct {
FormatId string `yaml:"format_id"` // Only valid format so far is "$ANSIBLE_VAULT"
Version string `yaml:"version"`
VaultId string `yaml:"vault_id"` // Version 1.2 only, optionally
CipherText string `yaml:"ciphertext"`
}
AnsibleVaultString is a struct that represents an Ansible vault string, like $ANSIBLE_VAULT;1.2;AES256;some-vault-id 623133...
func Encrypt ¶ added in v1.0.0
func Encrypt(plaintext, password string) (*AnsibleVaultString, error)
func NewAnsibleVaultString ¶ added in v1.0.0
func NewAnsibleVaultString(yamlContent string) (*AnsibleVaultString, error)
type BaseModule ¶ added in v1.0.0
type Closure ¶
type Closure struct {
HostContext *HostContext
ExtraFacts map[string]interface{}
Config *config.Config
}
func (*Closure) IsCheckMode ¶ added in v1.0.0
IsCheckMode returns true if ansible_check_mode fact is set to true
type ConcreteModuleInputProvider ¶
type ConcreteModuleInputProvider interface {
ToCode() string
GetVariableUsage() []string
Validate() error
// HasRevert indicates if this input defines a revert action.
HasRevert() bool
// ProvidesVariables returns a list of variable names this input might define (e.g., keys in set_fact).
ProvidesVariables() []string
}
ModuleInput is a marker interface for module input parameters. It ensures that module parameters have a method to generate their code representation.
func TemplateModuleInputFields ¶
func TemplateModuleInputFields(originalProvider ConcreteModuleInputProvider, closure *Closure) (ConcreteModuleInputProvider, error)
TemplateModuleInputFields creates a *copy* of the input provider's underlying struct, walking all string fields in the copied struct (recursively) and templates them. The original input struct is NOT mutated. It accepts a ConcreteModuleInputProvider and returns a new ConcreteModuleInputProvider of the same underlying kind (value or pointer) as the input, or an error.
type FactProvider ¶
type FactProvider interface {
AsFacts() map[string]interface{}
}
FactProvider is an interface that module outputs can implement to provide a map representation suitable for registering as facts.
type GenericMapOutput ¶ added in v1.0.0
type GenericMapOutput map[string]interface{}
GenericMapOutput provides a generic, map-based implementation of ModuleOutput. This is useful for reconstructing ModuleOutput from history where type information may have been lost.
func (GenericMapOutput) Changed ¶ added in v1.0.0
func (g GenericMapOutput) Changed() bool
Changed checks for a "changed" key in the map.
func (GenericMapOutput) String ¶ added in v1.0.0
func (g GenericMapOutput) String() string
String provides a simple string representation of the map.
type GenericOutput ¶ added in v1.0.0
type GenericOutput map[string]interface{}
GenericOutput is a flexible map-based implementation of pkg.ModuleOutput.
func (GenericOutput) Changed ¶ added in v1.0.0
func (g GenericOutput) Changed() bool
Changed checks for a "changed" key in the map.
func (GenericOutput) Facts ¶ added in v1.0.0
func (g GenericOutput) Facts() map[string]interface{}
Facts returns the output map itself, so all keys become facts.
func (GenericOutput) String ¶ added in v1.0.0
func (g GenericOutput) String() string
String provides a simple string representation of the map.
type Graph ¶
type Graph struct {
RequiredInputs []string
Nodes [][]GraphNode
Handlers []GraphNode
Vars map[string]interface{}
PlaybookPath string
}
func NewGraphFromFS ¶ added in v1.0.0
NewGraphFromFS builds a graph from a playbook path within an fs.FS. The playbookPath must be the POSIX-style path inside the provided FS.
func NewGraphFromFile ¶
func (Graph) CheckForRequiredInputs ¶ added in v1.0.0
func (g Graph) CheckForRequiredInputs(hostContexts map[string]*HostContext) error
func (Graph) MarshalJSON ¶ added in v1.0.0
MarshalJSON implements custom JSON marshaling for Graph to handle GraphNode interfaces.
func (Graph) ParallelTasks ¶
Order tasks based on execution level
func (Graph) SaveToFile ¶
func (Graph) SequentialTasks ¶
Order tasks by their id
func (*Graph) UnmarshalJSON ¶ added in v1.0.0
UnmarshalJSON implements custom JSON unmarshaling for Graph to handle GraphNode interfaces.
type GraphExecutor ¶
type GraphExecutor interface {
Execute(hostContexts map[string]*HostContext, orderedGraph [][]GraphNode, cfg *config.Config) error
Revert(ctx context.Context, executedTasks []map[string]chan GraphNode, hostContexts map[string]*HostContext, cfg *config.Config) error
}
GraphExecutor defines the interface for running a Spage graph.
type GraphNode ¶
type GraphNode interface {
String() string
ToCode() string
GetVariableUsage() ([]string, error)
ConstructClosure(c *HostContext, cfg *config.Config) *Closure
ExecuteModule(closure *Closure) chan TaskResult
RevertModule(closure *Closure) chan TaskResult
ShouldExecute(closure *Closure) (bool, error)
json.Marshaler
// Interface marker to point to params
HasParams
}
GraphNode represents either a list of tasks or a nested graph
func TextToGraphNodes ¶
type HandlerTracker ¶ added in v1.0.0
type HandlerTracker struct {
// contains filtered or unexported fields
}
HandlerTracker tracks which handlers have been notified and which have already run
func NewHandlerTracker ¶ added in v1.0.0
func NewHandlerTracker(hostName string, handlers []GraphNode) *HandlerTracker
NewHandlerTracker creates a new HandlerTracker for the given host and handlers
func (*HandlerTracker) GetAllHandlers ¶ added in v1.0.0
func (ht *HandlerTracker) GetAllHandlers() []GraphNode
GetAllHandlers returns all handlers registered with this tracker
func (*HandlerTracker) GetNotifiedHandlers ¶ added in v1.0.0
func (ht *HandlerTracker) GetNotifiedHandlers() []GraphNode
GetNotifiedHandlers returns a list of handlers that have been notified but not yet executed
func (*HandlerTracker) GetStats ¶ added in v1.0.0
func (ht *HandlerTracker) GetStats() map[string]interface{}
GetStats returns statistics about handler notifications and executions
func (*HandlerTracker) IsExecuted ¶ added in v1.0.0
func (ht *HandlerTracker) IsExecuted(handlerName string) bool
IsExecuted checks if a handler has been executed
func (*HandlerTracker) IsNotified ¶ added in v1.0.0
func (ht *HandlerTracker) IsNotified(handlerName string) bool
IsNotified checks if a handler has been notified
func (*HandlerTracker) MarkExecuted ¶ added in v1.0.0
func (ht *HandlerTracker) MarkExecuted(handlerName string)
MarkExecuted marks a handler as executed
func (*HandlerTracker) NotifyHandler ¶ added in v1.0.0
func (ht *HandlerTracker) NotifyHandler(handlerName string)
NotifyHandler marks a handler as notified
func (*HandlerTracker) NotifyHandlers ¶ added in v1.0.0
func (ht *HandlerTracker) NotifyHandlers(handlerNames []string)
NotifyHandlers marks multiple handlers as notified
func (*HandlerTracker) Reset ¶ added in v1.0.0
func (ht *HandlerTracker) Reset()
Reset clears all notification and execution status
type HasParams ¶ added in v1.0.0
type HasParams interface {
Params() *TaskParams
}
type HostContext ¶
type HostContext struct {
Host *Host
Facts *sync.Map
History *sync.Map
HandlerTracker *HandlerTracker
// contains filtered or unexported fields
}
HostContext represents the context for a specific host during playbook execution. It contains host-specific data like facts, variables, and SSH connections.
func GetContextForHost ¶ added in v1.0.0
GetContextForHost creates a host context from inventory and host data
func InitializeHostContext ¶
func InitializeHostContext(host *Host, cfg *config.Config) (*HostContext, error)
func (*HostContext) Close ¶
func (c *HostContext) Close() error
func (*HostContext) Copy ¶
func (c *HostContext) Copy(src, dst string) error
func (*HostContext) GetOrCreateSSHPool ¶ added in v1.0.0
func (c *HostContext) GetOrCreateSSHPool() (*desopssshpool.Pool, error)
GetOrCreateSSHPool returns an existing SSH pool or creates a new one
func (*HostContext) GetOrCreateSftpClient ¶ added in v1.0.0
func (c *HostContext) GetOrCreateSftpClient() (*runtime.SftpClient, error)
GetOrCreateSftpClient returns an existing SFTP client or creates a new one using the SSH pool
func (*HostContext) InitializeHandlerTracker ¶ added in v1.0.0
func (c *HostContext) InitializeHandlerTracker(handlers []GraphNode)
InitializeHandlerTracker initializes the HandlerTracker with the provided handlers
func (*HostContext) ReadFile ¶
func (c *HostContext) ReadFile(filename string, username string) (string, error)
func (*HostContext) ReadFileBytes ¶
func (c *HostContext) ReadFileBytes(filename string, username string) ([]byte, error)
func (*HostContext) RunCommand ¶
func (*HostContext) RunCommandWithShell ¶ added in v1.0.0
func (*HostContext) SetFileMode ¶
func (c *HostContext) SetFileMode(path, mode, username string) error
func (*HostContext) WriteFile ¶
func (c *HostContext) WriteFile(filename, contents, username string) error
type IgnoredTaskError ¶
type IgnoredTaskError struct {
OriginalErr error
}
IgnoredTaskError is a custom error type used when a task fails but IgnoreErrors is set to true. It wraps the original error.
func (*IgnoredTaskError) Error ¶
func (e *IgnoredTaskError) Error() string
Error implements the error interface for IgnoredTaskError.
func (*IgnoredTaskError) Unwrap ¶
func (e *IgnoredTaskError) Unwrap() error
Unwrap allows errors.Is and errors.As to work with the wrapped original error.
type JinjaExpression ¶ added in v1.0.0
type JinjaExpression struct {
Expression string
}
func (JinjaExpression) Evaluate ¶ added in v1.0.0
func (e JinjaExpression) Evaluate(closure *Closure) (any, error)
func (JinjaExpression) IsEmpty ¶ added in v1.0.0
func (e JinjaExpression) IsEmpty() bool
func (JinjaExpression) IsTruthy ¶ added in v1.0.0
func (e JinjaExpression) IsTruthy(closure *Closure) bool
func (JinjaExpression) String ¶ added in v1.0.0
func (e JinjaExpression) String() string
func (JinjaExpression) ToCode ¶ added in v1.0.0
func (e JinjaExpression) ToCode() string
func (*JinjaExpression) UnmarshalJSON ¶ added in v1.0.0
func (e *JinjaExpression) UnmarshalJSON(data []byte) error
UnmarshalJSON allows JinjaExpression to be parsed from JSON as a string or bool
func (*JinjaExpression) UnmarshalYAML ¶ added in v1.0.0
func (e *JinjaExpression) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML allows JinjaExpression to be parsed from YAML as a string or bool
type JinjaExpressionList ¶ added in v1.0.0
type JinjaExpressionList []JinjaExpression
func (JinjaExpressionList) IsEmpty ¶ added in v1.0.0
func (el JinjaExpressionList) IsEmpty() bool
func (JinjaExpressionList) IsTruthy ¶ added in v1.0.0
func (el JinjaExpressionList) IsTruthy(closure *Closure) bool
func (JinjaExpressionList) ToCode ¶ added in v1.0.0
func (el JinjaExpressionList) ToCode() string
func (*JinjaExpressionList) UnmarshalJSON ¶ added in v1.0.0
func (el *JinjaExpressionList) UnmarshalJSON(data []byte) error
UnmarshalJSON for JinjaExpressionList supports both a single value or a list
func (*JinjaExpressionList) UnmarshalYAML ¶ added in v1.0.0
func (el *JinjaExpressionList) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML for JinjaExpressionList supports both a single value or a list
type MemFS ¶ added in v1.0.0
type MemFS struct {
// contains filtered or unexported fields
}
func NewMemFSFromTarGz ¶ added in v1.0.0
NewMemFSFromTarGz builds a MemFS from a tar.gz stream.
type MetaModule ¶ added in v1.0.0
type MetaModule interface {
BaseModule
EvaluateExecute(task *MetaTask, c *Closure) chan TaskResult
EvaluateRevert(task *MetaTask, c *Closure) chan TaskResult
}
func GetMetaModule ¶ added in v1.0.0
func GetMetaModule(name string) (MetaModule, bool)
GetMetaModule retrieves a registered meta module by name.
type MetaTask ¶ added in v1.0.0
type MetaTask struct {
*TaskParams
Children []GraphNode `yaml:"children" json:"children"`
Rescue []GraphNode `yaml:"rescue,omitempty" json:"rescue,omitempty"`
Always []GraphNode `yaml:"always,omitempty" json:"always,omitempty"`
}
func (*MetaTask) ConstructClosure ¶ added in v1.0.0
func (mt *MetaTask) ConstructClosure(c *HostContext, cfg *config.Config) *Closure
func (*MetaTask) ExecuteModule ¶ added in v1.0.0
func (mt *MetaTask) ExecuteModule(closure *Closure) chan TaskResult
func (*MetaTask) GetIsHandler ¶ added in v1.0.0
func (*MetaTask) GetVariableUsage ¶ added in v1.0.0
func (*MetaTask) MarshalJSON ¶ added in v1.0.0
func (*MetaTask) Params ¶ added in v1.0.0
func (mt *MetaTask) Params() *TaskParams
func (*MetaTask) RevertModule ¶ added in v1.0.0
func (mt *MetaTask) RevertModule(closure *Closure) chan TaskResult
func (*MetaTask) ShouldExecute ¶ added in v1.0.0
func (*MetaTask) UnmarshalJSON ¶ added in v1.0.0
type Module ¶
type Module interface {
BaseModule
Execute(params ConcreteModuleInputProvider, c *Closure, runAs string) (ModuleOutput, error)
Revert(params ConcreteModuleInputProvider, c *Closure, previous ModuleOutput, runAs string) (ModuleOutput, error)
ParameterAliases() map[string]string
}
type ModuleDocProvider ¶ added in v1.0.0
type ModuleDocProvider interface {
Doc() string
}
ModuleDocProvider is an optional interface that a Module can implement to provide additional Markdown documentation (description, examples, notes). If implemented, tooling like docgen can surface this content in generated docs.
type ModuleInput ¶
type ModuleInput struct {
// Actual holds the concrete *ShellInput, *CopyInput, etc.
// Let the standard marshalers handle this field when marshaling the parent Task struct,
// using the custom Task MarshalJSON.
Actual ConcreteModuleInputProvider `json:"actual,omitempty" yaml:"actual,omitempty"`
}
Its primary role is to facilitate correct JSON/YAML marshaling/unmarshaling when it's a field within another struct (like Task).
func (*ModuleInput) GetVariableUsage ¶
func (mi *ModuleInput) GetVariableUsage() []string
GetVariableUsage delegates to the Actual ConcreteModuleInputProvider.
func (*ModuleInput) HasRevert ¶
func (mi *ModuleInput) HasRevert() bool
HasRevert delegates to the Actual ConcreteModuleInputProvider.
func (*ModuleInput) ProvidesVariables ¶
func (mi *ModuleInput) ProvidesVariables() []string
ProvidesVariables delegates to the Actual ConcreteModuleInputProvider.
func (*ModuleInput) ToCode ¶
func (mi *ModuleInput) ToCode() string
ToCode delegates to the Actual ConcreteModuleInputProvider. It's called during code generation, Actual must be populated.
func (*ModuleInput) Validate ¶
func (mi *ModuleInput) Validate() error
Validate delegates to the Actual ConcreteModuleInputProvider.
type ModuleOutput ¶
ModuleOutput is a marker interface for module output results. It ensures that module results can indicate whether they represent a change.
type ParameterDoc ¶ added in v1.0.0
type ParameterDoc struct {
Description string // Human-readable description
Required *bool // Whether the parameter is required (nil = unspecified)
Default string // Default value rendered as text
Choices []string // Enumerated valid values, if applicable
}
ParameterDoc carries additional documentation for a single input parameter. All fields are optional; tooling will merge these with reflected types and comments.
type ParameterDocsProvider ¶ added in v1.0.0
type ParameterDocsProvider interface {
ParameterDocs() map[string]ParameterDoc
}
ParameterDocsProvider is an optional interface that a Module can implement to provide enriched documentation for its input parameters. The map key should be the YAML parameter name (e.g., "name", "state").
type RevertableChange ¶
type RevertableChange[T comparable] struct { Before T After T }
func (RevertableChange[T]) Changed ¶
func (r RevertableChange[T]) Changed() bool
func (RevertableChange[T]) DiffOutput ¶ added in v1.0.0
func (r RevertableChange[T]) DiffOutput() (string, error)
type Task ¶
type Task struct {
*TaskParams
}
func (Task) ConstructClosure ¶ added in v1.0.0
func (t Task) ConstructClosure(c *HostContext, cfg *config.Config) *Closure
func (Task) ExecuteModule ¶
func (t Task) ExecuteModule(closure *Closure) chan TaskResult
func (Task) GetIsHandler ¶ added in v1.0.0
func (Task) GetVariableUsage ¶ added in v1.0.0
func (Task) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for Task. This ensures that the Params field is marshaled correctly by handling the Actual field.
func (Task) Params ¶
func (t Task) Params() *TaskParams
func (Task) RevertModule ¶
func (t Task) RevertModule(closure *Closure) chan TaskResult
func (*Task) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for Task.
type TaskParams ¶ added in v1.0.0
type TaskParams struct {
Id int `yaml:"id" json:"id"`
Name string `yaml:"name" json:"name"`
Module string `yaml:"module" json:"module"`
Params ModuleInput `yaml:"params" json:"params"`
Validate string `yaml:"validate" json:"validate,omitempty"`
Before string `yaml:"before" json:"before,omitempty"`
After string `yaml:"after" json:"after,omitempty"`
When JinjaExpressionList `yaml:"when" json:"when,omitempty"`
Register string `yaml:"register" json:"register,omitempty"`
Become bool `yaml:"become" json:"become,omitempty"`
BecomeUser string `yaml:"become_user" json:"become_user,omitempty"`
IgnoreErrors JinjaExpression `yaml:"ignore_errors,omitempty" json:"ignore_errors,omitempty"`
FailedWhen JinjaExpressionList `yaml:"failed_when,omitempty" json:"failed_when,omitempty"`
ChangedWhen JinjaExpressionList `yaml:"changed_when,omitempty" json:"changed_when,omitempty"`
Loop interface{} `yaml:"loop,omitempty" json:"loop,omitempty"`
DelegateTo string `yaml:"delegate_to,omitempty" json:"delegate_to,omitempty"`
RunOnce JinjaExpression `yaml:"run_once,omitempty" json:"run_once,omitempty"`
NoLog JinjaExpression `yaml:"no_log,omitempty" json:"no_log,omitempty"`
Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"`
Vars interface{} `yaml:"vars,omitempty" json:"vars,omitempty"`
Rescue []GraphNode `yaml:"rescue,omitempty" json:"rescue,omitempty"`
Always []GraphNode `yaml:"always,omitempty" json:"always,omitempty"`
Until JinjaExpression `yaml:"until,omitempty" json:"until,omitempty"`
Retries int `yaml:"retries,omitempty" json:"retries,omitempty"`
Delay int `yaml:"delay,omitempty" json:"delay,omitempty"`
CheckMode *bool `yaml:"check_mode,omitempty" json:"check_mode,omitempty"`
Diff *bool `yaml:"diff,omitempty" json:"diff,omitempty"`
Notify []string `yaml:"notify,omitempty" json:"notify,omitempty"`
IsHandler bool `yaml:"is_handler,omitempty" json:"is_handler,omitempty"`
// Role context information for resource resolution
RoleName string `yaml:"_role_name,omitempty" json:"_role_name,omitempty"`
RolePath string `yaml:"_role_path,omitempty" json:"_role_path,omitempty"`
}
func (TaskParams) GetVariableUsage ¶ added in v1.0.0
func (t TaskParams) GetVariableUsage() ([]string, error)
func (*TaskParams) MarshalJSON ¶ added in v1.0.0
func (tp *TaskParams) MarshalJSON() ([]byte, error)
func (*TaskParams) ToCode ¶ added in v1.0.0
func (tp *TaskParams) ToCode() string
func (*TaskParams) UnmarshalJSON ¶ added in v1.0.0
func (tp *TaskParams) UnmarshalJSON(data []byte) error
type TaskResult ¶
type TaskResult struct {
Output ModuleOutput
Error error // This can now be nil, a normal error, or an IgnoredTaskError
Closure *Closure
Task GraphNode
Duration time.Duration
Status TaskStatus
Failed bool
Changed bool
// ExecutionSpecificOutput can store runner-specific results, e.g., SpageActivityResult for Temporal.
ExecutionSpecificOutput interface{}
}
Useful for having a single type to pass around in channels
func HandleResult ¶
func HandleResult(r *TaskResult, t Task, c *Closure) TaskResult
type TaskRunner ¶
type TaskRunner interface {
ExecuteTask(ctx context.Context, task GraphNode, closure *Closure, cfg *config.Config) chan TaskResult
RevertTask(ctx context.Context, task GraphNode, closure *Closure, cfg *config.Config) chan TaskResult
}
TaskRunner defines an interface for how a single task is executed. This allows the core execution logic to be generic, while the actual task dispatch (local, Temporal activity, etc.) can be specific.
type TaskStatus ¶
type TaskStatus string
const ( TaskStatusSkipped TaskStatus = "skipped" TaskStatusFailed TaskStatus = "failed" TaskStatusChanged TaskStatus = "changed" TaskStatusOk TaskStatus = "ok" )
func (TaskStatus) String ¶
func (s TaskStatus) String() string