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
- 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
- Go (1.24 or higher)
- Ansible (2.9 or higher)
- SSH key pair for instance access
- Cloud Credentials:
- For DigitalOcean: Personal Access Token in
DIGITALOCEAN_TOKEN
environment variable - For Linode: Coming soon
- For Vultr: Coming soon
- For DataPacket: Coming soon
- For DigitalOcean: Personal Access Token in
talis/
βββ cmd/
β βββ main.go # Main entry point
βββ internal/
β βββ api/ # API related code
β β βββ v1/
β β βββ handlers/ # Request handlers (instances, jobs)
β β βββ middleware/ # API middleware
β β βββ routes/ # Route definitions
β β βββ services/ # Business logic services
β βββ compute/ # Cloud provider implementations
β β βββ provider.go # ComputeProvider interface and common types
β β βββ digitalocean.go # DigitalOcean implementation
β β βββ ansible.go # Ansible configuration and provisioning
β βββ db/ # Database layer
β β βββ db.go # Database connection and configuration
β β βββ models/ # Database models (instances, jobs)
β β βββ repos/ # Database repositories
β βββ types/ # Common types and models
β βββ infrastructure/ # Infrastructure types and logic
βββ ansible/ # Ansible configurations
β βββ main.yml # Main Ansible configuration
β βββ stages/ # Task stages for different configurations
β β βββ setup.yml # Initial setup and configuration tasks
β βββ vars/ # Variable definitions
β β βββ main.yml # Main variables file
β βββ inventory_*_ansible.ini # Generated inventory files
βββ scripts/ # Utility scripts
βββ .env.example # Environment variables example
- handlers/: HTTP request handlers for instances and jobs
- middleware/: API middleware (logging, auth, etc.)
- routes/: API route definitions
- services/: Business logic services
- models/: Database models for instances and jobs
- repos/: Database repositories with CRUD operations
- db.go: Database connection and configuration
- provider.go: Defines the
ComputeProvider
interface and common types - digitalocean.go: Implementation for DigitalOcean with comprehensive test coverage
- ansible.go: Ansible configuration and provisioning
- main.yml: Main Ansible configuration file
- stages/: Contains different stages of configuration
- setup.yml: Initial setup and configuration tasks
- vars/: Variable definitions for Ansible
- main.yml: Main variables configuration
- inventory_*_ansible.ini: Generated inventory files for each deployment
- Copy
.env.example
to.env
:
cp .env.example .env
- Configure environment variables:
# DigitalOcean
DIGITALOCEAN_TOKEN=your_digitalocean_token_here
- Ensure your SSH key is available:
# The default path is ~/.ssh/id_rsa
# You can specify a different path in the request
# Build the CLI
make build-cli
# Copy and modify the example create configuration
cp create.json_example create.json
# Edit create.json with your specific configuration
# Create infrastructure using your configuration
talis infra create -f create.json
# A delete.json file will be automatically generated after successful creation
# Delete infrastructure using the auto-generated file
talis infra delete -f delete.json
# List all jobs
talis jobs list
# Get job status
talis jobs get --id job-20240315-123456
{
"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"
},
{
"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"
}
]
}
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".
Example configuration (delete.json_example):
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).
- Create new file in
internal/compute/
(e.g.,aws.go
) - 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 }
- Add the provider in
NewComputeProvider
inprovider.go
- Add comprehensive tests following the pattern in
digitalocean_test.go
Modify files in ansible/
:
main.yml
: Main Ansible configurationstages/setup.yml
: Initial system setup and configurationvars/main.yml
: Variable definitions- Add new stages in
ansible/stages/
for additional configurations
- 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
# Run all tests
make test
# Run tests with coverage
make test-coverage
# Run specific tests
go test ./internal/compute -run TestDigitalOceanProvider
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