Skip to content

Files

Latest commit

 Cannot retrieve latest commit at this time.

History

History
217 lines (171 loc) · 6 KB

README.md

File metadata and controls

217 lines (171 loc) · 6 KB

Talis 🦍

Talis is a multi-cloud infrastructure provisioning and configuration project that uses:

  • Direct Cloud Provider APIs to create and manage cloud instances
  • Ansible for initial system configuration and package installation

Overview

  • Multi-cloud: With a single codebase, you can choose which cloud provider to use (currently supporting DigitalOcean, with more providers coming soon)
  • Direct API Integration: Uses cloud provider APIs directly for better control and reliability
  • Ansible: Provides initial system configuration and package installation
  • Extensive Testing: Comprehensive test coverage for all cloud provider operations

Requirements

  • Go (1.24 or higher)
  • Ansible (2.9 or higher)
  • SSH key pair for instance access
  • Cloud Credentials:

Project Structure

See architecture doc

Setup

  1. Copy .env.example to .env:
cp .env.example .env
  1. Configure environment variables:
# DigitalOcean
DIGITALOCEAN_TOKEN=your_digitalocean_token_here
  1. Ensure your SSH key is available:
# The default path is ~/.ssh/id_rsa
# You can specify a different path in the request

Usage

Using the CLI

# Build the CLI
make build-cli

# Create a project
./bin/talis-cli project create -n my-project

# Copy and modify the example create configuration
cp create.json_example create.json

# Create infrastructure using your configuration
./bin/talis-cli infra create -f create.json
# A delete.json file will be automatically generated after successful creation

# Delete infrastructure using the auto-generated file
./bin/talis-cli infra delete -f delete.json

Example Configuration Files

Create Configuration (create.json_example):

{
    "instance_name": "talis",
    "project_name": "talis-test",
    "instances": [
        {
            "provider": "do",
            "number_of_instances": 1,
            "provision": true,
            "region": "nyc3",
            "size": "s-1vcpu-1gb",
            "image": "ubuntu-22-04-x64",
            "tags": ["talis-do-instance"],
            "ssh_key_name": "your-ssh-key-name",
            "volumes": [
                {
                    "name": "talis-volume",
                    "size_gb": 15,
                    "mount_point": "/mnt/data"
                }
            ]
        },
        {
            "provider": "do",
            "name": "talis-validator",
            "number_of_instances": 1,
            "provision": true,
            "region": "nyc3",
            "size": "s-2vcpu-2gb",
            "image": "ubuntu-22-04-x64",
            "tags": ["talis-validator"],
            "ssh_key_name": "your-ssh-key-name",
            "volumes": [
                {
                    "name": "talis-volume",
                    "size_gb": 15,
                    "mount_point": "/mnt/data"
                }
            ]
        }
    ]
}

Auto-generated Delete Configuration (delete.json):

The delete configuration will be automatically generated after a successful creation. It will include all necessary information to delete the created resources:

The instance_name field is used as a base name for instances. Each instance gets a suffix that is incremented starting from 0 (e.g., "talis-0"). Individual instances can have custom names by specifying the name field in the instance object, as shown in the example above with "talis-validator".

Delete Instances

Example configuration (delete.json_example):

Delete Configuration (delete.json):

This file is automatically generated after a successful creation. It contains all the information needed to delete the created resources:

{
    "id": 10,
    "instance_name": "talis",
    "project_name": "talis-test",
    "instances": [
        {
            "provider": "do",
            "number_of_instances": 1,
            "region": "nyc3"
        },
        {
            "provider": "do",
            "name": "talis-validator",
            "region": "nyc3"
        }
    ]
}

When deleting instances, you can specify which instances to delete by providing the name field in the instance object. If no specific names are provided, instances are deleted in FIFO order (oldest first).

Extensibility

Adding New Providers

  1. Create new file in internal/compute/ (e.g., aws.go)
  2. Implement the ComputeProvider interface:
    type ComputeProvider interface {
        ValidateCredentials() error
        GetEnvironmentVars() map[string]string
        ConfigureProvider(stack interface{}) error
        CreateInstance(ctx context.Context, name string, config InstanceConfig) ([]InstanceInfo, error)
        DeleteInstance(ctx context.Context, name string, region string) error
    }
  3. Add the provider in NewComputeProvider in provider.go
  4. Add comprehensive tests following the pattern in digitalocean_test.go

Customizing Ansible

Modify files in ansible/:

  • main.yml: Main Ansible configuration
  • stages/setup.yml: Initial system setup and configuration
  • vars/main.yml: Variable definitions
  • Add new stages in ansible/stages/ for additional configurations

Upcoming Features

  • AWS provider implementation
  • Linode provider implementation
  • Vultr provider implementation
  • DataPacket provider implementation
  • Webhook notification system
  • Enhanced job management and monitoring
  • 100 Light Nodes deployment support

Development

Running Tests

# Run all tests
make test

# Run tests with coverage
make test-coverage

# Run specific tests
go test ./internal/compute -run TestDigitalOceanProvider

Code Quality

The project uses:

  • golangci-lint for code quality
  • go test for unit and integration testing
  • yamllint for YAML file validation

Run the linters:

make lint