diff options
| author | clyhtsuriva <aimeric@adjutor.xyz> | 2025-02-18 21:03:00 +0100 | 
|---|---|---|
| committer | clyhtsuriva <aimeric@adjutor.xyz> | 2025-02-18 21:03:00 +0100 | 
| commit | 1e1a8a1f3f4a8586072d3e31d2bef9c27786d448 (patch) | |
| tree | 95b1618e62c971265f1df55131e1a784d2e3d873 /opentofu/main.tf | |
| parent | 8af7efa1e03c1d37cf34197249e487348d382d82 (diff) | |
Replace proxmox provider telmate by bpg + remove k8s cluster (talos on the way)
Also changes the id of the packer images,
now starting at the "end" (999), while VMs start at 100
Diffstat (limited to 'opentofu/main.tf')
| -rw-r--r-- | opentofu/main.tf | 112 | 
1 files changed, 53 insertions, 59 deletions
| diff --git a/opentofu/main.tf b/opentofu/main.tf index 3da6045..ff9f945 100644 --- a/opentofu/main.tf +++ b/opentofu/main.tf @@ -1,68 +1,62 @@ -module "k8s_control_plane" { -  source = "./modules/k8s_control_plane" +resource "proxmox_virtual_environment_vm" "docker_server" { +  name        = "docker-server" +  description = "Debian server with docker installed." +  tags        = ["debian", "docker"] +  node_name   = var.proxmox_node -  name              = "k8s-cp-01" -  desc              = "k8s control plane" -  agent             = 1 -  target_node       = var.proxmox_node -  tags              = "debian;k8s" -  clone             = var.debian_server_bookworm_packer_image_name -  full_clone        = true -  qemu_os           = "other" -  cores             = 2 -  sockets           = 1 -  cpu_type          = "host" -  memory            = 6144 -  scsihw            = "virtio-scsi-pci" -  bootdisk          = "scsi0" -  cloudinit_storage = "local-lvm" -  disk_storage      = "local-lvm" -  disk_size         = "32G" -  iothread          = true -  replicate         = false -  network_id        = 0 -  network_model     = "virtio" -  network_bridge    = "vmbr0" -  ipconfig0         = "ip=dhcp" -  ciuser            = "mas" -  sshkeys           = var.ssh_public_key -} +  clone { +    vm_id = var.debian_server_bookworm_packer_image_id # Use the VM ID of the template +    full  = true +  } + +  agent { +    enabled = true # Qemu Guest Agent +  } + +  cpu { +    cores   = 2 +    sockets = 1 +    type    = "host" +  } + +  memory { +    dedicated = 4096 +  } -module "k8s_worker" { -  source = "./modules/k8s_worker" +  disk { +    interface    = "virtio0" +    datastore_id = "local-lvm" +    size         = 20 +    discard      = "on" +    iothread     = true +  } -  vm_count          = var.k8s_worker_vm_count -  name_prefix       = var.k8s_worker_vm_name_prefix -  desc              = "k8s worker" -  agent             = 1 -  target_node       = var.proxmox_node -  tags              = "debian;k8s" -  clone             = var.debian_server_bookworm_packer_image_name -  full_clone        = true -  qemu_os           = "other" -  cores             = 1 -  sockets           = 1 -  cpu_type          = "host" -  memory            = 2048 -  scsihw            = "virtio-scsi-pci" -  bootdisk          = "scsi0" -  cloudinit_storage = "local-lvm" -  disk_storage      = "local-lvm" -  disk_size         = "32G" -  iothread          = true -  replicate         = false -  network_id        = 0 -  network_model     = "virtio" -  network_bridge    = "vmbr0" -  ipconfig0         = "ip=dhcp" -  ciuser            = "mas" -  sshkeys           = var.ssh_public_key +  network_device { +    bridge = "vmbr0" +    model  = "virtio" +  } + +  initialization { +    ip_config { +      ipv4 { +        address = "dhcp" +      } +    } + +    user_account { +      username = var.vm_username +      keys     = [var.ssh_public_key] +    } +  }  } -module "ansible_provision_k8s" { +# Run Ansible playbook after VM creation to install Docker +module "ansible_provision_docker_server" {    source                = "./modules/ansible_provisioner" -  inventory_file_path   = local_file.ansible_inventory.filename +  vm_ip                 = proxmox_virtual_environment_vm.docker_server.ipv4_addresses[1][0] # Use first ip & ensure this is a string    vm_username           = var.vm_username    ssh_private_key_path  = var.ssh_private_key_path -  ansible_playbook_path = var.k8s_ansible_playbook_path +  ansible_playbook_path = var.docker_ansible_playbook_path +  depends_on            = [proxmox_virtual_environment_vm.docker_server] +}  } | 
