Hosts
A host block names an SSH target. Other blocks reference its fields via host.<name>.<field>.
host "prod" {
addr = "root@192.0.2.10"
port = 22
}
host_block ::= "host" string "{" attr* "}"
The single label is the host's name and must be unique within the document. The body is a flat list of attributes; nested blocks are allowed but rare in practice.
Literal-only
Host blocks are evaluated in pass 1 with an empty scope. They cannot reference anything — not other hosts, not providers, not themselves. Any ref inside a host body errors with references not allowed inside host blocks.
host "prod" {
addr = host.staging.addr # error: hosts must be literal
}
Fields
There is no schema for host fields — anything you put in a host body is accessible by ref. The conventional fields used by the SSH and Docker providers are:
| field | type | notes |
|---|---|---|
addr | string | user@host form passed verbatim to the ssh binary. |
port | number | Currently unused by the providers; reserved for future use. |
In the providers shipped today, only addr is consumed; SSH connection options come from your ~/.ssh/config and ssh-agent. The port field is parsed but not yet wired through.
Multiple hosts
Declare as many as you need. Each one is independent.
host "prod" { addr = "root@192.0.2.10" }
host "staging" { addr = "root@5.6.7.8" }
resource "ssh_exec" "uptime_prod" {
host = host.prod.addr
command = "uptime"
}
resource "ssh_exec" "uptime_staging" {
host = host.staging.addr
command = "uptime"
}