Skip to content

ruanbekker/devops-ai-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

48 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

devops-ai-cli

devops-ai-cli is a personal CLI tool written in Go, powered by Cobra and Viper.

About

It's a cli tool that includes some of the following:

πŸš€ Installation

Prerequisites

You need Go installed. Check with:

go version

If Go is not installed, you can install version 1.24.0 on Linux

Read more
curl -fsSL https://golang.org/dl/go1.24.0.linux-amd64.tar.gz | sudo tar -C /usr/local -xzf -
export PATH=$PATH:/usr/local/go/bin
echo "export PATH=\$PATH:/usr/local/go/bin" >> ~/.bashrc
echo "export GOPATH=\$HOME/go" >> ~/.bashrc
echo "export GOROOT=/usr/local/go" >> ~/.bashrc

Now, verify installation:

go version

πŸ› οΈ Setup & Usage

1️⃣ Install Dependencies

go mod tidy

2️⃣ Build the CLI

go build -o devopscli main.go

✨ Features

πŸ› οΈ Initialize Configuration

The init command creates a default configuration file.

πŸ“Œ Usage

./devopscli init

This will create a configuration file at ~/.config/devopscli/config.yaml

πŸ“Œ Example Config (config.yaml)

openwebui:
  host: "http://localhost:3000"
  api_key: "your-api-key-here"
  model: "gpt-4-turbo"

debug: false

πŸ“Œ Overriding the Config Location

By default, devopscli uses ~/.config/devopscli/config.yaml for its configuration and to use a custom location you can set DEVOPSCLI_CONFIG_LOCATION environment variable:

export DEVOPSCLI_CONFIG_LOCATION="$HOME/.devopscli/config.yaml"

πŸ“œ Render a Markdown File

The render command allows you to display Markdown files beautifully in the terminal.

Usage

./devopscli render -f example.md

Example

echo "# Hello, World!" > example.md
./devopscli render -f example.md

πŸ€– Explain Command

The explain command allows you to ask OpenWebUI AI for explanations on various topics,
and it returns a response formatted in Markdown.

Usage

./devopscli explain "what does the Kubernetes CrashLoopBackOff mean?"

Configuration

To use this command, configure OpenWebUI API details in one of two ways:

πŸ“Œ Option 1: Using config.yaml

openwebui:
  host: "http://localhost:3000"
  api_key: "your-api-key-here"

πŸ“Œ Option 2: Using Environment Variables

export OPENWEB_API_KEY="your-secret-api-key"
export OPENWEB_API_HOST="http://localhost:3000"

How It Works

βœ… The CLI sends a request to OpenWebUI with your query.
βœ… OpenWebUI processes the request and returns a response.
βœ… The response is rendered as Markdown using glamour.

πŸ€– Query Command (Maintain Conversations)

The query command allows you to ask OpenWebUI AI questions while maintaining context across multiple queries.

πŸ“ Basic Usage

./devopscli query "What is Kubernetes?"

Example Response

  # Kubernetes Explained
  Kubernetes is an open-source container orchestration system...
πŸ†” **Conversation ID**: 1

This assigns the question a Conversation ID (1), allowing follow-ups.

πŸ”„ Continue a Conversation

To ask follow-up questions, use the --cid flag with the conversation ID:

./devopscli query "How does Kubernetes handle scaling?" --cid "1"

Example Response

  # Kubernetes Scaling
  - Uses Horizontal Pod Autoscaler (HPA)
  - Uses Cluster Autoscaler
  - Supports Vertical Pod Autoscaling

This maintains context and follows up on the previous question.

πŸ“‹ List Saved Conversations

./devopscli query --list

Example Output

πŸ“ **Previous Conversations:**
πŸ†” 1: What is Kubernetes?
πŸ†” 2: How does Kubernetes handle deployments?

This lets you see which past questions you can continue.

πŸ—‘οΈ Delete a Specific Conversation

./devopscli query --delete 1

βœ… Removes conversation ID 1 from storage.

🚨 Clear All Conversations

./devopscli query --clear

πŸ—‘οΈ Deletes all stored conversations.

✨ Features

βœ… Maintains conversation history
βœ… Allows follow-up questions (--cid)
βœ… Lists previous queries (--list)
βœ… Deletes single (--delete) or all (--clear) conversations
βœ… Uses OpenWebUI API for intelligent responses
βœ… Outputs beautifully formatted Markdown responses

πŸš€ Optimize Command

The optimize command allows you to send a code or configuration file (e.g., YAML, JSON, Python, Terraform, Shell scripts) to OpenWebUI AI, which will analyze and provide optimization suggestions in Markdown format.

πŸ”Ή Usage

./devopscli optimize -f _extras/manifests/example-deployment.yaml 

Example for a Terraform file:

./devopscli optimize -f infra.tf

Example for a Python script:

./devopscli optimize -f script.py

βš™οΈ Configuration

To use this command, configure OpenWebUI API details via a config file or environment variables.

πŸ“Œ Option 1: Using config.yaml

openwebui:
  host: "http://localhost:3000"
  api_key: "your-api-key-here"
  model: "gemma:2b"

πŸ“Œ Option 2: Using Environment Variables

export OPENWEB_API_KEY="your-secret-api-key"
export OPENWEB_API_HOST="http://localhost:3000"

πŸ“ Example Output

If you run:

./devopscli optimize -f _extras/manifests/example-deployment.yaml

The response from AI will be returned in markdown format.

✨ Summary

βœ… Supports multiple file types (YAML, JSON, .py, .tf, .sh, etc.)
βœ… Sends the file content to OpenWebUI for AI-based optimization
βœ… Receives Markdown suggestions and beautifully renders them in the terminal

πŸ” Verify Installed Tools

The verify command checks whether required DevOps tools are installed on your system. It reads the list of tools from config.yaml and reports their availability.

πŸ“ Usage

./devopscli verify

πŸ“Œ Example Configuration

Define required tools in config.yaml:

tools:
  required:
    - kubectl
    - terraform
    - docker
    - helm
    - git
    - jq
    - curl

πŸ“Œ Example Output

πŸ” **Verifying Required Tools:**

βœ… kubectl
❌ terraform (Not Installed)
βœ… docker
βœ… helm
βœ… git
❌ jq (Not Installed)
βœ… curl

πŸ’‘ Features

βœ… Reads required tools from config.yaml
βœ… Checks if each tool is installed
βœ… Displays βœ… (installed) and ❌ (missing)
βœ… Fast and lightweight!

πŸ“š Resources

About

DevOps CLI using Go, Viper and Cobra

Resources

Stars

Watchers

Forks

Packages

No packages published