facts

package module
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: BSD-3-Clause Imports: 7 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

facts

Fact gathering (the 'setup' module equivalent), pure Go CGO=0.

Part of go-ansible — a pure-Go (CGO=0), functional-parity port of Ansible.

CI Go Reference License

Usage

data, err := facts.Gather(ctx, conn) // conn: a github.com/go-remoteexec/transport.Connection

os := data["ansible_distribution"]     // e.g. "Ubuntu"
fam := data["ansible_os_family"]       // e.g. "Debian"

Gather collects the whole ansible_facts/ansible_* set in one shell round trip to the target — no Python setup module, no per-fact command.

Documentation

Overview

Package facts implements Ansible's `setup` module / gather_facts: probing a target for a portable subset of system facts (Ansible's own ansible_facts namespace) using only POSIX shell commands present on virtually every real target, no Python required.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gather

func Gather(ctx context.Context, conn remoteexec.Connection) (map[string]any, error)

Gather collects facts with real's defaults.

func GatherWith added in v0.13.0

func GatherWith(ctx context.Context, conn remoteexec.Connection, opts Options) (map[string]any, error)

GatherWith collects facts, honouring the setup module's arguments.

Types

type Options added in v0.13.0

type Options struct {
	// FactPath is real's fact_path: the directory of *.fact files
	// exposed as ansible_local. Empty means real's own default.
	FactPath string
}

Gather probes conn for a portable subset of Ansible's ansible_facts: system/kernel/architecture (uname), hostname/fqdn, distribution/ distribution_version/os_family (parsed /etc/os-release on Linux, sw_vers on macOS), date_time.epoch, processor_count, user_id, and pkg_mgr (the package manager available, for module dispatch).

The returned map's keys are bare (e.g. "system", not "ansible_system") — see vars.InjectFacts for the ansible_facts / ansible_<name> namespacing a caller applies on top. Options are the setup module's own knobs, as far as this port implements them.

Jump to

Keyboard shortcuts

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