Documentation
¶
Overview ¶
Package modules implements Ansible's module execution model: each module is a Go function that takes a target connection (github.com/go-remoteexec/transport) and a set of arguments (already Jinja2-rendered by the caller) and returns a Result — Ansible's changed/failed/msg triple plus any module-specific fields.
Unlike real Ansible, which copies a Python script to the target and runs it there, a module here runs its logic on the control node and reaches the target only through the Connection's Exec/Put/Fetch primitives. The observable behavior is the same (the target ends up in the same state); the difference is architectural, not behavioral, and it means a module needs no Go toolchain on the target.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Docs = map[string]string{}/* 126 elements not displayed */
Docs maps every registered module name to its Go doc comment — the same argument/deviation documentation this project has always written on each module<Name> function, extracted once at build time so ansible-doc can print it without the source tree present.
Functions ¶
This section is empty.
Types ¶
type Func ¶
type Func func(ctx context.Context, conn remoteexec.Connection, args map[string]any) (Result, error)
Func is a module's entry point. ctx carries cancellation/timeout; conn is already connected to the task's target; args is the task's parameters, already Jinja2-rendered by the caller (this package never templates anything itself). A non-nil error means the module could not determine an outcome at all (a transport failure); an expected failure is a Result with Failed=true and a nil error.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps module names to their Func.
func Default ¶
func Default() *Registry
Default returns a Registry pre-populated with this package's built-in module set.
func (*Registry) Register ¶
Register adds fn under name, replacing any existing module of the same name (so a caller can override a built-in with a custom module).
func (*Registry) Run ¶
func (r *Registry) Run(ctx context.Context, name string, conn remoteexec.Connection, args map[string]any) (Result, error)
Run looks up name and runs it, returning a Result{Failed:true} (not a Go error) for an unknown module name — matching Ansible's own "couldn't resolve module" being a task failure, not a crash.
type Result ¶
type Result struct {
Changed bool
Failed bool
Msg string
Facts map[string]any
Extra map[string]any
}
Result is a module's outcome: Ansible's changed/failed/msg triple, plus optional facts (merged into ansible_facts, e.g. by set_fact) and module-specific extra fields (e.g. command's stdout/stderr/rc).
func Fail ¶
Fail returns a failed result. Modules normally return this alongside a non-nil error only when the failure is unexpected (a connection error, an unreadable file); an expected, well-formed failure (e.g. the `fail` module itself, or `assert` on a false condition) returns it with a nil error, since it is not the module's own execution that went wrong.
Source Files
¶
- acl.go
- alternatives.go
- apk.go
- apt.go
- apt_key.go
- apt_repository.go
- archive.go
- args.go
- assemble.go
- async_status.go
- at.go
- authorized_key.go
- blockinfile.go
- bundler.go
- capabilities.go
- cargo.go
- command.go
- composer.go
- copy.go
- cpanm.go
- cron.go
- cronvar.go
- crypttab.go
- deb822_repository.go
- debconf.go
- debug.go
- decompress.go
- django_command.go
- django_manage.go
- dnf.go
- dnf5.go
- docs_generated.go
- dpkg_selections.go
- exec.go
- expect.go
- fetch.go
- file.go
- filesize.go
- find.go
- firewalld.go
- firewalld_info.go
- flatpak.go
- flatpak_remote.go
- gather_facts.go
- gem.go
- get_url.go
- getent.go
- git.go
- git_config.go
- golang_package.go
- group.go
- homebrew.go
- homebrew_cask.go
- homebrew_services.go
- homebrew_tap.go
- hostname.go
- htpasswd.go
- ini_file.go
- iptables.go
- java_cert.go
- kernel_blacklist.go
- known_hosts.go
- lineinfile.go
- locale_gen.go
- logrotate.go
- mail.go
- maven_artifact.go
- modprobe.go
- module.go
- mount.go
- mount_facts.go
- npm.go
- opkg.go
- package.go
- package_facts.go
- pacman.go
- pacman_key.go
- pam_limits.go
- pamd.go
- patch.go
- pause.go
- pear.go
- ping.go
- pip.go
- pkgmgr.go
- pnpm.go
- raw.go
- read_csv.go
- reboot.go
- registry.go
- replace.go
- rhel_facts.go
- rhel_rpm_ostree.go
- rpm_key.go
- rpm_ostree_upgrade.go
- script.go
- seboolean.go
- selinux.go
- service_facts.go
- set_stats.go
- setfact.go
- setup.go
- shellquote.go
- slurp.go
- snap.go
- snap_alias.go
- ssh_config.go
- stat.go
- subversion.go
- sudoers.go
- supervisorctl.go
- synchronize.go
- sysctl.go
- systemd.go
- sysvinit.go
- tempfile.go
- template.go
- timezone.go
- unarchive.go
- uri.go
- user.go
- validate_argument_spec.go
- wait_for.go
- wait_for_connection.go
- xattr.go
- xml.go
- yarn.go
- yum_repository.go
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
gendocs
command
Command gendocs extracts each registered module's Go doc comment (already written on its module<Name> function — this project's convention has always been to document arguments and every deviation from real Ansible's behavior there) and emits docs_generated.go: a map from the module's registered name to that comment text, for ansible-doc to print without needing the source tree at runtime.
|
Command gendocs extracts each registered module's Go doc comment (already written on its module<Name> function — this project's convention has always been to document arguments and every deviation from real Ansible's behavior there) and emits docs_generated.go: a map from the module's registered name to that comment text, for ansible-doc to print without needing the source tree at runtime. |