command
Experimental. For evaluation. Interfaces, configuration, and behavior may change incompatibly.
Runs remote shell commands and checks host reachability through SSH, including Teleport transport.
Prerequisites
- Configured SSH module.
- Target hosts with the tools and permissions needed by your commands.
Setup
- Add to tenant TOML:
This module must be enabled in your Remediation Orchestrator config before it is available to scripts.
This module provides utilities for executing remote commands.
Members
execute
command.execute(node_id, cmd, args?, env?, timeout?, hostname?, ip?)Execute a system command and return its output.
Parameters
node_idstringNode ID to execute the command on. ID format is specific to the data center, and is presumed to be unique within that data center. Can be empty if hostname or ip is provided.cmdstringThe command to execute.args?optionallist[string]The arguments to pass to the command as a list of strings.env?optionaldict[string:string]Environment variables to set for the command as a dict of string keys and values.timeout?optionalstringTimeout duration as a string (e.g. ‘2m’, ’30s’, ‘1h’). If not provided, the default timeout will be used.hostname?optionalstringHostname to execute the command on. Used as fallback when node_id is empty.ip?optionalstringIP address to execute the command on. Used as fallback when node_id is empty.Returns
resultcommand.ExecuteCommandResultThe result of the command execution.wait_for_response
command.wait_for_response(node_id, poll_interval?, max_duration?, hostname?, ip?)Wait until a node becomes reachable by polling with a simple command.
Parameters
node_idstringNode ID to wait for. ID format is specific to the data center. Can be empty if hostname or ip is provided.poll_interval?optionalstringHow long to wait between attempts as a string (e.g. ’30s’, ‘1m’).max_duration?optionalstringMaximum total time to wait as a string (e.g. ‘15m’, ‘1h’).hostname?optionalstringHostname to wait for. Used as fallback when node_id is empty.ip?optionalstringIP address to wait for. Used as fallback when node_id is empty.Returns
resultcommand.WaitForResponseResultThe result indicating whether the node became reachable.wait_for_success
command.wait_for_success(node_id, cmd, poll_interval?, max_duration?, hostname?, ip?)Wait until a bash command exits successfully.
Parameters
node_idstringNode ID to run the command on. ID format is specific to the data center. Can be empty if hostname or ip is provided.cmdstringThe bash command to execute until it succeeds.poll_interval?optionalstringHow long to wait between attempts as a string (e.g. ’30s’, ‘1m’).max_duration?optionalstringMaximum total time to wait as a string (e.g. ‘15m’, ‘1h’).hostname?optionalstringHostname to run the command on. Used as fallback when node_id is empty.ip?optionalstringIP address to run the command on. Used as fallback when node_id is empty.Returns
resultcommand.WaitForSuccessResultThe result indicating whether the command succeeded, including the successful command output.