Opsfile

Like make, but for common live ops commands

Create an Opsfile. Run ops prod rollback-cluster. Go back to sleep.

$ ops prod tail-logs
Fetching logs from /aws/ecs/my-service-prod ...
$ ops prod check-alarms
No alarms in ALARM state. All clear.

Installation

curl -fsSL https://seanseannery.github.io/opsfile/install.sh | bash
brew tap seanseannery/opsfile https://github.com/seanseannery/opsfile
brew install seanseannery/opsfile/opsfile
npm install -g github:seanseannery/opsfile

Getting Started

Step 1: Create an Opsfile

Create an Opsfile in your repo root. It uses Makefile-style syntax:

# Variables โ€” prefix with environment name to scope them
prod_AWS_ACCOUNT=1234567
preprod_AWS_ACCOUNT=8765431

# Commands โ€” define per-environment shell lines
# Use "default" as a fallback when env-specific block is absent
tail-logs:
    default:
        aws logs tail /aws/ecs/my-service --follow --since 30m
    local:
        docker logs myapp --follow --tail 100

list-instance-ips:
    prod:
        aws ec2 describe-instances --filters "Name=tag:Env,Values=prod" --query "Reservations[*].Instances[*].PrivateIpAddress" --output text
    preprod:
        aws ecs list-container-instances --cluster my-cluster-preprod --output text

# Shell env vars are injected automatically โ€” ops falls back to env if not in Opsfile
show-profile:
    default:
        echo "Using AWS profile: $(AWS_PROFILE)"

Step 2: Run ops commands

Run commands with the following syntax:

$ ops [flags] <environment> <command> [args]
Flag Short Description
--directory <path>-D <path>Use the Opsfile in the given directory
--env-file <path>-e <path>Load secrets from a .env file (defaults to .ops_secrets.env)
--dry-run-dPrint resolved commands without executing
--list-lList available commands and environments
--silent-sExecute commands without printing output
--version-vPrint the ops version and exit
--help-hShow usage information and exit

Examples:

$ ops preprod instance-count
$ ops prod open-dashboard
$ ops local logs
$ ops prod k8s -namespace myspace

Why use it?

โšก
Less Stress

Quickly find the right command during a live outage

๐Ÿค–
Less AI tokens

Let agents run ops scripts instead of googling commands

๐Ÿ“–
Knowledge Sharing

Share runbooks with your team as code

๐Ÿ“ฆ
Encapsulation

Keep your Makefile focused on CI/CD

๐Ÿค
Team Standardisation

No more tribal knowledge or bespoke bash aliases. Opsfile lives in the repo.

๐Ÿ”’
Secrets-Safe by Design

Inject secrets from .env files with -e โ€” never commit them to your Opsfile.