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 ¶
- Variables
- func AsyncCheck(ctx context.Context, conn remoteexec.Connection, jid string) (found, done bool, rc int, stdout, stderr string, err error)
- func AsyncCleanup(ctx context.Context, conn remoteexec.Connection, jid string) error
- func AsyncLaunch(ctx context.Context, conn remoteexec.Connection, cmdLine string) (jid string, err error)
- func ComposeCommandLine(ctx context.Context, conn remoteexec.Connection, module string, ...) (cmdLine string, skip bool, skipMsg string, err error)
- func NormalizeName(name string) string
- type Func
- type Registry
- type Result
Constants ¶
This section is empty.
Variables ¶
var Docs = map[string]string{}/* 565 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 ¶
func AsyncCheck ¶ added in v0.19.0
func AsyncCheck(ctx context.Context, conn remoteexec.Connection, jid string) (found, done bool, rc int, stdout, stderr string, err error)
AsyncCheck reports a job's current status. found=false means no job directory exists at all for jid (a typo, or AsyncCleanup already ran) — distinct from done=false, which means the directory exists but the job is still running (or, indistinguishably, has not yet written its first byte of output — matching real Ansible's own async_status in that same ambiguous case). done=true gives rc/ stdout/stderr, fetched only then (not on every poll, to avoid hauling potentially large output over the wire while still waiting).
func AsyncCleanup ¶ added in v0.19.0
func AsyncCleanup(ctx context.Context, conn remoteexec.Connection, jid string) error
AsyncCleanup removes a job's directory entirely — async_status's mode=cleanup.
func AsyncLaunch ¶ added in v0.19.0
func AsyncLaunch(ctx context.Context, conn remoteexec.Connection, cmdLine string) (jid string, err error)
AsyncLaunch backgrounds cmdLine on conn's target under a fresh job ID, returning immediately without waiting for it to finish — the command keeps running independently of this call and of the connection itself (nohup traps SIGHUP, so it survives the connection closing), which is the entire point of async:.
A real, disclosed limitation: unlike real Ansible's own async wrapper (which forks/setpgids the job so it can SIGKILL the whole process group if async: 's time limit is exceeded), this does NOT actively kill a job that overruns its time limit — there is no portable POSIX shell equivalent to killpg across every target shell this might run against without a dependency (setsid, part of util-linux) that real targets (macOS/BSD in particular) do not ship by default. AsyncCheck (see below) still enforces the time limit on the CONTROLLER side (a poll loop gives up and reports a timeout failure once the limit passes), it just doesn't reach out and stop the job itself the way real Ansible's wrapper does.
func ComposeCommandLine ¶ added in v0.19.0
func ComposeCommandLine(ctx context.Context, conn remoteexec.Connection, module string, args map[string]any) (cmdLine string, skip bool, skipMsg string, err error)
ComposeCommandLine composes the exact shell command line the "command" or "shell" module would execute for args (argv-quoting/ chdir handling included), running the real creates/removes short-circuit check against conn but WITHOUT executing the command itself — skip=true means the command should not run at all (skipMsg explains why, matching what a synchronous run would return via Ok(msg) instead of actually running anything).
Exported for go-ansible/playbook's async: task launcher: command and shell are the only two modules whose entire job reduces to one remote command, and so the only two this port can genuinely background on the target the way async requires — the launcher needs the exact command a synchronous run would use, to wrap it instead of running it directly.
func NormalizeName ¶ added in v0.18.0
NormalizeName strips a known collection prefix from an FQCN module or playbook-directive reference, returning name unchanged if it carries none of them.
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) Get ¶
Get looks up a module by name. A fully-qualified collection name (FQCN) — "ansible.builtin.copy", "community.general.ufw" — resolves to the same entry as the bare name ("copy", "ufw") once the known collection prefix is stripped; see NormalizeName. This is a deliberate simplification, not full collection-scoped resolution: this registry is a single flat namespace (matching how this port's module set has no real cross-collection name collisions to disambiguate), so an FQCN with the WRONG collection prefix for a given module (e.g. "ansible.builtin.ufw", when ufw is actually community.general's) still resolves — real Ansible would instead fail "couldn't resolve module" in that case. In practice this only diverges from real Ansible on a playbook that already has an incorrect FQCN, which would already be broken there too.
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
- aerospike_migrations.go
- airbrake_deployment.go
- aix_devices.go
- aix_filesystem.go
- aix_inittab.go
- aix_lvg.go
- aix_lvol.go
- alerta_customer.go
- ali_common.go
- ali_instance.go
- ali_instance_info.go
- alternatives.go
- android_sdk.go
- ansible_galaxy_install.go
- apache2_mod_proxy.go
- apache2_module.go
- apk.go
- apt.go
- apt_key.go
- apt_repo.go
- apt_repository.go
- apt_rpm.go
- archive.go
- args.go
- assemble.go
- async.go
- async_status.go
- at.go
- authorized_key.go
- awall.go
- beadm.go
- blockinfile.go
- bootc_manage.go
- bower.go
- btrfs_info.go
- btrfs_subvolume.go
- bundler.go
- bzr.go
- capabilities.go
- cargo.go
- circonus_annotation.go
- cloud_init_data_facts.go
- cloudflare_dns.go
- cobbler_sync.go
- cobbler_system.go
- command.go
- composer.go
- consul.go
- consul_acl.go
- consul_acl_bootstrap.go
- consul_agent_check.go
- consul_agent_service.go
- consul_auth_method.go
- consul_binding_rule.go
- consul_kv.go
- consul_kv_info.go
- consul_policy.go
- consul_role.go
- consul_session.go
- consul_token.go
- copr.go
- copy.go
- cpanm.go
- cron.go
- cronvar.go
- crypttab.go
- dconf.go
- deb822_repository.go
- debconf.go
- debug.go
- decompress.go
- deploy_helper.go
- django_check.go
- django_command.go
- django_createcachetable.go
- django_dumpdata.go
- django_loaddata.go
- django_manage.go
- dnf.go
- dnf5.go
- dnf_config_manager.go
- dnf_versionlock.go
- dnsimple.go
- dnsimple_common.go
- dnsimple_info.go
- docs_generated.go
- dpkg_divert.go
- dpkg_selections.go
- easy_install.go
- ejabberd_user.go
- elasticsearch_plugin.go
- emc_vnx_sg_member.go
- etcd3.go
- exec.go
- expect.go
- facter_facts.go
- fetch.go
- file.go
- file_remove.go
- filesize.go
- filesystem.go
- find.go
- firewalld.go
- firewalld_info.go
- flatpak.go
- flatpak_remote.go
- gather_facts.go
- gconftool2.go
- gconftool2_info.go
- gem.go
- get_url.go
- getent.go
- gio_mime.go
- git.go
- git_config.go
- git_config_info.go
- github_common.go
- github_deploy_key.go
- github_issue.go
- github_key.go
- github_release.go
- github_repo.go
- github_secrets.go
- github_secrets_info.go
- github_webhook.go
- github_webhook_info.go
- gitlab_branch.go
- gitlab_common.go
- gitlab_dedicated_common.go
- gitlab_deploy_key.go
- gitlab_group.go
- gitlab_group_access_token.go
- gitlab_group_members.go
- gitlab_group_variable.go
- gitlab_hook.go
- gitlab_instance_variable.go
- gitlab_issue.go
- gitlab_label.go
- gitlab_merge_request.go
- gitlab_milestone.go
- gitlab_project.go
- gitlab_project_access_token.go
- gitlab_project_approvals.go
- gitlab_project_badge.go
- gitlab_project_members.go
- gitlab_project_variable.go
- gitlab_protected_branch.go
- gitlab_runner.go
- gitlab_user.go
- golang_package.go
- group.go
- gunicorn.go
- haproxy.go
- heroku_collaborator.go
- hg.go
- homebrew.go
- homebrew_cask.go
- homebrew_services.go
- homebrew_tap.go
- homectl.go
- honeybadger_deployment.go
- hostname.go
- hpilo_boot.go
- hpilo_common.go
- hpilo_info.go
- hponcfg.go
- htpasswd.go
- hwc_common.go
- hwc_ecs_instance.go
- hwc_evs_disk.go
- hwc_network_vpc.go
- hwc_smn_topic.go
- hwc_vpc_eip.go
- hwc_vpc_peering_connect.go
- hwc_vpc_port.go
- hwc_vpc_private_ip.go
- hwc_vpc_route.go
- hwc_vpc_security_group.go
- hwc_vpc_security_group_rule.go
- hwc_vpc_subnet.go
- ibm_sa_common.go
- ibm_sa_domain.go
- ibm_sa_host.go
- ibm_sa_host_ports.go
- ibm_sa_pool.go
- ibm_sa_vol.go
- ibm_sa_vol_map.go
- icinga2_downtime.go
- icinga2_feature.go
- icinga2_host.go
- idrac_common.go
- idrac_redfish_command.go
- idrac_redfish_config.go
- idrac_redfish_info.go
- ilo_common.go
- ilo_redfish_command.go
- ilo_redfish_config.go
- ilo_redfish_info.go
- imgadm.go
- infinity.go
- influxdb_database.go
- influxdb_query.go
- influxdb_retention_policy.go
- influxdb_user.go
- influxdb_write.go
- ini_file.go
- installp.go
- interfaces_file.go
- ip2location_info.go
- ip_netns.go
- ipa_common.go
- ipa_config.go
- ipa_dnsrecord.go
- ipa_dnszone.go
- ipa_getkeytab.go
- ipa_group.go
- ipa_hbacrule.go
- ipa_host.go
- ipa_hostgroup.go
- ipa_otpconfig.go
- ipa_otptoken.go
- ipa_pwpolicy.go
- ipa_role.go
- ipa_service.go
- ipa_subca.go
- ipa_sudocmd.go
- ipa_sudocmdgroup.go
- ipa_sudorule.go
- ipa_user.go
- ipa_vault.go
- ipinfoio_facts.go
- ipmi_boot.go
- ipmi_power.go
- iptables.go
- iptables_state.go
- ipwcli_dns.go
- iso_create.go
- iso_customize.go
- iso_extract.go
- java_cert.go
- java_keystore.go
- jboss.go
- jenkins_build.go
- jenkins_build_info.go
- jenkins_common.go
- jenkins_credential.go
- jenkins_job.go
- jenkins_job_info.go
- jenkins_node.go
- jenkins_plugin.go
- jenkins_script.go
- jira.go
- kdeconfig.go
- kea_command.go
- kernel_blacklist.go
- keycloak_authentication.go
- keycloak_authentication_required_actions.go
- keycloak_authentication_v2.go
- keycloak_authz_authorization_scope.go
- keycloak_authz_custom_policy.go
- keycloak_authz_permission.go
- keycloak_authz_permission_info.go
- keycloak_client.go
- keycloak_client_rolemapping.go
- keycloak_client_rolescope.go
- keycloak_clientscope.go
- keycloak_clientscope_rolemappings.go
- keycloak_clientscope_type.go
- keycloak_clientsecret_info.go
- keycloak_clientsecret_regenerate.go
- keycloak_clienttemplate.go
- keycloak_common.go
- keycloak_component.go
- keycloak_component_info.go
- keycloak_group.go
- keycloak_identity_provider.go
- keycloak_json_helpers.go
- keycloak_realm.go
- keycloak_realm_info.go
- keycloak_realm_key.go
- keycloak_realm_keys_metadata_info.go
- keycloak_realm_localization.go
- keycloak_realm_rolemapping.go
- keycloak_realm_users_info.go
- keycloak_role.go
- keycloak_user.go
- keycloak_user_execute_actions_email.go
- keycloak_user_federation.go
- keycloak_user_rolemapping.go
- keycloak_userprofile.go
- keyring.go
- keyring_info.go
- kibana_plugin.go
- known_hosts.go
- kopia_repository.go
- kopia_repository_info.go
- krb_ticket.go
- launchd.go
- layman.go
- lbu.go
- ldap_attrs.go
- ldap_common.go
- ldap_entry.go
- ldap_inc.go
- ldap_passwd.go
- ldap_search.go
- lineinfile.go
- linode.go
- linode_v4.go
- listen_ports_facts.go
- lldp_facts.go
- locale_gen.go
- logrotate.go
- logstash_plugin.go
- lvg.go
- lvg_rename.go
- lvm_pv.go
- lvm_pv_move_data.go
- lvol.go
- lxc_container.go
- lxd_container.go
- lxd_profile.go
- lxd_project.go
- lxd_storage_pool_info.go
- lxd_storage_volume_info.go
- macports.go
- mail.go
- make.go
- mas.go
- mattermost.go
- maven_artifact.go
- memset_common.go
- memset_dns_reload.go
- memset_memstore_info.go
- memset_server_info.go
- memset_zone.go
- memset_zone_domain.go
- memset_zone_record.go
- mksysb.go
- modprobe.go
- module.go
- monit.go
- mount.go
- mount_facts.go
- mqtt.go
- mssql_db.go
- mssql_script.go
- nagios.go
- newrelic_deployment.go
- nginx_status_info.go
- nictagadm.go
- nmcli.go
- nomad_job.go
- nomad_job_info.go
- nomad_token.go
- nosh.go
- npm.go
- nsupdate.go
- odbc.go
- ohai.go
- omapi_host.go
- one_common.go
- one_host.go
- one_image.go
- one_image_info.go
- one_service.go
- one_template.go
- one_vm.go
- one_vnet.go
- onepassword_info.go
- open_iscsi.go
- openbsd_pkg.go
- opendj_backendprop.go
- openwrt_init.go
- opkg.go
- osx_defaults.go
- ovh_common.go
- ovh_ip_failover.go
- ovh_ip_loadbalancing_backend.go
- ovh_monthly_billing.go
- pacemaker_cluster.go
- pacemaker_info.go
- pacemaker_resource.go
- pacemaker_stonith.go
- package.go
- package_facts.go
- packet_common.go
- packet_device.go
- packet_ip_subnet.go
- packet_project.go
- packet_sshkey.go
- packet_volume.go
- packet_volume_attachment.go
- pacman.go
- pacman_key.go
- pam_limits.go
- pamd.go
- parted.go
- patch.go
- pause.go
- pear.go
- pids.go
- ping.go
- pip.go
- pip_package_info.go
- pipx.go
- pipx_info.go
- pkg5.go
- pkg5_publisher.go
- pkgin.go
- pkgmgr.go
- pkgng.go
- pkgutil.go
- pmem.go
- pnpm.go
- portage.go
- portinstall.go
- pritunl_common.go
- pritunl_org.go
- pritunl_org_info.go
- pritunl_user.go
- pritunl_user_info.go
- pulp_repo.go
- puppet.go
- python_requirements_info.go
- raw.go
- read_csv.go
- reboot.go
- redfish_command.go
- redfish_common.go
- redfish_config.go
- redfishtool_common.go
- redhat_subscription.go
- redis.go
- redis_data.go
- redis_data_incr.go
- redis_data_info.go
- redis_info.go
- registry.go
- replace.go
- rhel_facts.go
- rhel_rpm_ostree.go
- rhsm_release.go
- rhsm_repository.go
- riak.go
- rollbar_deployment.go
- rpm_key.go
- rpm_ostree_pkg.go
- rpm_ostree_upgrade.go
- rundeck_acl_policy.go
- rundeck_common.go
- rundeck_job_executions_info.go
- rundeck_job_run.go
- rundeck_project.go
- runit.go
- say.go
- scaleway_common.go
- scaleway_compute.go
- scaleway_compute_private_network.go
- scaleway_container.go
- scaleway_container_info.go
- scaleway_container_namespace.go
- scaleway_container_namespace_info.go
- scaleway_container_registry.go
- scaleway_container_registry_info.go
- scaleway_database_backup.go
- scaleway_function.go
- scaleway_function_info.go
- scaleway_function_namespace.go
- scaleway_function_namespace_info.go
- scaleway_image_info.go
- scaleway_ip.go
- scaleway_ip_info.go
- scaleway_lb.go
- scaleway_organization_info.go
- scaleway_private_network.go
- scaleway_security_group.go
- scaleway_security_group_info.go
- scaleway_security_group_rule.go
- scaleway_server_info.go
- scaleway_snapshot_info.go
- scaleway_sshkey.go
- scaleway_user_data.go
- scaleway_volume.go
- scaleway_volume_info.go
- script.go
- seboolean.go
- sefcontext.go
- selinux.go
- selinux_permissive.go
- selogin.go
- sendgrid.go
- seport.go
- serverless.go
- service_facts.go
- set_stats.go
- setfact.go
- setup.go
- shellquote.go
- shutdown.go
- simpleinit_msb.go
- sl_vm.go
- slackpkg.go
- slurp.go
- smartos_image_info.go
- snap.go
- snap_alias.go
- snap_connect.go
- snmp_facts.go
- solaris_zone.go
- sorcery.go
- spectrum_common.go
- spectrum_device.go
- spectrum_model_attrs.go
- ss_3par_cpg.go
- ssh_config.go
- sssd_info.go
- stacki_host.go
- stat.go
- statsd.go
- subversion.go
- sudoers.go
- supervisorctl.go
- svc.go
- svr4pkg.go
- swdepot.go
- swupd.go
- synchronize.go
- sysctl.go
- syslogger.go
- syspatch.go
- sysrc.go
- systemd.go
- systemd_creds_decrypt.go
- systemd_creds_encrypt.go
- systemd_info.go
- sysupgrade.go
- sysvinit.go
- tempfile.go
- template.go
- terraform.go
- timezone.go
- twilio.go
- udm_common.go
- udm_dns_record.go
- udm_dns_zone.go
- udm_group.go
- udm_share.go
- udm_user.go
- ufw.go
- unarchive.go
- uptimerobot.go
- uri.go
- urpmi.go
- usb_facts.go
- user.go
- uv_python.go
- validate_argument_spec.go
- vdo.go
- vertica.go
- vertica_configuration.go
- vertica_info.go
- vertica_role.go
- vertica_schema.go
- vertica_user.go
- vmadm.go
- wait_for.go
- wait_for_connection.go
- wakeonlan.go
- write_binary_file.go
- xattr.go
- xbps.go
- xcc_redfish_command.go
- xdg_mime.go
- xenserver_common.go
- xenserver_facts.go
- xenserver_guest.go
- xenserver_guest_info.go
- xenserver_guest_powerstate.go
- xfconf.go
- xfconf_info.go
- xfs_quota.go
- xml.go
- xml_info.go
- yarn.go
- yum_repository.go
- yum_versionlock.go
- zfs.go
- zfs_delegate_admin.go
- zfs_facts.go
- znode.go
- zpool.go
- zpool_facts.go
- zypper.go
- zypper_repository.go
- zypper_repository_info.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. |