class

Krikri::Host

Inherits Reference < Object

Represents a target host for automation

Constructors

from_json(json : JSON::Any) : Host

Create from JSON (for plugin communication). Uses the ? variants (as_s?/as_i?) rather than .try(&.as_s): try only guards against a missing key (Crystal nil), not a key present with a JSON null value - {"user": null}.try(&.as_s) still raises, since the JSON::Any itself is non-nil even though it wraps null. A host declared without an explicit user (e.g. localhost ansible_connection=local, with no ansible_user=) serializes exactly that way.

Source
new(name : String, user : String | Nil = nil, port : Int32 | Nil = nil)
Source

Instance methods

connection_host

The address the SSH/transport layer actually connects to — either ansible_host (if set in the inventory) or the inventory hostname. Used for display and connection routing throughout the codebase.

Source
from_add_host=(from_add_host : Bool)

True when the host entry came from an add_host: action (or was merged into one) rather than the static inventory. TaskExecutor's hostvars builder enriches such hosts' entries with the play magic variables Ansible exposes on every hostvars entry.

Source
from_add_host?

True when the host entry came from an add_host: action (or was merged into one) rather than the static inventory. TaskExecutor's hostvars builder enriches such hosts' entries with the play magic variables Ansible exposes on every hostvars entry.

Source
name
Source
name=(name : String)
Source
port

nil means "the user never specified a port" - not the same thing as port 22. Only an explicit ansible_port (inventory/CLI) sets this; when nil, SSHManager omits -p entirely so ssh's own resolution (~/.ssh/config Port directives, /etc/ssh/ssh_config) takes over, matching Ansible's ssh connection plugin. An explicit port still overrides ssh's config exactly as -p always has.

Source
port=(port : Int32 | Nil)

nil means "the user never specified a port" - not the same thing as port 22. Only an explicit ansible_port (inventory/CLI) sets this; when nil, SSHManager omits -p entirely so ssh's own resolution (~/.ssh/config Port directives, /etc/ssh/ssh_config) takes over, matching Ansible's ssh connection plugin. An explicit port still overrides ssh's config exactly as -p always has.

Source
user
Source
user=(user : String | Nil)
Source
var_origins

Where each of this host's inventory vars was defined - real ansible-core labels a name-template error inside an inventory value with the DEFINING INVENTORY LINE (no column; the excerpt's caret is a full-line run). Only inventory-sourced vars carry an entry; vars a host picks up elsewhere never consult this.

Source
var_origins=(var_origins : Hash(String, VarOrigin))

Where each of this host's inventory vars was defined - real ansible-core labels a name-template error inside an inventory value with the DEFINING INVENTORY LINE (no column; the excerpt's caret is a full-line run). Only inventory-sourced vars carry an entry; vars a host picks up elsewhere never consult this.

Source
vars
Source
vars=(vars : Hash(String, JSON::Any))
Source