rauto - Network Device Automation CLI
rauto is a powerful CLI tool for network device automation, written in Rust. It leverages the rneter library for intelligent SSH connection management and utilizes minijinja for flexible command templating.
Features
- Double Template System: Command Templates (Jinja2) & Device Profiles (TOML).
- Intelligent Connection Handling: Uses
rneterfor SSH state management. - Dry Run Support: Preview commands before execution.
- Variable Injection: Load variables from JSON.
- Extensible: Custom TOML device profiles.
- Built-in Web Console: Start browser UI with
rauto web. - Embedded Web Assets: Frontend files are embedded into the binary for release usage.
Installation
From Binary (Recommended)
Download the latest release for your platform from GitHub Releases.
From Crates.io
From Source
Ensure you have Rust and Cargo installed.
The binary will be available at target/release/rauto.
Usage
1. Template Mode (Recommended)
Render commands from a template and execute them on a device.
Basic Usage:
With Variables:
Given a template templates/commands/configure_vlan.j2 and variables file templates/example_vars.json:
Dry Run (Preview):
2. Direct Execution
Execute raw commands directly without templates.
Specifying Execution Mode:
Execute a command in a specific mode (e.g., Enable, Config).
3. Device Profiles
rauto supports built-in device profiles (inherited from rneter) and custom TOML profiles.
List Available Profiles:
Using a Specific Profile:
Default is cisco. To use Huawei VRP:
Custom Device Profile:
You can define custom profiles in templates/devices/*.toml.
Example templates/devices/custom_cisco.toml:
= "custom_cisco"
[[]]
= "Enable"
= ['^[^\s#]+#\s*$']
# ... see templates/devices/custom_cisco.toml for full example
Use it:
Useful profile management commands:
4. Web Console (Axum)
Start the built-in web service and open the visual console in your browser:
Then visit http://127.0.0.1:3000.
Web assets are embedded into the binary at build time.
For released binaries, users only need to run the executable (no extra static/ files required at runtime).
5. Template Storage Commands
6. CLI Quick Reference
Connection troubleshooting
Profile management
Template storage management
Start web console
Directory Structure
By default, rauto stores and reads templates under ~/.rauto/templates/.
Default directories:
~/.rauto/templates/commands~/.rauto/templates/devices
These folders are auto-created on startup.
For backward compatibility, local ./templates/ is still checked as a fallback.
.
├── templates/
│ ├── commands/ # Store your .j2 command templates here
│ │ ├── configure_vlan.j2
│ │ └── show_version.j2
│ ├── devices/ # Store custom .toml device profiles here
│ │ └── custom_cisco.toml
│ └── example_vars.json # Example variable files
└── src/
You can specify a custom template directory using the --template-dir argument or RAUTO_TEMPLATE_DIR environment variable.
Configuration
| Argument | Env Var | Description |
|---|---|---|
--host |
- | Device hostname or IP |
--username |
- | SSH username |
--password |
RAUTO_PASSWORD |
SSH password |
--enable-password |
- | Enable/Secret password |
--ssh-port |
- | SSH port (default: 22) |
--device-profile |
- | Device type (default: cisco) |
Template Syntax
rauto uses Minijinja, which is compatible with Jinja2.
Example configure_vlan.j2:
conf t
{% for vlan in vlans %}
vlan {{ vlan.id }}
name {{ vlan.name }}
{% endfor %}
end
Example variables:
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT