A lightweight AI-powered DevOps automation tool using a fine-tuned Qwen3-1.7B model with Ollama and SmolAgents. Specialized for Docker and Kubernetes workflows with sequential tool execution and structured reasoning.
- Sequential Tool Execution: Calls ONE tool at a time, waits for results, then proceeds
- Structured Reasoning: Uses
<think>and<plan>tags to show thought process - Validation-Aware: Checks command outputs for errors before proceeding
- Multi-Step Tasks: Handles complex workflows requiring multiple tool calls
- Approval Mode: User confirmation before executing each tool call for enhanced safety (enabled by default)
- Resource Efficient: Optimized for local development (1GB GGUF model)
- Fast: Completes typical DevOps tasks in ~10 seconds
This model is fine-tuned specifically for DevOps automation with improved reasoning capabilities:
- Docker & Kubernetes Expert: Trained on 300+ Docker and Kubernetes workflows (90% of training data)
- One tool at a time: Unlike base models that try to call all tools at once, this model executes sequentially
- Explicit planning: Shows reasoning with
<think>and<plan>before acting - Uses actual values: Extracts and uses real values from tool responses in subsequent calls
- Error handling: Validates each step and tries alternative approaches on failure
The model has been trained on:
- Docker workflows: Building images, containers, Docker Compose, optimization
- Kubernetes operations: Pods, deployments, services, configurations
- General DevOps: File operations, system commands, basic troubleshooting
Task: Get all pods in default namespace
Step 1: Execute kubectl command
<tool_call>
{"name": "bash", "arguments": {"command": "kubectl get pods -n default"}}
</tool_call>
[Receives pod list]
Step 2: Provide summary
<tool_call>
{"name": "final_answer", "arguments": {"answer": "Successfully retrieved 10 pods in default namespace..."}}
</tool_call>
For the best experience with full DevOps capabilities:
curl -fsSL https://raw.githubusercontent.com/ubermorgenland/devops-agent/main/install.sh | bashThis will automatically:
- Install Ollama (if not present)
- Install Python dependencies
- Download the model from Hugging Face
- Create the Ollama model
- Set up the
devops-agentCLI command
Why native installation?
- ✅ Full system access - manage real infrastructure
- ✅ No credential mounting - works with your existing setup
- ✅ Better performance - no container overhead
- ✅ Simpler usage - just run
devops-agent
For containerized environments or testing:
Perfect if you already have Ollama installed and running locally.
# Pull the lite image (faster, smaller ~500MB)
docker pull ubermorgenai/ollama-devops:lite
# Run with your configurations mounted
docker run -it --rm \
--add-host=host.docker.internal:host-gateway \
-e OLLAMA_HOST=http://host.docker.internal:11434 \
-v ~/.kube:/home/devops/.kube:ro \
-v ~/.config/gcloud:/home/devops/.config/gcloud \
-v ~/.aws:/home/devops/.aws \
-v ~/.azure:/home/devops/.azure \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(pwd):/workspace \
ubermorgenai/ollama-devops:liteComplete package with Ollama and model included - no external dependencies.
# Pull the full image (slower, larger ~2GB, but complete)
docker pull ubermorgenai/ollama-devops:full
# Run standalone (no external Ollama needed)
docker run -it --rm \
-p 11434:11434 \
-v ~/.kube:/home/devops/.kube:ro \
-v ~/.config/gcloud:/home/devops/.config/gcloud \
-v ~/.aws:/home/devops/.aws \
-v ~/.azure:/home/devops/.azure \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(pwd):/workspace \
ubermorgenai/ollama-devops:fullTools Included in Both:
- 🔧 kubectl - Kubernetes management
- ☁️ gcloud - Google Cloud Platform authentication
- 🔶 aws - Amazon Web Services authentication
- 🌐 az - Microsoft Azure authentication
- 🐳 docker - Container operations
- 🤖 DevOps agent - AI-powered automation
Lite Version Examples:
# File operations (requires external Ollama)
docker run --rm \
--add-host=host.docker.internal:host-gateway \
-e OLLAMA_HOST=http://host.docker.internal:11434 \
-v $(pwd):/workspace \
ubermorgenai/ollama-devops:lite \
"List all files in the current directory"
# Kubernetes operations
docker run --rm \
--add-host=host.docker.internal:host-gateway \
-e OLLAMA_HOST=http://host.docker.internal:11434 \
-v ~/.kube:/home/devops/.kube:ro \
-v ~/.config/gcloud:/home/devops/.config/gcloud \
ubermorgenai/ollama-devops:lite \
"Get all pods in default namespace"
# Docker operations
docker run --rm \
--add-host=host.docker.internal:host-gateway \
-e OLLAMA_HOST=http://host.docker.internal:11434 \
-v /var/run/docker.sock:/var/run/docker.sock \
ubermorgenai/ollama-devops:lite \
"List all running Docker containers"Full Version Examples:
# File operations (completely self-contained)
docker run --rm \
-v $(pwd):/workspace \
ubermorgenai/ollama-devops:full \
"Create a Dockerfile for a Node.js application"
# Kubernetes operations (no external Ollama needed)
docker run --rm \
-v ~/.kube:/home/devops/.kube:ro \
-v ~/.config/gcloud:/home/devops/.config/gcloud \
ubermorgenai/ollama-devops:full \
"Get all pods in default namespace"
# Interactive mode with full DevOps access
docker run -it --rm \
-p 11434:11434 \
-v ~/.kube:/home/devops/.kube:ro \
-v ~/.config/gcloud:/home/devops/.config/gcloud \
-v ~/.aws:/home/devops/.aws \
-v ~/.azure:/home/devops/.azure \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(pwd):/workspace \
ubermorgenai/ollama-devops:full \
--interactiveCredential Requirements:
- Kubernetes: Mount
~/.kube(read-only) for cluster access - Google Cloud: Mount
~/.config/gcloud(read-write) for GKE authentication - AWS: Mount
~/.aws(read-write) for EKS authentication - Azure: Mount
~/.azure(read-write) for AKS authentication - Docker: Mount
/var/run/docker.sockfor container operations
Security Notes:
- Only mount credentials you actually need for your use case
- Credentials are never stored in the container image
- Container has isolated access only to mounted directories
- This is standard practice for containerized DevOps tools
Install Ollama:
# macOS: Download from website or use Homebrew
brew install ollama
# OR download from: https://ollama.com/download
# Linux:
curl -fsSL https://ollama.com/install.sh | shInstall Python dependencies:
pip install smolagents requests prompt_toolkitNote: prompt_toolkit is required for interactive mode with arrow key support and command history.
Download the fine-tuned GGUF model (1GB) from Hugging Face:
# Install huggingface-hub if not already installed
pip install huggingface-hub
# Download the model
huggingface-cli download ubermorgen/qwen3-devops qwen3-devops.gguf --local-dir .Or download manually from: https://huggingface.co/ubermorgen/qwen3-devops
Note: Make sure the GGUF file is in the same directory as the Modelfile.
ollama create qwen3-devops -f ModelfileSingle query mode:
devops-agent "Get all pods in default namespace"Interactive mode (REPL):
devops-agent
# OR
devops-agent --interactiveVerbose mode (show detailed execution):
devops-agent "Your query" --verboseApproval mode (enabled by default, disable with -na flag):
# By default, approval mode is enabled
devops-agent "List all Docker containers"
# You'll be prompted to approve each tool call
# Disable approval mode for automatic execution
devops-agent --no-approval "List all Docker containers"
# OR use shorthand
devops-agent -na "List all Docker containers"
# Combine with interactive mode without approval
devops-agent -i -na
# Using environment variable to disable approval
REQUIRE_APPROVAL=0 devops-agent "Your query"
# Note: Old -a/--require-approval flags are still accepted for backward
# compatibility but are now redundant (approval is enabled by default)The agent supports an interactive REPL (Read-Eval-Print Loop) for continuous task execution:
devops-agentFeatures:
- Execute multiple tasks in one session
- Real-time thinking indicator with timer
- Clean output showing only tool calls and observations
- Arrow key support: Use Up/Down to navigate command history, Left/Right to edit current line
- Persistent command history: Commands are saved to
~/.devops_agent_history - Approval mode enabled by default for safety (confirm before executing tools, disable with
-na) - Type
exit,quit, orqto leave - Type
helpor?for available commands
Example session:
🤖 DevOps Agent - Interactive Mode
Type your task and press Enter. Type 'exit' or 'quit' to leave.
> Get all pods in default namespace
⠋ thinking... 3s
⏱️ 6s
bash {kubectl get pods -n default}
Observations:
NAME READY STATUS RESTARTS AGE
nginx-deployment-abc123 1/1 Running 0 2d
✅ Successfully retrieved all pods in the default namespace...
> Create a simple Dockerfile for Python app
⠋ thinking... 2s
⏱️ 4s
write_file {Dockerfile}
Observations:
Wrote 156 bytes to Dockerfile
✅ Created Dockerfile for Python application...
> exit
Goodbye!
Verbose mode:
devops-agent --verbose # Show detailed execution stepsApproval mode (enabled by default, example):
$ devops-agent -i
🤖 DevOps Agent - Interactive Mode
⚠️ Approval mode enabled - you'll be asked to approve each tool call
Type your task and press Enter. Type 'exit' or 'quit' to leave.
> List all files in current directory
⏱️ 3s
🔧 Tool call requested:
Tool: bash
Arguments: {
"command": "ls -la"
}
Approve this tool call? [y/n]: y
bash {ls -la}
Observations:
total 64
drwxr-xr-x 8 user staff 256 Jan 13 10:30 .
drwxr-xr-x 15 user staff 480 Jan 10 15:22 ..
-rw-r--r-- 1 user staff 5234 Jan 13 10:28 agent.py
...
✅ Successfully listed all files in the current directory
> Delete all log files
⏱️ 2s
🔧 Tool call requested:
Tool: bash
Arguments: {
"command": "rm -f *.log"
}
Approve this tool call? [y/n]: n
Optional feedback for the agent (press Enter to skip): Too dangerous, just list them first
bash {rm -f *.log}
Observations:
User rejected this tool call. User comment: Too dangerous, just list them first
⏱️ 4s
🔧 Tool call requested:
Tool: bash
Arguments: {
"command": "ls -la *.log"
}
Approve this tool call? [y/n]: y
bash {ls -la *.log}
Observations:
-rw-r--r-- 1 user staff 12345 Jan 12 14:22 app.log
-rw-r--r-- 1 user staff 4567 Jan 13 09:15 error.log
✅ Found 2 log files in the current directory
# Build and manage images
devops-agent "Build Docker image for Node.js application"
# Container management
devops-agent "Run Docker container with environment variables"
# Docker Compose
devops-agent "Setup Docker Compose for local development"
# Optimization
devops-agent "Optimize Docker image to reduce size"
# Debugging
devops-agent "Debug Docker container networking issues"# List pods
devops-agent "Get all pods in default namespace"
# Deployments
devops-agent "Scale Kubernetes deployment manually"
# Services
devops-agent "Expose Kubernetes deployment with service"
# Configuration
devops-agent "Configure liveness probe for Kubernetes pod"
# Environment
devops-agent "Configure environment variables in Kubernetes pod"# Read a file
devops-agent "Read the contents of /etc/hosts"
# Write a file
devops-agent "Create a Dockerfile that prints Hello World"
# List files
devops-agent "List all .py files in the current directory"# Check system resources
devops-agent "Check disk usage and available memory"
# Environment variables
devops-agent "Get the value of PATH environment variable"
# Run commands
devops-agent "Show running Docker containers"# Build and validate
devops-agent "Create a Dockerfile, then check if it exists"
# Deploy workflow
devops-agent "Get DOCKER_USER from environment and create a Dockerfile using it"The agent has access to these tools:
| Tool | Description | Example |
|---|---|---|
read_file |
Read content from a file | Reading config files |
write_file |
Write content to a file | Creating Dockerfiles, scripts |
bash |
Execute shell commands | ls, kubectl, docker, etc. |
get_env |
Get environment variables | AWS credentials, PATH |
final_answer |
Return final result | Completing the task |
Base Model: Qwen3-1.7B Fine-tuning: Custom DevOps dataset with multi-turn tool calling examples Format: GGUF Q4_K_M quantization (1GB) Performance: Optimized for sequential tool execution with validation
Key Improvements over Base Model:
- Structured reasoning with explicit planning steps
- One tool call per response (prevents calling all tools at once)
- Uses actual values from tool responses in subsequent calls
- Validates each step before proceeding
- Better error handling and retry logic
┌─────────────────┐
│ User Query │
└────────┬────────┘
│
▼
┌─────────────────┐
│ agent.py │ CLI interface
└────────┬────────┘
│
▼
┌─────────────────┐
│ DevOpsAgent │ SmolAgents ToolCallingAgent
└────────┬────────┘
│
▼
┌─────────────────┐
│ ollama_backend │ Custom Ollama backend
└────────┬────────┘
│
▼
┌─────────────────┐
│ Ollama (Local) │ qwen3-devops model
└─────────────────┘
Edit agent.py line 151:
model = OllamaChat(model="qwen3-devops")Edit agent.py line 151:
model = OllamaChat(
model="qwen3-devops",
endpoint="http://your-server:11434/api/chat"
)Edit Modelfile and recreate the model:
PARAMETER temperature 0.7 # Lower for more deterministic (e.g., 0.3)
PARAMETER top_p 0.9 # Sampling threshold
PARAMETER num_predict 512 # Max tokens per response
Then recreate: ollama create qwen3-devops -f Modelfile
SMOLAGENTS_LOG_LEVEL=DEBUG devops-agent "Your query here"- First response: ~up to 30 seconds (model loading)
- Subsequent responses: ~3-4 seconds per tool call
- Multi-step tasks: ~10 seconds total for 2-3 step workflows
- Memory usage: ~1.5GB RAM for model + inference
-
Keep Ollama running: Pre-load model to avoid startup delay
ollama run qwen3-devops "hello" -
Reduce temperature: For more deterministic outputs, lower temperature to 0.3-0.5
-
Adjust max_steps: Edit
agent.pyline 165 to limit steps (default: 4)
# Check if Ollama is running
curl http://localhost:11434/api/tags
# Start Ollama
ollama serve# List installed models
ollama list
# If missing, recreate the model
ollama create qwen3-devops -f ModelfileMake sure you've downloaded the GGUF file from Hugging Face and placed it in the repository directory.
- The backend has built-in safety to prevent infinite loops (max_steps=4)
- Check output for validation warnings
- The model automatically validates each tool call before proceeding
- First response is slow due to model loading (~2-3 seconds)
- Subsequent responses are faster (~1-2 seconds)
- Keep Ollama running in background for faster startup
Important: This tool is designed for local DevOps automation on trusted environments.
⚠️ Usesshell=Truefor command execution (convenient but potentially unsafe)⚠️ No input sanitization or command whitelisting⚠️ Full access to file system and shell commands
Do NOT expose this tool to untrusted users or networks.
Security Enhancement - Approval Mode:
- Enabled by default: User confirmation is required before each tool execution
- Each tool call will require explicit approval (y/n)
- Rejections can include feedback comments that guide the agent to try alternative approaches
- Use
--no-approvalor-naflag to disable approval mode for trusted/automated workflows
For production use, consider:
- Keeping approval mode enabled (default behavior) for all operations
- Adding command whitelisting
- Implementing proper input validation
- Running in Docker containers with limited permissions
- Using dedicated service accounts with minimal privileges
- User Input: Query provided via CLI
- SmolAgents: Orchestrates the agent loop and tool calling
- Ollama Backend: Custom backend that formats prompts and parses tool calls
- Sequential Execution: Model calls one tool, waits for response, then proceeds
- Validation: Each tool output is checked before next step
- Result: Final answer returned to user
- Custom System Prompt: Strict instructions to enforce one-tool-at-a-time execution
- Tool Call Parsing: Regex-based parsing of XML
<tool_call>format - Safety Filter: Automatically strips
final_answerwhen combined with other tools - Tool Response Formatting: Explicit "The value is: ..." format for better value extraction
ollama_devops/
├── agent.py # Main CLI and agent definition
├── ollama_backend.py # Custom Ollama backend for SmolAgents
├── smolagents_patches.py # Output filtering patches
├── Modelfile # Ollama model configuration
├── test_agent.py # Unit tests
├── README.md # This file
└── tests/ # Test scripts
Run the test suite to verify functionality:
# Install pytest (included in requirements.txt)
pip install pytest
# Run all tests
pytest test_agent.py -v
# Run with coverage
pytest test_agent.py --cov=agent --cov-report=htmlThe test suite includes:
- Tool Tests: Unit tests for
read_file,write_file,bash, andget_env - Agent Tests: Initialization, verbose mode, and approval mode functionality
- Integration Tests: End-to-end workflows combining multiple tools
All 16 tests should pass on a properly configured system.
The repository includes automated Docker image publishing via GitHub Actions:
Setup Requirements:
- GitHub Container Registry (automatic with GITHUB_TOKEN)
- Docker Hub (requires secrets):
DOCKERHUB_USERNAME: Your Docker Hub usernameDOCKERHUB_TOKEN: Docker Hub access token
Automatic Publishing:
- On push to main: Creates
latesttag - On version tags (v*): Creates versioned tags (e.g.,
v1.0.0,1.0,1) - Multi-architecture: Builds for
linux/amd64andlinux/arm64 - Registries: Publishes to both GitHub Container Registry and Docker Hub
Manual Image Build:
# Build locally
docker build -t ollama-devops .
# Test the image
docker run -it --rm ollama-devops --helpRelease Process:
# Create and push a version tag
git tag v1.0.0
git push origin v1.0.0
# GitHub Actions will automatically:
# - Build multi-arch images
# - Push to ghcr.io/ubermorgenland/ollama_devops:v1.0.0
# - Push to ubermorgenai/ollama-devops:v1.0.0
# - Update latest tags@tool
def my_tool(arg: str) -> str:
"""
Tool description here.
Args:
arg (str): Argument description.
Returns:
str: Return value description.
"""
# Your implementation
return "result"
# Add to agent
agent = DevOpsAgent(
tools=[read_file, write_file, bash, get_env, my_tool],
model=model,
instructions="..."
)# Run with debug logging and save output
SMOLAGENTS_LOG_LEVEL=DEBUG devops-agent "test query" 2>&1 | tee test_output.log- Training Focus: Optimized for Docker and Kubernetes workflows. Limited training on:
- Cloud CLIs (gcloud, AWS CLI, Azure CLI)
- General system administration
- Database operations
- Model Size: 1.7B parameter model may make mistakes on complex tasks
- No Memory Between Queries: Each query in interactive mode is independent (no conversation history)
- Local Only: Requires Ollama running locally
- Max Steps: Limited to 15 steps by default (configurable)
This project uses a modular backend architecture. While it currently ships with the ollama_backend.py for local Ollama models, the design supports:
- Alternative Model Backends: Support for other inference engines (llama.cpp, API-based models, etc.) can be added based on user requests
- Larger Models: The codebase supports any GGUF model - you can use larger models (3B, 7B, 14B) by updating the
Modelfile - Custom Tools: Easy to add new tools using the
@tooldecorator (see CONTRIBUTING.md)
If you need support for a specific model format or backend, please open an issue describing your use case.
- Interactive mode (REPL with clean output)
- Docker containerization
- Conversation history management (multi-turn context)
- Better error handling with retry logic
- Command whitelisting for security
- Web UI interface
- KV cache optimization for faster responses
MIT License - Use at your own risk
This is a local DevOps automation tool. Feel free to fork and customize for your needs.
If you use this model or codebase, please cite:
@misc{qwen3-devops,
title={Qwen3-1.7B Fine-tuned for DevOps Automation},
author={ApInference},
year={2025},
url={https://github.com/yourusername/ollama_devops}
}