Configuration Module¶
Configuration system for managing executor settings and remote targets.
Overview¶
The config module provides TOML-based configuration management for Shannot executors. It allows you to define reusable executor configurations (local or SSH) with their associated profiles and connection settings.
Key Components:
ShannotConfig- Main configuration container with executor targetsExecutorConfig- Base configuration for executorsLocalExecutorConfig- Local executor configurationSSHExecutorConfig- SSH executor configuration with connection detailsload_config()- Load configuration from TOML file
Configuration File Format¶
Shannot uses TOML for configuration files, typically located at ~/.config/shannot/config.toml:
[executors.production]
type = "ssh"
host = "prod.example.com"
username = "readonly"
key_file = "~/.ssh/prod_key"
profile = "diagnostics"
port = 22
[executors.staging]
type = "ssh"
host = "staging.example.com"
username = "readonly"
key_file = "~/.ssh/staging_key"
profile = "minimal"
[executors.local]
type = "local"
profile = "diagnostics"
bwrap_path = "/usr/bin/bwrap"
Common Usage Patterns¶
Loading Configuration¶
from shannot.config import load_config
# Load from default location (~/.config/shannot/config.toml)
config = load_config()
# Load from custom path
config = load_config(Path("/etc/shannot/config.toml"))
Getting Executors¶
# Get specific executor
executor = config.get_executor("production")
# Use with commands
result = await executor.run_command(profile, ["df", "-h"])
Listing Available Targets¶
# List all configured executor names
targets = config.list_executors()
print(f"Available targets: {', '.join(targets)}")
CLI Integration¶
# Use configured target from CLI
shannot --target production df -h
# MCP install on remote target
shannot mcp install claude-code --target staging
Configuration Options¶
SSH Executor Options¶
[executors.myserver]
type = "ssh"
host = "server.example.com" # Required: hostname or IP
username = "readonly" # Optional: SSH username (default: current user)
key_file = "~/.ssh/id_rsa" # Optional: SSH private key path
port = 22 # Optional: SSH port (default: 22)
profile = "diagnostics" # Optional: default profile for this target
connection_pool_size = 5 # Optional: max concurrent connections
known_hosts = "~/.ssh/known_hosts" # Optional: known_hosts file
strict_host_key = true # Optional: strict host key checking
Local Executor Options¶
[executors.local]
type = "local"
profile = "minimal" # Optional: default profile
bwrap_path = "/usr/bin/bwrap" # Optional: explicit bwrap path
Environment Variables¶
Configuration paths can be overridden with environment variables:
# Custom config location
export SHANNOT_CONFIG=~/my-shannot-config.toml
shannot --target prod df -h
# Custom profile
export SANDBOX_PROFILE=~/.config/shannot/diagnostics.json
shannot --target prod df -h
Programmatic Configuration¶
You can also create configurations programmatically:
from shannot.config import ShannotConfig, SSHExecutorConfig
# Create config
config = ShannotConfig(executors={
"prod": SSHExecutorConfig(
type="ssh",
host="prod.example.com",
username="readonly",
key_file=Path("~/.ssh/prod_key"),
profile="diagnostics"
)
})
# Use executor
executor = config.get_executor("prod")
Related Documentation¶
- Configuration Guide - Detailed configuration examples
- Execution Module - Executor implementations
- CLI Usage - Using configured targets from command line
- Deployment Guide - Production configuration patterns
API Reference¶
config
¶
Configuration management for Shannot.
This module handles loading and managing executor configurations from TOML files.
Classes¶
ExecutorConfig
¶
LocalExecutorConfig
¶
SSHExecutorConfig
¶
Bases: ExecutorConfig
Configuration for SSH executor.
Source code in shannot/config.py
ShannotConfig
¶
Bases: BaseModel
Complete Shannot configuration.
Source code in shannot/config.py
Functions¶
get_executor_config(name=None)
¶
Get executor config by name, or default if name is None.
Source code in shannot/config.py
Functions¶
get_config_path()
¶
Get the path to the Shannot config file.
Returns: Path to ~/.config/shannot/config.toml (or Windows/macOS equivalent)
Source code in shannot/config.py
load_config(config_path=None)
¶
Load Shannot configuration from TOML file.
Args: config_path: Optional path to config file. If not provided, uses default.
Returns: Loaded configuration
Raises: FileNotFoundError: If config file doesn't exist ValueError: If config file is invalid
Source code in shannot/config.py
save_config(config, config_path=None)
¶
Save Shannot configuration to TOML file.
Args: config: Configuration to save config_path: Optional path to config file. If not provided, uses default.
Source code in shannot/config.py
create_executor(config, executor_name=None)
¶
Create an executor from configuration.
Args: config: Shannot configuration executor_name: Name of executor to create, or None for default
Returns: Initialized executor
Raises: ValueError: If executor config is invalid or executor not found
Source code in shannot/config.py
get_executor(executor_name=None, config_path=None)
¶
Convenience function to load config and create executor.
Args: executor_name: Name of executor to create, or None for default config_path: Optional path to config file
Returns: Initialized executor