modules

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPackageInstalled

func IsPackageInstalled(packageName string, c *pkg.HostContext, runAs string) bool

Types

type AptInput

type AptInput struct {
	Name        interface{} `yaml:"name"`         // Name of the package(s) (string or list of strings)
	State       string      `yaml:"state"`        // present (default), absent, latest
	UpdateCache bool        `yaml:"update_cache"` // Run apt-get update before action
	// Internal storage for parsed package list
	PkgNames []string
}

AptInput defines the parameters for the apt module.

func (*AptInput) GetVariableUsage

func (i *AptInput) GetVariableUsage() []string

GetVariableUsage identifies variables used in the apt parameters.

func (*AptInput) HasRevert

func (i *AptInput) HasRevert() bool

HasRevert indicates if the action can be reverted.

func (*AptInput) ProvidesVariables

func (i *AptInput) ProvidesVariables() []string

func (*AptInput) ToCode

func (i *AptInput) ToCode() string

ToCode converts the AptInput struct into its Go code representation.

func (*AptInput) UnmarshalYAML

func (i *AptInput) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML handles shorthand and list formats for the apt module 'name'.

func (*AptInput) Validate

func (i *AptInput) Validate() error

Validate checks if the input parameters are valid.

type AptModule

type AptModule struct{}

AptModule implements the Ansible 'apt' module logic.

func (AptModule) Execute

func (m AptModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

Execute runs the apt module logic.

func (AptModule) InputType

func (am AptModule) InputType() reflect.Type

func (AptModule) OutputType

func (am AptModule) OutputType() reflect.Type

func (AptModule) ParameterAliases

func (m AptModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for module parameters.

func (AptModule) Revert

func (m AptModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

Revert attempts to undo the action performed by Execute.

type AptOutput

type AptOutput struct {
	Packages    []string `yaml:"packages"` // Packages operated on
	Versions    []string `yaml:"versions"` // Versions installed/removed (if applicable)
	State       string   `yaml:"state"`    // Final state (installed, removed, updated)
	WasChanged  bool     // Internal flag to track if apt made changes
	UpdateCache bool     // Whether cache update was performed
	pkg.ModuleOutput
}

AptOutput defines the output of the apt module.

func (AptOutput) AsFacts

func (o AptOutput) AsFacts() map[string]interface{}

AsFacts implements the pkg.FactProvider interface.

func (AptOutput) Changed

func (o AptOutput) Changed() bool

Changed indicates if the apt module made changes to the system.

func (AptOutput) String

func (o AptOutput) String() string

String provides a string representation of the AptOutput.

type AssertInput

type AssertInput struct {
	That []string `yaml:"that"` // List of assertions to evaluate
	Msg  string   `yaml:"msg"`  // Optional message on failure
}

func (AssertInput) GetVariableUsage

func (i AssertInput) GetVariableUsage() []string

func (AssertInput) HasRevert

func (i AssertInput) HasRevert() bool

HasRevert indicates that the assert module cannot be reverted.

func (AssertInput) ProvidesVariables

func (i AssertInput) ProvidesVariables() []string

func (AssertInput) ToCode

func (i AssertInput) ToCode() string

func (AssertInput) Validate

func (i AssertInput) Validate() error

type AssertModule

type AssertModule struct{}

func (AssertModule) Execute

func (m AssertModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

func (AssertModule) InputType

func (am AssertModule) InputType() reflect.Type

func (AssertModule) OutputType

func (am AssertModule) OutputType() reflect.Type

func (AssertModule) ParameterAliases

func (m AssertModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for module parameters.

func (AssertModule) Revert

func (m AssertModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

Revert for Assert is a no-op as it doesn't change state

type AssertOutput

type AssertOutput struct {
	FailedAssertion string // Which assertion failed, if any
	pkg.ModuleOutput
}

func (AssertOutput) Changed

func (o AssertOutput) Changed() bool

func (AssertOutput) String

func (o AssertOutput) String() string

type CommandInput

type CommandInput struct {
	Execute string `yaml:"execute"` // The command to execute. Aliased as 'cmd'.
	Revert  string `yaml:"revert"`  // The command to execute for reverting changes.
}

CommandInput defines the parameters for the command module.

func (CommandInput) GetVariableUsage

func (i CommandInput) GetVariableUsage() []string

GetVariableUsage identifies variables used in the execute and revert commands.

func (CommandInput) HasRevert

func (i CommandInput) HasRevert() bool

HasRevert checks if a revert command is defined.

func (CommandInput) ProvidesVariables

func (i CommandInput) ProvidesVariables() []string

func (CommandInput) ToCode

func (i CommandInput) ToCode() string

ToCode converts the CommandInput struct into its Go code representation.

func (*CommandInput) UnmarshalYAML

func (i *CommandInput) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML allows the command module value to be either a string (shorthand) or a map with 'execute' and optionally 'revert'.

func (CommandInput) Validate

func (i CommandInput) Validate() error

Validate checks if the input parameters are valid.

type CommandModule

type CommandModule struct{}

CommandModule implements the Ansible 'command' module logic. It executes commands directly without going through a shell, meaning variables like $HOME and operations like "<", ">", "|", ";", "&" will not work.

func (CommandModule) Execute

func (cm CommandModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

Execute runs the main command.

func (CommandModule) InputType

func (cm CommandModule) InputType() reflect.Type

func (CommandModule) OutputType

func (cm CommandModule) OutputType() reflect.Type

func (CommandModule) ParameterAliases

func (m CommandModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for module parameters.

func (CommandModule) Revert

func (cm CommandModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

Revert runs the revert command.

type CommandOutput

type CommandOutput struct {
	Stdout  string `yaml:"stdout"`
	Stderr  string `yaml:"stderr"`
	Command string `yaml:"command"` // The actual command executed after templating.
	pkg.ModuleOutput
}

CommandOutput defines the output of the command module.

func (CommandOutput) AsFacts

func (o CommandOutput) AsFacts() map[string]interface{}

AsFacts implements the pkg.FactProvider interface. It returns a map representation suitable for registration.

func (CommandOutput) Changed

func (o CommandOutput) Changed() bool

Changed indicates if the command potentially changed the system state. For the command module, we assume it always potentially changes state.

func (CommandOutput) String

func (o CommandOutput) String() string

String provides a string representation of the CommandOutput.

type CopyInput

type CopyInput struct {
	Content string `yaml:"content"`
	Src     string `yaml:"src"`
	Dst     string `yaml:"dest"`
	Mode    string `yaml:"mode"`
}

func (CopyInput) GetVariableUsage

func (i CopyInput) GetVariableUsage() []string

func (CopyInput) HasRevert

func (i CopyInput) HasRevert() bool

HasRevert indicates that the copy module can be reverted.

func (CopyInput) ProvidesVariables

func (i CopyInput) ProvidesVariables() []string

func (CopyInput) ToCode

func (i CopyInput) ToCode() string

func (CopyInput) Validate

func (i CopyInput) Validate() error

type CopyModule

type CopyModule struct{}

func (CopyModule) Execute

func (m CopyModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

func (CopyModule) InputType

func (cm CopyModule) InputType() reflect.Type

func (CopyModule) OutputType

func (cm CopyModule) OutputType() reflect.Type

func (CopyModule) ParameterAliases

func (cm CopyModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for module parameters.

func (CopyModule) Revert

func (m CopyModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

type CopyOutput

type CopyOutput struct {
	Contents pkg.RevertableChange[string]
	Mode     pkg.RevertableChange[string]
	pkg.ModuleOutput
}

func (CopyOutput) Changed

func (o CopyOutput) Changed() bool

func (CopyOutput) String

func (o CopyOutput) String() string

type DebugInput

type DebugInput struct {
	Msg string `yaml:"msg,omitempty"`
	Var string `yaml:"var,omitempty"`
}

DebugInput defines the structure for the debug module's input. It can take a 'msg' to print directly, or a 'var' to print a variable's content.

func (DebugInput) GetVariableUsage

func (i DebugInput) GetVariableUsage() []string

GetVariableUsage extracts variables used within the 'msg' or 'var' fields.

func (DebugInput) HasRevert

func (i DebugInput) HasRevert() bool

HasRevert indicates that debug module does not have a revert action.

func (DebugInput) ProvidesVariables

func (i DebugInput) ProvidesVariables() []string

ProvidesVariables returns an empty list as debug doesn't set new variables.

func (DebugInput) ToCode

func (i DebugInput) ToCode() string

ToCode generates Go code representation of the DebugInput.

func (*DebugInput) UnmarshalYAML

func (i *DebugInput) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML custom unmarshaler to handle parameters.

func (DebugInput) Validate

func (i DebugInput) Validate() error

Validate ensures that either 'msg' or 'var' is provided.

type DebugModule

type DebugModule struct{}

DebugModule implements the logic for the debug module.

func (DebugModule) Execute

func (m DebugModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

Execute prints the message or variable content.

func (DebugModule) InputType

func (m DebugModule) InputType() reflect.Type

func (DebugModule) OutputType

func (m DebugModule) OutputType() reflect.Type

func (DebugModule) ParameterAliases

func (m DebugModule) ParameterAliases() map[string]string

ParameterAliases defines aliases if needed.

func (DebugModule) Revert

func (m DebugModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

Revert for debug now mirrors Execute.

type DebugOutput

type DebugOutput struct {
	MessagePrinted string
}

DebugOutput provides information about what was printed.

func (DebugOutput) Changed

func (o DebugOutput) Changed() bool

Changed indicates that the debug module does not change state.

func (DebugOutput) String

func (o DebugOutput) String() string

String provides a human-readable summary of the output.

type FailInput

type FailInput struct {
	Msg string `yaml:"msg"`
}

FailInput defines the structure for the fail module's input. It takes a 'msg' to be used as the failure message.

func (FailInput) GetVariableUsage

func (i FailInput) GetVariableUsage() []string

GetVariableUsage extracts variables used within the 'msg' field.

func (FailInput) HasRevert

func (i FailInput) HasRevert() bool

HasRevert indicates that fail module does not have a specific revert action. The failure itself might trigger a broader revert of previous tasks.

func (FailInput) ProvidesVariables

func (i FailInput) ProvidesVariables() []string

ProvidesVariables returns an empty list as fail doesn't set new variables.

func (FailInput) ToCode

func (i FailInput) ToCode() string

ToCode generates Go code representation of the FailInput.

func (FailInput) Validate

func (i FailInput) Validate() error

Validate ensures that 'msg' is provided.

type FailModule

type FailModule struct{}

FailModule implements the logic for the fail module.

func (FailModule) Execute

func (m FailModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

Execute always returns an error with the provided message.

func (FailModule) InputType

func (m FailModule) InputType() reflect.Type

func (FailModule) OutputType

func (m FailModule) OutputType() reflect.Type

func (FailModule) ParameterAliases

func (m FailModule) ParameterAliases() map[string]string

ParameterAliases defines aliases if needed.

func (FailModule) Revert

func (m FailModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

Revert for fail is a no-op. The failure itself is the primary action.

type FailOutput

type FailOutput struct {
	FailedMessage string
}

FailOutput provides information about the failure.

func (FailOutput) Changed

func (o FailOutput) Changed() bool

Changed indicates that the fail module does not change state.

func (FailOutput) String

func (o FailOutput) String() string

String provides a human-readable summary of the output.

type FileInput

type FileInput struct {
	Path  string `yaml:"path"` // Destination path
	State string `yaml:"state"`
	Mode  string `yaml:"mode"`
	Src   string `yaml:"src,omitempty"` // Source path for state=link
}

func (FileInput) GetVariableUsage

func (i FileInput) GetVariableUsage() []string

func (FileInput) HasRevert

func (i FileInput) HasRevert() bool

func (FileInput) ProvidesVariables

func (i FileInput) ProvidesVariables() []string

func (FileInput) ToCode

func (i FileInput) ToCode() string

func (FileInput) Validate

func (i FileInput) Validate() error

type FileModule

type FileModule struct{}

func (FileModule) Execute

func (m FileModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

func (FileModule) InputType

func (fm FileModule) InputType() reflect.Type

func (FileModule) OutputType

func (fm FileModule) OutputType() reflect.Type

func (FileModule) ParameterAliases

func (fm FileModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for the file module parameters.

func (FileModule) Revert

func (m FileModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

type FileOutput

type FileOutput struct {
	State      pkg.RevertableChange[string] // "file", "directory", "link", "absent"
	Mode       pkg.RevertableChange[string] // Octal mode string
	Exists     pkg.RevertableChange[bool]
	IsLnk      pkg.RevertableChange[bool]   // Whether the path is a symlink
	LinkTarget pkg.RevertableChange[string] // Target of the symlink, if IsLnk is true
	pkg.ModuleOutput
}

func (FileOutput) Changed

func (o FileOutput) Changed() bool

func (FileOutput) String

func (o FileOutput) String() string

type GitInput

type GitInput struct {
	Repo    string `yaml:"repo"`
	Dest    string `yaml:"dest"`
	Version string `yaml:"version"`
}

func (GitInput) GetVariableUsage

func (i GitInput) GetVariableUsage() []string

func (GitInput) HasRevert

func (i GitInput) HasRevert() bool

func (GitInput) ProvidesVariables

func (i GitInput) ProvidesVariables() []string

func (GitInput) ToCode

func (i GitInput) ToCode() string

func (GitInput) Validate

func (i GitInput) Validate() error

type GitModule

type GitModule struct{}

func (GitModule) CheckoutVersion

func (m GitModule) CheckoutVersion(dest, version string, c *pkg.HostContext, runAs string) (string, error)

func (GitModule) CloneRepo

func (m GitModule) CloneRepo(repo, dest string, c *pkg.HostContext, runAs string) error

func (GitModule) Execute

func (m GitModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

func (GitModule) GetCurrentRev

func (m GitModule) GetCurrentRev(dest string, c *pkg.HostContext, runAs string) (string, error)

func (GitModule) InputType

func (sm GitModule) InputType() reflect.Type

func (GitModule) OutputType

func (sm GitModule) OutputType() reflect.Type

func (GitModule) ParameterAliases

func (m GitModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for module parameters.

func (GitModule) Revert

func (m GitModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

type GitOutput

type GitOutput struct {
	Rev  pkg.RevertableChange[string]
	Dest string
	pkg.ModuleOutput
}

func (GitOutput) Changed

func (o GitOutput) Changed() bool

func (GitOutput) String

func (o GitOutput) String() string

type IncludeInput

type IncludeInput struct {
	Path string `yaml:"path"`
}

IncludeInput defines the structure for the 'include' directive parameters. It's used during preprocessing, not as a runtime module.

func (IncludeInput) GetVariableUsage

func (i IncludeInput) GetVariableUsage() []string

GetVariableUsage identifies variables used in the path, potentially for future templating.

func (IncludeInput) InputType

func (i IncludeInput) InputType() reflect.Type

InputType returns the type of IncludeInput, used for parsing.

func (IncludeInput) Validate

func (i IncludeInput) Validate() error

Validate checks if the required 'path' parameter is present.

type IncludeRoleInput

type IncludeRoleInput struct {
	Name string `yaml:"name"`
}

IncludeRoleInput defines the structure for the 'include_role' directive parameters. It's used during preprocessing, not as a runtime module.

func (IncludeRoleInput) GetVariableUsage

func (i IncludeRoleInput) GetVariableUsage() []string

GetVariableUsage identifies variables used in the role name.

func (IncludeRoleInput) InputType

func (i IncludeRoleInput) InputType() reflect.Type

InputType returns the type of IncludeRoleInput, used for parsing.

func (IncludeRoleInput) Validate

func (i IncludeRoleInput) Validate() error

Validate checks if the required 'name' parameter is present.

type LineinfileInput

type LineinfileInput struct {
	Path         string `yaml:"path"` // Aliases: dest, destfile, name
	Line         string `yaml:"line"`
	Regexp       string `yaml:"regexp"`
	State        string `yaml:"state,omitempty"`        // "present" or "absent", defaults to "present"
	Backrefs     bool   `yaml:"backrefs,omitempty"`     // Use backreferences from regexp in line
	Create       bool   `yaml:"create,omitempty"`       // Create the file if it doesn't exist
	InsertAfter  string `yaml:"insertafter,omitempty"`  // Regex, or "EOF"
	InsertBefore string `yaml:"insertbefore,omitempty"` // Regex, or "BOF"
	Mode         string `yaml:"mode,omitempty"`         // File mode if created
}

func (LineinfileInput) GetVariableUsage

func (i LineinfileInput) GetVariableUsage() []string

GetVariableUsage identifies variables used in templates.

func (LineinfileInput) HasRevert

func (i LineinfileInput) HasRevert() bool

HasRevert indicates that the lineinfile module can be reverted.

func (LineinfileInput) ProvidesVariables

func (i LineinfileInput) ProvidesVariables() []string

ProvidesVariables returns nil as lineinfile doesn't inherently define variables.

func (LineinfileInput) ToCode

func (i LineinfileInput) ToCode() string

ToCode generates the Go code representation of the input.

func (LineinfileInput) Validate

func (i LineinfileInput) Validate() error

Validate checks the input parameters for correctness.

type LineinfileModule

type LineinfileModule struct{}

func (LineinfileModule) Execute

func (lm LineinfileModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

func (LineinfileModule) InputType

func (lm LineinfileModule) InputType() reflect.Type

func (LineinfileModule) OutputType

func (lm LineinfileModule) OutputType() reflect.Type

func (LineinfileModule) ParameterAliases

func (lm LineinfileModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for module parameters.

func (LineinfileModule) Revert

func (lm LineinfileModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previousOutput pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

type LineinfileOutput

type LineinfileOutput struct {
	Msg                string                       `yaml:"msg"`
	Diff               pkg.RevertableChange[string] `yaml:"diff"` // For file content changes
	OriginalFileExists bool                         `yaml:"originalFileExists"`
	OriginalMode       string                       `yaml:"originalMode"`
	pkg.ModuleOutput
}

func (LineinfileOutput) Changed

func (o LineinfileOutput) Changed() bool

Changed indicates if the module made any changes.

func (LineinfileOutput) String

func (o LineinfileOutput) String() string

String provides a human-readable summary of the output.

type PacmanInput

type PacmanInput struct {
	Name  []string `yaml:"name"`
	State string   `yaml:"state"`
}

func (PacmanInput) GetVariableUsage

func (i PacmanInput) GetVariableUsage() []string

func (PacmanInput) HasRevert

func (i PacmanInput) HasRevert() bool

func (PacmanInput) ProvidesVariables

func (i PacmanInput) ProvidesVariables() []string

func (PacmanInput) ToCode

func (i PacmanInput) ToCode() string

func (PacmanInput) Validate

func (i PacmanInput) Validate() error

type PacmanModule

type PacmanModule struct{}

func (PacmanModule) Execute

func (m PacmanModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

func (PacmanModule) InputType

func (sm PacmanModule) InputType() reflect.Type

func (PacmanModule) InstallPackages

func (m PacmanModule) InstallPackages(packages []string, c *pkg.HostContext, runAs string) (PacmanOutput, error)

func (PacmanModule) IsPackageInstalled

func (m PacmanModule) IsPackageInstalled(packageName string, c *pkg.HostContext, runAs string) bool

func (PacmanModule) OutputType

func (sm PacmanModule) OutputType() reflect.Type

func (PacmanModule) ParameterAliases

func (m PacmanModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for module parameters.

func (PacmanModule) RemovePackages

func (m PacmanModule) RemovePackages(packages []string, c *pkg.HostContext, runAs string) (PacmanOutput, error)

func (PacmanModule) Revert

func (m PacmanModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

type PacmanOutput

type PacmanOutput struct {
	Installed []string
	Removed   []string
	Stdout    string
	Stderr    string
	pkg.ModuleOutput
}

func (PacmanOutput) Changed

func (o PacmanOutput) Changed() bool

func (PacmanOutput) String

func (o PacmanOutput) String() string

type SetFactInput

type SetFactInput struct {
	Facts map[string]interface{}
}

SetFactInput defines the structure for facts to be set. Using a map directly allows flexible key-value pairs.

func (SetFactInput) GetVariableUsage

func (i SetFactInput) GetVariableUsage() []string

GetVariableUsage extracts variables used within the fact values.

func (SetFactInput) HasRevert

func (i SetFactInput) HasRevert() bool

HasRevert indicates whether the input parameters define a revert action. For set_fact, revert is handled generically (no-op), so input doesn't define it.

func (SetFactInput) ProvidesVariables

func (i SetFactInput) ProvidesVariables() []string

ProvidesVariables returns the names of the facts being set.

func (SetFactInput) ToCode

func (i SetFactInput) ToCode() string

ToCode generates Go code representation of the SetFactInput.

func (*SetFactInput) UnmarshalYAML

func (i *SetFactInput) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML custom unmarshaler to handle direct map structure

func (SetFactInput) Validate

func (i SetFactInput) Validate() error

Validate ensures that there are facts to set.

type SetFactModule

type SetFactModule struct{}

SetFactModule implements the logic for setting facts.

func (SetFactModule) Execute

func (m SetFactModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

Execute sets the facts in the host context.

func (SetFactModule) InputType

func (m SetFactModule) InputType() reflect.Type

func (SetFactModule) OutputType

func (m SetFactModule) OutputType() reflect.Type

func (SetFactModule) ParameterAliases

func (m SetFactModule) ParameterAliases() map[string]string

ParameterAliases defines aliases if needed.

func (SetFactModule) Revert

func (m SetFactModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

Revert for set_fact is generally a no-op. Facts set are part of the context state. Undoing them would require tracking the previous state, which adds complexity. If a task fails, subsequent tasks won't see the facts set by the failed task anyway.

type SetFactOutput

type SetFactOutput struct {
	FactsSet map[string]interface{} // Record which facts were actually set/modified

}

SetFactOutput provides information about the facts that were set.

func (SetFactOutput) Changed

func (o SetFactOutput) Changed() bool

Changed indicates if any facts were added or modified.

func (SetFactOutput) String

func (o SetFactOutput) String() string

String provides a human-readable summary of the output.

type SetupInput

type SetupInput struct {
	Facts []string `yaml:"facts"`
}

func (SetupInput) GetVariableUsage

func (i SetupInput) GetVariableUsage() []string

func (SetupInput) HasRevert

func (i SetupInput) HasRevert() bool

func (SetupInput) ProvidesVariables

func (i SetupInput) ProvidesVariables() []string

func (SetupInput) ToCode

func (i SetupInput) ToCode() string

func (SetupInput) Validate

func (i SetupInput) Validate() error

type SetupModule

type SetupModule struct{}

func (SetupModule) Execute

func (m SetupModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

func (SetupModule) InputType

func (sm SetupModule) InputType() reflect.Type

func (SetupModule) OutputType

func (sm SetupModule) OutputType() reflect.Type

func (SetupModule) ParameterAliases

func (m SetupModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for module parameters.

func (SetupModule) Revert

func (m SetupModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

type SetupOutput

type SetupOutput struct {
	Facts map[string]interface{}
	pkg.ModuleOutput
}

func (SetupOutput) Changed

func (o SetupOutput) Changed() bool

func (SetupOutput) String

func (o SetupOutput) String() string

type ShellInput

type ShellInput struct {
	Execute string `yaml:"execute"`
	Revert  string `yaml:"revert"`
}

func (ShellInput) GetVariableUsage

func (i ShellInput) GetVariableUsage() []string

func (ShellInput) HasRevert

func (i ShellInput) HasRevert() bool

HasRevert checks if a revert command is defined.

func (ShellInput) ProvidesVariables

func (i ShellInput) ProvidesVariables() []string

ProvidesVariables returns nil as shell input doesn't inherently define variables.

func (ShellInput) ToCode

func (i ShellInput) ToCode() string

func (*ShellInput) UnmarshalYAML

func (i *ShellInput) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface for ShellInput. This remains important as Task.UnmarshalYAML will delegate decoding of the params node to this method if the input type is ShellInput. It allows the shell module value to be either a string (shorthand for execute) or a map with 'execute' and optionally 'revert' keys.

func (ShellInput) Validate

func (i ShellInput) Validate() error

type ShellModule

type ShellModule struct{}

func (ShellModule) Execute

func (m ShellModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

func (ShellModule) InputType

func (sm ShellModule) InputType() reflect.Type

func (ShellModule) OutputType

func (sm ShellModule) OutputType() reflect.Type

func (ShellModule) ParameterAliases

func (m ShellModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for module parameters.

func (ShellModule) Revert

func (m ShellModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

type ShellOutput

type ShellOutput struct {
	Stdout  string `yaml:"stdout"`
	Stderr  string `yaml:"stderr"`
	Command string `yaml:"command"`
	pkg.ModuleOutput
}

func (ShellOutput) AsFacts

func (o ShellOutput) AsFacts() map[string]interface{}

AsFacts implements the pkg.FactProvider interface. It returns a map representation suitable for registration, using lowercase keys for Ansible compatibility.

func (ShellOutput) Changed

func (o ShellOutput) Changed() bool

func (ShellOutput) String

func (o ShellOutput) String() string

type SlurpInput

type SlurpInput struct {
	Source string `yaml:"src"` // Path to the file to fetch from the remote node
}

SlurpInput defines the parameters for the slurp module.

func (SlurpInput) GetVariableUsage

func (i SlurpInput) GetVariableUsage() []string

GetVariableUsage extracts variables used within the source path.

func (SlurpInput) HasRevert

func (i SlurpInput) HasRevert() bool

HasRevert indicates that slurp does not have a revert action.

func (SlurpInput) ProvidesVariables

func (i SlurpInput) ProvidesVariables() []string

func (SlurpInput) ToCode

func (i SlurpInput) ToCode() string

ToCode generates the Go code representation of the SlurpInput.

func (*SlurpInput) UnmarshalYAML

func (i *SlurpInput) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML handles both shorthand (string) and map inputs for the slurp module.

func (SlurpInput) Validate

func (i SlurpInput) Validate() error

Validate checks if the required 'src' parameter is provided.

type SlurpModule

type SlurpModule struct{}

SlurpModule fetches a file from the remote host and stores its content.

func (SlurpModule) Execute

func (m SlurpModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

Execute runs the slurp operation on the remote host.

func (SlurpModule) InputType

func (m SlurpModule) InputType() reflect.Type

func (SlurpModule) OutputType

func (m SlurpModule) OutputType() reflect.Type

func (SlurpModule) ParameterAliases

func (m SlurpModule) ParameterAliases() map[string]string

ParameterAliases defines aliases if needed.

func (SlurpModule) Revert

func (m SlurpModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

Revert for slurp is a no-op as it only reads information.

type SlurpOutput

type SlurpOutput struct {
	Content      string `json:"content"`  // Base64 encoded content of the file
	Source       string `json:"source"`   // The source path provided
	Encoding     string `json:"encoding"` // The encoding of the content (always base64)
	ChangedState bool   `json:"changed"`  // Indicates whether the module changed the system state
	pkg.ModuleOutput
}

SlurpOutput holds the result of the slurp operation.

func (SlurpOutput) AsFacts

func (o SlurpOutput) AsFacts() map[string]interface{}

AsFacts provides the output data in a map suitable for registration.

func (SlurpOutput) Changed

func (o SlurpOutput) Changed() bool

Changed indicates whether the module changed the system state. Slurp is read-only.

func (SlurpOutput) String

func (o SlurpOutput) String() string

String provides a human-readable summary of the SlurpOutput.

type StatDetails

type StatDetails struct {
	Exists     bool    `json:"exists"`
	Path       string  `json:"path"`
	Mode       string  `json:"mode,omitempty"`
	UID        int     `json:"uid,omitempty"`
	GID        int     `json:"gid,omitempty"`
	Size       int64   `json:"size,omitempty"`
	IsLnk      bool    `json:"islnk,omitempty"`
	IsReg      bool    `json:"isreg,omitempty"`
	IsDir      bool    `json:"isdir,omitempty"`
	IsFifo     bool    `json:"isfifo,omitempty"`
	IsBlk      bool    `json:"isblk,omitempty"`
	IsChr      bool    `json:"ischr,omitempty"`
	IsSock     bool    `json:"issock,omitempty"`
	Atime      float64 `json:"atime,omitempty"`
	Mtime      float64 `json:"mtime,omitempty"`
	Ctime      float64 `json:"ctime,omitempty"`
	Checksum   string  `json:"checksum,omitempty"`
	Mime       string  `json:"mime,omitempty"`
	Attributes string  `json:"attributes,omitempty"`
	Device     uint64  `json:"dev,omitempty"`        // Device number
	Inode      uint64  `json:"inode,omitempty"`      // Inode number
	NLink      uint64  `json:"nlink,omitempty"`      // Number of hard links
	Rdev       uint64  `json:"rdev,omitempty"`       // Device number (if special file)
	Blocks     int64   `json:"blocks,omitempty"`     // Number of blocks allocated
	BlockSize  int64   `json:"block_size,omitempty"` // Block size
	Owner      string  `json:"owner,omitempty"`
	Group      string  `json:"group,omitempty"`
}

StatDetails holds the detailed stat information for a file. This struct is used within StatOutput.

type StatInput

type StatInput struct {
	Path              string `yaml:"path"`
	ChecksumAlgorithm string `yaml:"checksum_algorithm,omitempty"`
	Follow            bool   `yaml:"follow,omitempty"`
	GetAttributes     bool   `yaml:"get_attributes,omitempty"`
	GetChecksum       bool   `yaml:"get_checksum,omitempty"`
	GetMime           bool   `yaml:"get_mime,omitempty"`
}

func (StatInput) GetVariableUsage

func (i StatInput) GetVariableUsage() []string

func (StatInput) HasRevert

func (i StatInput) HasRevert() bool

func (StatInput) ProvidesVariables

func (i StatInput) ProvidesVariables() []string

func (StatInput) ToCode

func (i StatInput) ToCode() string

func (StatInput) Validate

func (i StatInput) Validate() error

type StatModule

type StatModule struct{}

func (StatModule) Execute

func (m StatModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

func (StatModule) InputType

func (sm StatModule) InputType() reflect.Type

func (StatModule) OutputType

func (sm StatModule) OutputType() reflect.Type

func (StatModule) ParameterAliases

func (m StatModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for module parameters.

func (StatModule) Revert

func (m StatModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

Stat module is read-only, so Revert does nothing.

type StatOutput

type StatOutput struct {
	Stat StatDetails `json:"stat"`
	pkg.ModuleOutput
}

func (StatOutput) Changed

func (o StatOutput) Changed() bool

Stat module never changes state

func (StatOutput) String

func (o StatOutput) String() string

type SystemdInput

type SystemdInput struct {
	Name         string `yaml:"name"`
	State        string `yaml:"state"`
	Enabled      bool   `yaml:"enabled"`
	DaemonReload bool   `yaml:"daemon_reload"`
}

func (SystemdInput) GetVariableUsage

func (i SystemdInput) GetVariableUsage() []string

func (SystemdInput) HasRevert

func (i SystemdInput) HasRevert() bool

func (SystemdInput) ProvidesVariables

func (i SystemdInput) ProvidesVariables() []string

func (SystemdInput) ToCode

func (i SystemdInput) ToCode() string

func (SystemdInput) Validate

func (i SystemdInput) Validate() error

type SystemdModule

type SystemdModule struct{}

func (SystemdModule) DaemonReload

func (m SystemdModule) DaemonReload(c *pkg.HostContext, runAs string) error

func (SystemdModule) Disable

func (m SystemdModule) Disable(name string, c *pkg.HostContext, runAs string) error

func (SystemdModule) Enable

func (m SystemdModule) Enable(name string, c *pkg.HostContext, runAs string) error

func (SystemdModule) Execute

func (m SystemdModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

func (SystemdModule) InputType

func (sm SystemdModule) InputType() reflect.Type

func (SystemdModule) OutputType

func (sm SystemdModule) OutputType() reflect.Type

func (SystemdModule) ParameterAliases

func (m SystemdModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for module parameters.

func (SystemdModule) Revert

func (m SystemdModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

func (SystemdModule) Start

func (m SystemdModule) Start(name string, c *pkg.HostContext, runAs string) error

func (SystemdModule) Stop

func (m SystemdModule) Stop(name string, c *pkg.HostContext, runAs string) error

type SystemdOutput

type SystemdOutput struct {
	State pkg.RevertableChange[SystemdState]
	pkg.ModuleOutput
}

func (SystemdOutput) Changed

func (o SystemdOutput) Changed() bool

func (SystemdOutput) String

func (o SystemdOutput) String() string

type SystemdState

type SystemdState struct {
	Enabled bool `yaml:"enabled"`
	Started bool `yaml:"started"`
}

func (SystemdState) Equal

func (s SystemdState) Equal(other SystemdState) bool

func (SystemdState) String

func (s SystemdState) String() string

type TemplateInput

type TemplateInput struct {
	Src  string `yaml:"src"`
	Dst  string `yaml:"dest"`
	Mode string `yaml:"mode"`
}

func (TemplateInput) GetVariableUsage

func (i TemplateInput) GetVariableUsage() []string

func (TemplateInput) HasRevert

func (i TemplateInput) HasRevert() bool

func (TemplateInput) ProvidesVariables

func (i TemplateInput) ProvidesVariables() []string

func (TemplateInput) ToCode

func (i TemplateInput) ToCode() string

func (TemplateInput) Validate

func (i TemplateInput) Validate() error

type TemplateModule

type TemplateModule struct{}

func (TemplateModule) Execute

func (m TemplateModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

func (TemplateModule) InputType

func (sm TemplateModule) InputType() reflect.Type

func (TemplateModule) OutputType

func (sm TemplateModule) OutputType() reflect.Type

func (TemplateModule) ParameterAliases

func (m TemplateModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for module parameters.

func (TemplateModule) Revert

func (m TemplateModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

type TemplateOutput

type TemplateOutput struct {
	Contents pkg.RevertableChange[string]
	// TODO: track if file was created
	pkg.ModuleOutput
}

func (TemplateOutput) Changed

func (o TemplateOutput) Changed() bool

func (TemplateOutput) String

func (o TemplateOutput) String() string

type YayInput

type YayInput struct {
	Name  []string `yaml:"name"`
	State string   `yaml:"state"`
}

func (YayInput) GetVariableUsage

func (i YayInput) GetVariableUsage() []string

func (YayInput) HasRevert

func (i YayInput) HasRevert() bool

func (YayInput) ProvidesVariables

func (i YayInput) ProvidesVariables() []string

func (YayInput) ToCode

func (i YayInput) ToCode() string

func (YayInput) Validate

func (i YayInput) Validate() error

type YayModule

type YayModule struct{}

func (YayModule) Execute

func (m YayModule) Execute(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, runAs string) (pkg.ModuleOutput, error)

func (YayModule) InputType

func (sm YayModule) InputType() reflect.Type

func (YayModule) InstallPackages

func (m YayModule) InstallPackages(packages []string, c *pkg.HostContext, runAs string) (YayOutput, error)

func (YayModule) OutputType

func (sm YayModule) OutputType() reflect.Type

func (YayModule) ParameterAliases

func (m YayModule) ParameterAliases() map[string]string

ParameterAliases defines aliases for module parameters.

func (YayModule) RemovePackages

func (m YayModule) RemovePackages(packages []string, c *pkg.HostContext, runAs string) (YayOutput, error)

func (YayModule) Revert

func (m YayModule) Revert(params pkg.ConcreteModuleInputProvider, closure *pkg.Closure, previous pkg.ModuleOutput, runAs string) (pkg.ModuleOutput, error)

type YayOutput

type YayOutput struct {
	Installed []string
	Removed   []string
	Stdout    string
	Stderr    string
	pkg.ModuleOutput
}

func (YayOutput) Changed

func (o YayOutput) Changed() bool

func (YayOutput) String

func (o YayOutput) String() string

Jump to

Keyboard shortcuts

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