salt.runners.topology#
Topology operator commands.
Exposed via salt-run topology.<command>. Read-mostly; the one
mutation (trust()) is a thin wrapper over salt-key --master
semantics for convenience in automation workflows that would
otherwise shell out to the key CLI.
All read commands degrade gracefully to on-disk state when the
publish daemon's salt.topology.link_manager module is not
live in this process (which is the typical case: runners run from
a short-lived salt.runner.RunnerClient process that does
not share module-level state with the master's publish daemon).
The resting state consulted here is:
<pki_dir>/masters/--- accepted peers<pki_dir>/masters_pre/--- pending peers<pki_dir>/masters_rejected/--- rejected peers<pki_dir>/master/topology_registry.mmap*--- registry cache<pki_dir>/master/topology_breadcrumbs.mmap*--- breadcrumbs cacheopts["topology_peers"]--- configured seed peers
Any of these may be absent on a fresh master; absence is treated as empty rather than as an error.
Terminology note#
cluster_id fields in this runner's output name a peer master's
external identity. Solo masters and clustered masters show up
the same way in topology.peers output; the cluster_id
column is the opts-key name of the identity, not a claim that
the peer runs as a multi-master cluster.
- salt.runners.topology.find(minion_id, timeout=10)#
On-demand lookup: ask every reachable cluster whether it has an accepted key for
minion_id.Without a live outbound-link set in this process (the common case: runners run in a short-lived
RunnerClientsubprocess that does not share the publish daemon's module globals), falls back to a local-only lookup against this master's accepted minion keys. Returns the same shape either way so callers do not need to special-case either path.- Parameters:
minion_id -- Minion id to locate.
timeout -- Deadline in seconds.
0short-circuits and returns an empty dict without consulting any state.
- Returns:
{cluster_path: minion_id_as_known_locally}.
- salt.runners.topology.graph(fmt='text')#
Render the known topology graph.
- Parameters:
fmt -- One of
text(default, indented tree-ish),dot(Graphviz source), orjson({"nodes": [...], "edges": [...]}).- Returns:
A string for text/dot, a dict for json, or an
{"error": ...}dict for unknown formats.
- salt.runners.topology.links()#
Return detailed health + metadata for every known peer link.
Fields per entry:
peer_cluster_idhealthendpointslast_summary_atbreadcrumbs_active
Live-link health is taken from the in-process
salt.topology.link_managerwhen it is active in the current process; when the runner runs in a RunnerClient subprocess (the usual case), health is derived from on-disk state:"connected"— peer has a registry entry (summary gossip received at least once); this is the strongest confirmation the runner can make without an IPC query."attached"— peer's identity key is accepted inmasters/but no summary has been ingested yet. Matches thepeers()label for the same state.absent — peer key is in
masters_pre/ormasters_rejected/only.
Note:
"disconnected"is reserved for future use when a persistedLinkHealthsentinel tracks genuine transport-level failure (a known follow-up).
- salt.runners.topology.peers()#
Return the list of peer references, each with its current state:
configured--- intopology.confbut not yet seen on any key path.pending--- key is inmasters_pre/.attached--- key is inmasters/and the publish daemon's outbound link is CONNECTED with no recent fault.attached-degraded--- key accepted, but the outbound link's REQ channel was torn down after a send fault and is awaiting re-handshake by the periodic sweeper.attached-wedged--- key accepted, link reports CONNECTED, but the most recent send failed more recently than the most recent success. Operator should expectsend_publish ok peer=...to recover shortly; if not, investigate the receiver.attached-disconnected--- key accepted but outbound link has not been reconnected since startup.rejected--- key is inmasters_rejected/.
Each entry has
{"cluster_id": ..., "state": ...}and, for configured-only entries,{"host": ..., "port": ...}fields identifying the seed endpoint. When a health snapshot is available (publish daemon has written one for this peer), the entry also carriessession_generation,send_fault_count,last_send_fault_at, andlast_send_success_atso operators see the "attached-per-runner but dead-per-forwards" asymmetry without having to grep the master log.
- salt.runners.topology.status()#
Return a tree-shaped summary of the reachable topology graph.
Shape:
{ "cluster_id": "<local>", "minion_count": N, "up_count": N, "peers": [ { "cluster_id": "<peer>", "state": "attached" | "pending" | ..., "minion_count": N, "up_count": N, "last_summary_at": <unix ts> | None, }, ... ], }
Peers in the registry carry minion counts from the most recent summary this master received from them; peers whose state is on-disk only (pending / configured) carry zeroes.
- salt.runners.topology.trust(cluster_id, action)#
Thin wrapper over
salt-key --mastersemantics.- Parameters:
cluster_id -- Peer cluster to act on.
action -- One of
accept,reject,delete,fingerprint.
- Returns:
{"cluster_id": ..., "state": ...}for state-changing actions,{"cluster_id": ..., "fingerprint": ...}forfingerprint, or{"error": ...}on invalid input.