Check whether a named deployment environment exists in the workspace.
Provides a scripting-friendly way to test whether an environment has been created. Unlike show, this command:
- Always exits 0 on success, regardless of whether the environment exists
- Outputs bare
trueorfalse— valid for both human reading and shell scripting - Never produces verbose output — designed for use in conditionals and pipelines
- Never loads the environment — pure file-existence check, sub-millisecond
torrust-tracker-deployer exists <ENVIRONMENT> [OPTIONS]<ENVIRONMENT>(required) - Name of the environment to check
-o, --output-format <FORMAT>(optional) - Output format:text(default) orjson
| Scenario | Exit Code | Stdout | Stderr |
|---|---|---|---|
| Environment exists | 0 | true |
— |
| Environment does not exist | 0 | false |
— |
| Invalid environment name | 1 | — | Error with help |
| Repository/IO error | 1 | — | Error with help |
Check if an environment exists:
torrust-tracker-deployer exists my-environment
# stdout: true (if it exists)
# stdout: false (if it does not)Both output formats produce bare true or false — valid JSON boolean values.
torrust-tracker-deployer exists my-environmenttrue
torrust-tracker-deployer exists my-environment --output-format jsontrue
Note: Both formats output the same bare value (
trueorfalse), which happens to be valid JSON. There is no JSON object wrapper — the entire stdout is a JSON boolean.
if [ "$(torrust-tracker-deployer exists my-env)" = "true" ]; then
echo "Environment already exists, skipping creation"
else
torrust-tracker-deployer create environment -f config.json
fiENV_EXISTS=$(torrust-tracker-deployer exists my-env)
if [ "$ENV_EXISTS" = "false" ]; then
echo "Error: environment 'my-env' does not exist. Run create first." >&2
exit 1
fi# Check before potentially destructive operation
if [ "$(torrust-tracker-deployer exists staging)" = "true" ]; then
torrust-tracker-deployer destroy staging
fi| Aspect | exists |
show |
|---|---|---|
| Exit code when missing | 0 (false on stdout) |
1 (error) |
| Output when found | true |
Full environment details |
| Output format | Bare boolean | Structured text or JSON |
| Use case | Scripts, conditionals | Human inspection |
| Performance | Sub-millisecond | Slightly slower (deserializes environment) |