Node Inventory
A node inventory is a named list of SSH hosts with labels. Workflows select hosts by label instead of naming them, and Dagu connects to each host over SSH. Workers whose ID is a valid node name are nodes too.
This page covers how nodes are defined and managed. To run steps on them, see Node Targeting.
INFO
Node inventories require Dagu 2.28.0 or later.
Inventories
An inventory is one JSON record: a name, a description, defaults that its nodes share, and its nodes.
{
"name": "Tokyo production",
"description": "Racks A and B",
"defaults": {
"user": "deploy",
"key": { "secret": "ssh/tokyo" },
"labels": ["site=tokyo", "env=prod"]
},
"nodes": [
{ "name": "tokyo-web01", "host": "10.0.1.11", "labels": ["web"] },
{ "name": "tokyo-web02", "host": "10.0.1.12", "labels": ["web", "canary"] },
{ "name": "tokyo-db01", "host": "db01.internal", "port": 2222, "bastion": "tokyo-jump", "labels": ["db"] },
{ "name": "tokyo-jump", "host": "jump.tokyo.example.com" }
]
}| Field | Meaning |
|---|---|
name | Display name, 1 to 200 characters, not blank. Unique among inventories, compared without case |
description | Text |
defaults | Node fields from port through timeout, and labels, applied to the inventory's nodes |
nodes | The inventory's nodes |
Dagu gives each inventory an ID when it is created: inv_ and 10 lowercase letters or digits. The ID never changes. A record with an unknown field is an error.
Every change is checked against every rule and against the other inventories. A change that breaks a rule stores nothing.
Node Fields
| Field | Default | Meaning |
|---|---|---|
name | Required | Node name |
host | Required | Host name or IP address |
port | 22 | SSH port, 1 to 65535 |
user | - | SSH user |
key | - | Private key: a path, { "file": <path> }, or { "secret": <ref> } |
password | - | Password: { "secret": <ref> } only |
passphrase | - | Passphrase of an encrypted key: { "secret": <ref> } only |
bastion | - | Name of another node of the same inventory to connect through |
host_key | - | Pinned public key, in authorized_keys form such as ssh-ed25519 AAAA… |
strict_host_key | true | Check the host key. See Host Keys |
shell | - | Remote shell |
timeout | 30s | Connect timeout, a positive duration such as 10s or 1m30s |
labels | - | Labels, as key or key=value |
description | - | Text |
disabled | false | true keeps runs off the node |
Rules:
- A node name is a letter or digit, followed by letters, digits,
-,_, or., at most 200 characters. Names are unique across all inventories, compared without case. hostis a DNS name, an IPv4 address, or an IPv6 address without a zone.useris a letter, digit, or_, followed by letters, digits,.,_, or-.- Labels follow the rules of DAG labels. Keys and values are lowercased.
- A bastion names a node of the same inventory exactly as written. A node is never its own bastion. A bastion connects directly, so a node that connects through a bastion cannot be one.
Defaults
A default fills a field that a node leaves unset.
defaults.labelsare added to each node's labels. A node's label replaces a default label with the same key.- A node that sets
keytakes nopassphrasefromdefaults, since a passphrase belongs to the key it unlocks. - A default
bastiondoes not apply to the node it names.
To label every node of an inventory, put the label in defaults.labels.
Disabled Nodes
"disabled": true keeps runs off a node. A disabled node is still listed, matched by selectors, and tested. A step skips it, and a run bound to it fails before any step.
Credentials
An inventory never holds a secret value.
keytakes a path,{ "file": <path> }, or{ "secret": <ref> }.passwordandpassphrasetake only{ "secret": <ref> }. Given as text, they are an error.<ref>names a Dagu-managed secret, such asssh/deploy-key. Store a private key with its line breaks; see Storing a Private Key.
The CLI, the API, the Nodes page, and exports show credentials as key paths and secret refs, never as values.
A run resolves its node's credentials once, before its first step, when any of its steps connects to the node. The values join the run's masking. A run whose steps never connect resolves none. A ref that does not resolve fails the run before any step, naming the field and the ref.
Host Keys
With strict_host_key on, the default, a node accepts only the key in its host_key or the key trusted for it. known_hosts files do not apply to inventory nodes. With strict_host_key: false, a node accepts any key.
- Dagu trusts at most one key per node, kept by node name.
- Trusted keys are not part of an inventory, so they are never exported or imported.
- A run never trusts a key. Trust keys with
dagu nodes test,dagu nodes add, the Nodes page, or the API. - A key that is unknown or has changed stops the connection before any credential reaches that host.
A trusted key belongs to a node name. Removing or renaming a node forgets the key trusted for that name, and a new node starts with none. A node that keeps its name keeps its key, even when its host changes. Imports and edits follow the same rule.
Test Connections
A test checks the host key of each hop, authenticates with the node's credentials, and runs true. The test itself never trusts a key.
dagu nodes test --labels webThe command prints one line per node as its test ends: <name> passed <fingerprint> <time> or <name> failed <error>. When tests stop at keys it can trust, it lists them and asks:
Unknown host keys:, thenTrust these host keys?Changed host keys:, each with the trusted and presented fingerprints, thenReplace the trusted host keys?
Each question is asked once for all the keys it lists. Any answer but yes trusts nothing. On yes, the command trusts the keys and tests the stopped nodes again. A node behind a bastion with an unknown key is asked about twice: for the bastion, then for the node.
The command ends with <n> passed, <m> failed, and exits non-zero when any node failed its last test.
A changed key is offered only when a key is trusted for the node. A key that differs only from the node's host_key is fixed in the inventory, not trusted.
Manage Nodes
Import and Export
dagu nodes import reads a JSON array of inventory records. dagu nodes export prints the same JSON, without IDs, so the output imports into any installation.
dagu nodes import inventories.json --dry-run # check, store nothing
dagu nodes import inventories.json # create new inventories
dagu nodes export > inventories.json # back up, or move elsewhere
dagu nodes import inventories.json --replace # apply edits made to the file- An inventory whose name is new is created.
- An inventory whose name exists, compared without case, is refused unless
--replaceis given.--replacereplaces that inventory as a whole and keeps its ID. - A record that sets
idis refused. - The whole import is checked before anything is stored. When any inventory breaks a rule, nothing is stored, and the error lists every broken rule.
- Inventories are then stored one at a time. When an import stops partway, the same import with
--replacefinishes it.
Error: nothing imported:
inventory "Bad": node "x1": password: takes only {"secret": <ref>}List and Show
dagu nodes list --labels 'site=tokyo,web,!canary'
dagu nodes show tokyo-db01NAME INVENTORY KIND HOST LABELS STATUS
tokyo-web01 Tokyo production ssh 10.0.1.11 env=prod,site=tokyo,web enabled--labels takes a selector. --format json prints each node with its defaults applied.
Add and Remove
dagu nodes add adds one node from flags. Before it saves, it tests the connection.
dagu nodes add tokyo-web03 --inventory "Tokyo production" \
--host 10.0.1.13 --labels web- A name the inventory already holds is refused before anything is tested.
- When the host key is unknown,
addprintsThe host key of <hop> "<node>" is unknown: <fingerprint>and asks. On yes, it tests again with that key, and saves the node and trusts the key only when that test passes. - A node whose test fails is not saved, unless
--no-testskips the test. --inventorymay be left out when there is one inventory.- A relative
--keypath is stored as an absolute path.
dagu nodes remove <name> removes a node from its inventory and forgets its trusted key.
Remote Servers
Every dagu nodes command runs against a remote context, through the server's API, with the same output. add and test then connect from the server. A remote add needs a --key path the server can read: absolute, or starting with ~ or $.
Remote nodes in the Web UI do not serve their inventories. With a remote node selected, the Nodes page lists no nodes. The node and inventory API endpoints refuse a request for a remote node with 403.
Workers as Nodes
A worker that sets worker.id to a valid node name is a node of kind worker.
- Its name is the worker ID, and its host is the host it reports.
- Its labels are its
worker.labels, plus theosandarchlabels every worker has. - A worker without
worker.idreportshostname@pid, a new ID at every start, which is not a valid node name. Such a worker is not a node. - A worker whose
worker.idis not a valid node name logs a warning when it starts.localnames runs on the Dagu host, so a worker withworker.id: localis never a node.
dagu worker --worker.coordinators=coordinator.internal:50055 \
--worker.id=tokyo-gw --worker.labels=site=tokyo,gatewayWorker nodes are listed among inventory nodes in name order, and selectors match their labels as they match an inventory node's. --inventory lists no worker nodes.
NAME INVENTORY KIND HOST LABELS STATUS
tokyo-gw - worker gw.tokyo.lan arch=amd64,gateway,os=linux,site=tokyo onlinedisableddoes not apply to a worker. To keep a worker out of a selector, change its labels.- A worker goes offline when it has sent no heartbeat for 30 seconds, as the coordinator finds at its next zombie detection pass, every
scheduler.zombie_detection_interval(45sby default). An offline worker stays listed with statusofflineand the time of its last heartbeat. It is online again at its next heartbeat. - A worker whose ID names an inventory node, compared without case, is not a node.
dagu nodes listprints a warning on stderr:worker "<id>" is not a node: inventory "<inventory>" has a node of that name.
dagu nodes forget <name> forgets an offline worker node. The worker is listed again when it connects. Forgetting an online worker is refused.
On Kubernetes, a worker pool becomes a worker node only with a stable workerId. See Kubernetes (Helm).
Nodes Page
The Nodes page, under Configure in the Web UI, lists the nodes of the server's inventories and its worker nodes. Filter by inventory, labels, and name. Select a node to see its details, connection settings, credentials as key paths and secret refs, and host key settings.
| Task | Where | Role |
|---|---|---|
| View nodes and inventories | Node list, node drawer, Inventories tab | Any signed-in user |
| Test connections | Check nodes, then test them, or test every matched node | Operator |
| Trust or replace host keys | The test panel: Trust key, Trust N unknown keys, Replace key | Developer |
| Add a node | Add node. The server tests the connection first; Add without testing skips the test | Developer |
| Edit a node's labels, disable, or remove it | The node drawer. Other node fields are edited on the Inventories tab | Developer |
| Create, edit, or delete inventories | Inventories tab, as a form or as JSON | Developer |
| Export inventories | Export on the Inventories tab | Any signed-in user |
| Import inventories | Import on the Inventories tab. The import is checked before it is stored | Developer |
| Forget an offline worker node | The node drawer | Admin |
A test takes at most 1,000 nodes. The replace dialog shows the trusted and the presented fingerprints. Changes, tests, trusted keys, and forgotten workers are written to the audit log.
Each change names the version of the inventory it was based on. When someone else changed the inventory since, the change is refused and the page offers to load the current version.
Storage
Inventories are stored in data/inventories/, trusted host keys in data/host-keys/, and worker nodes in data/worker-nodes/. See Backup and Restore. dagu nodes export prints the inventories, but not the trusted keys.
See Also
- Node Targeting: run steps and workflows on nodes
dagu nodes: CLI reference- Node endpoints: REST API
- SSH: connect to one host from a step

