# Example Working Configuration Template
# This is a complete, ready-to-deploy example
# Import from installed provisioning package
import provisioning.settings as settings
import provisioning.server as server
import provisioning.defaults as defaults

# Import taskservs (infrastructure services)
# The os taskserv is loaded automatically during workspace init
# To use it, import from the taskservs directory:
# import taskservs.os

# To discover more taskservs: provisioning dt
# To load additional taskservs: cd infra/<name> && provisioning mod load taskservs . <taskserv_name>
# Example: provisioning mod load taskservs . kubernetes containerd cilium

# Main settings for example infrastructure
main_settings: settings.Settings = {
    main_name = "example-demo"
    main_title = "Example Demo Infrastructure"

    # Configure paths relative to infrastructure directory
    settings_path = "../../data/settings.yaml"
    defaults_provs_dirpath = "./defs"
    prov_data_dirpath = "../../data"
    created_taskservs_dirpath = "../../tmp/deployment"
    prov_resources_path = "../../resources"
    created_clusters_dirpath = "../../tmp/clusters"
    prov_clusters_path = "./clusters"

    cluster_admin_host = ""
    servers_wait_started = 30

    runset = {
        wait = True
        output_format = "human"
        output_path = "../../tmp/deployment"
        inventory_file = "./inventory.yaml"
        use_time = True
    }
}

# Example: Simple web application stack
# 2 web servers + 1 database server
web_app_servers: [server.Server] = [
    {
        hostname = "demo-web-01"
        title = "Demo Web Server 01"

        lock = False
        time_zone = "UTC"
        running_wait = 10
        running_timeout = 200
        storage_os_find = "name: debian-12 | arch: x86_64"

        # Public-facing web server
        network_utility_ipv4 = True
        network_public_ipv4 = True

        user = "demo"
        user_ssh_port = 22
        fix_local_hosts = True
        labels = "env: demo, role: web, app: frontend"

        # Minimal resources for demo
        # plan = "1xCPU-2GB"
        # storage_size = 25
    }
    {
        hostname = "demo-web-02"
        title = "Demo Web Server 02"

        lock = False
        time_zone = "UTC"
        running_wait = 10
        running_timeout = 200
        storage_os_find = "name: debian-12 | arch: x86_64"

        network_utility_ipv4 = True
        network_public_ipv4 = True

        user = "demo"
        user_ssh_port = 22
        fix_local_hosts = True
        labels = "env: demo, role: web, app: frontend"
    }
    {
        hostname = "demo-db-01"
        title = "Demo Database Server"

        lock = False
        time_zone = "UTC"
        running_wait = 15
        running_timeout = 300
        storage_os_find = "name: debian-12 | arch: x86_64"

        # Database on private network only
        network_utility_ipv4 = True
        network_public_ipv4 = False

        user = "demo"
        user_ssh_port = 22
        fix_local_hosts = True
        labels = "env: demo, role: database, app: backend"

        # plan = "2xCPU-4GB"
        # storage_size = 50
    }
]

# Export configuration
{
    settings = main_settings
    servers = web_app_servers
}

# Usage Instructions:
# 1. Discover available taskservs:
#    provisioning dt                   # Discover all taskservs
#    provisioning dp                   # Discover all providers
#    provisioning dc                   # Discover all clusters
#
# 3. Load additional modules:
#    provisioning mod load taskservs . containerd kubernetes cilium
#    provisioning mod load providers . upcloud
#
# 4. Configure provider-specific settings (uncomment in servers above):
#    - Set 'plan' for server sizes (e.g., "2xCPU-4GB")
#    - Set 'storage_size' for disk size (e.g., 50)
#    - Add provider-specific network configuration
#
# 5. Deploy:
#    provisioning s create --infra <name> --check  # Dry-run first
#    provisioning s create --infra <name>          # Deploy
#
# 6. Verify:
#    provisioning s list               # List all servers
#    provisioning s ssh demo-web-01    # SSH to server
