Skip to content

a task runner Cli that automates general infrastrcuture workflows and run them dynamically as one task, with a lot more features should be added as plugins in the future

Notifications You must be signed in to change notification settings

JOSA-OpenLab/Infra_Cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Infra_Cli

A task runner CLI that automates general infrastructure workflows and runs them dynamically as one task.

Features

  • 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

Installation

# Build the CLI
go build -o infra-cli main.go

# Or run directly
go run main.go

Usage

Basic Usage

Run all tasks defined in project.yaml:

./infra-cli

List Tasks

View all configured tasks without running them:

./infra-cli --list

Custom Configuration

Specify a custom configuration file:

./infra-cli --config custom-project.yaml

Version Information

Check the CLI version:

./infra-cli --version

Using Make

make build      # Build the binary
make run        # Build and run
make list       # List tasks
make clean      # Clean artifacts
make help       # Show all commands

Configuration

Create 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

Task Types

Terraform

  • path: Directory containing Terraform files
  • command: Terraform command (init, plan, apply, destroy)

Docker

  • image: Docker image name
  • action: Docker action (build, pull, run)
  • tag: Optional tag for build operations

Python

  • script: Path to Python script
  • args: Optional command-line arguments

Example

$ ./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!

Project Structure

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

Extending

To add a new task type:

  1. Create a new file in internal/tasks/
  2. Implement the Task interface:
    type Task interface {
        Name() string
        Run() error
    }
  3. Add a case in createTask() in internal/runner/project.go

About

a task runner Cli that automates general infrastrcuture workflows and run them dynamically as one task, with a lot more features should be added as plugins in the future

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •