resource "proxmox_lxc" "app" {
  target_node = var.target_node
  hostname    = var.vm_hostname
  ostemplate  = var.ostemplate
  password    = "password"

  depends_on = [var.db_host]

  ssh_public_keys = var.ssh_public_key

  cores  = var.lxc_resources.cores
  memory = var.lxc_resources.memory
  swap   = var.lxc_resources.swap

  rootfs {
    storage = var.storage
    size    = var.size
  }

  network {
    name     = "eth0"
    bridge   = var.bridge
    ip       = "${var.ip_address}/24"
    gw       = var.gateway
    firewall = true
  }

  start = true

  provisioner "remote-exec" {
    inline = [
      "echo Приложение подключится к БД ${var.db_host}"
    ]
  }

  connection {
    type        = "ssh"
    host        = var.ip_address
    user        = "root"
    private_key = var.private_key
    timeout     = "2m"
  }


}
