# Full Server Configuration Template
# 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

# Import other loaded modules (uncomment after loading)
# import .providers as providers
# import .clusters as clusters

# Main settings for this infrastructure
main_settings: settings.Settings = {
    main_name = "full-infra"
    main_title = "Full Infrastructure Configuration"

    # 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"

    # Configure cluster settings
    cluster_admin_host = ""  # Will be set by provider
    servers_wait_started = 30

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

# Web server example
web_servers: [server.Server] = [
    {
        hostname = "web-01"
        title = "Web Server 01"

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

        # Network configuration
        network_utility_ipv4 = True
        network_public_ipv4 = True

        # User configuration
        user = "admin"
        user_ssh_port = 22
        fix_local_hosts = True
        labels = "env: production, role: web, tier: frontend"

        # Resource configuration (adjust based on provider)
        # plan = "2xCPU-4GB"  # UpCloud example
        # storage_size = 50

        # Task services (uncomment after loading modules)
        # taskservs = [
        #     { name = "containerd", profile = "default" }
        #     { name = "cilium", profile = "default" }
        # ]
    }
    {
        hostname = "web-02"
        title = "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 = "admin"
        user_ssh_port = 22
        fix_local_hosts = True
        labels = "env: production, role: web, tier: frontend"
    }
]

# Database server example
db_servers: [server.Server] = [
    {
        hostname = "db-01"
        title = "Database Server"

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

        # Network configuration (database typically on private network)
        network_utility_ipv4 = True
        network_public_ipv4 = False

        user = "admin"
        user_ssh_port = 22
        fix_local_hosts = True
        labels = "env: production, role: database, tier: backend"

        # Higher resources for database
        # plan = "4xCPU-8GB"
        # storage_size = 100
    }
]

# Kubernetes control plane example
k8s_control: [server.Server] = [
    {
        hostname = "k8s-control-01"
        title = "Kubernetes Control Plane"

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

        network_utility_ipv4 = True
        network_public_ipv4 = True

        user = "admin"
        user_ssh_port = 22
        fix_local_hosts = True
        labels = "env: production, role: k8s-control, tier: control-plane"

        # Task services for Kubernetes (uncomment after loading)
        # taskservs = [
        #     { name = "kubernetes", profile = "control-plane" }
        #     { name = "containerd", profile = "default" }
        #     { name = "cilium", profile = "default" }
        # ]
    }
]

# Kubernetes worker nodes example
k8s_workers: [server.Server] = [
    {
        hostname = "k8s-worker-01"
        title = "Kubernetes Worker 01"

        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 = "admin"
        user_ssh_port = 22
        fix_local_hosts = True
        labels = "env: production, role: k8s-worker, tier: compute"

        # taskservs = [
        #     { name = "kubernetes", profile = "worker" }
        #     { name = "containerd", profile = "default" }
        # ]
    }
    {
        hostname = "k8s-worker-02"
        title = "Kubernetes Worker 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 = "admin"
        user_ssh_port = 22
        fix_local_hosts = True
        labels = "env: production, role: k8s-worker, tier: compute"
    }
]

# Combine all servers
all_servers = web_servers + db_servers + k8s_control + k8s_workers

# Export configuration
{
    settings = main_settings
    servers = all_servers
}
