A task runner CLI that automates general infrastructure workflows and runs them dynamically as one task.
- Multi-Task Support: Execute Terraform, Docker, and Python tasks sequentially
- YAML Configuration: Simple, declarative project configuration
- Extensible: Easy to add new task types
- Hook System: Built-in logging and timing hooks
- Error Handling: Graceful failure management with detailed error messages
# Build the CLI
go build -o infra-cli main.go
# Or run directly
go run main.goRun all tasks defined in project.yaml:
./infra-cliView all configured tasks without running them:
./infra-cli --listSpecify a custom configuration file:
./infra-cli --config custom-project.yamlCheck the CLI version:
./infra-cli --versionmake build # Build the binary
make run # Build and run
make list # List tasks
make clean # Clean artifacts
make help # Show all commandsCreate a project.yaml file with your tasks:
tasks:
# Terraform infrastructure provisioning
- type: terraform
name: provision-infrastructure
path: ./infra
command: plan # init, plan, apply, destroy
# Docker container management
- type: docker
name: build-backend
image: backend:latest
action: build # build, pull, run
tag: backend:v1.0
# Python scripts for automation
- type: python
name: run-health-check
script: ./scripts/health_check.py
args:
- --verbose
- --timeout=30- path: Directory containing Terraform files
- command: Terraform command (init, plan, apply, destroy)
- image: Docker image name
- action: Docker action (build, pull, run)
- tag: Optional tag for build operations
- script: Path to Python script
- args: Optional command-line arguments
$ ./infra-cli
=> Starting Infra CLI - Running 3 tasks
--- Task 1/3 ---
=> Running Terraform task: provision-infrastructure
Path: ./infra
Command: terraform plan
[OK] Terraform task completed: provision-infrastructure
--- Task 2/3 ---
=> Running Docker task: build-backend
Image: backend:latest
Action: docker build
[OK] Docker task completed: build-backend
--- Task 3/3 ---
=> Running Python task: run-health-check
Script: ./scripts/health_check.py
Args: [--verbose --timeout=30]
[OK] Python task completed: run-health-check
=> All tasks completed successfully!infra-cli/
├── main.go # CLI entry point
├── project.yaml # Configuration file
├── go.mod
└── internal/
├── runner/
│ ├── task.go # Task interface
│ ├── project.go # Project loader and runner
│ └── hooks.go # Pre/post execution hooks
└── tasks/
├── terraform.go # Terraform task implementation
├── docker.go # Docker task implementation
└── python.go # Python task implementation
To add a new task type:
- Create a new file in
internal/tasks/ - Implement the
Taskinterface:type Task interface { Name() string Run() error }
- Add a case in
createTask()in internal/runner/project.go