diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f3dbf1a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +credentials.auto.tfvars \ No newline at end of file diff --git a/credentials.auto.tfvars b/credentials.auto.tfvars index e69de29..d4d8ec7 100644 --- a/credentials.auto.tfvars +++ b/credentials.auto.tfvars @@ -0,0 +1,5 @@ +proxmox_api_url= "https://192.168.1.155:8006/api2/json" +proxmox_api_token_id= "root@pam!TerraDemo" +proxmox_api_token_secret= "4f6c33d0-7a29-4238-815c-ad7d368dae66" +root_password = "Zakaria1986!!!" +ssh_public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO65p1xPly/h1Pso+G44zFnIBX2x7OfrZkXIb22JmW8J k_ansible" \ No newline at end of file diff --git a/lxc_Demo.tf b/lxc_Demo.tf index e69de29..15a1bd1 100644 --- a/lxc_Demo.tf +++ b/lxc_Demo.tf @@ -0,0 +1,27 @@ +resource "proxmox_lxc" "TerraformDemo" { + target_node = "ThePearl" + hostname = "lxc-SemaTerra" + ostemplate = "local:vztmpl/ubuntu-24.04-standard_24.04-2_amd64.tar.zst" + password = var.root_password + unprivileged = true + memory = 2048 + swap = 512 + cores = 2 + cpulimit = 2 + + ssh_keys = [ + var.ssh_public_key + ] + + // Terraform will crash without rootfs defined + rootfs { + storage = "TheTower" + size = "4G" + } + + network { + name = "eth0" + bridge = "vmbr0" + ip = "dhcp" + } +} \ No newline at end of file diff --git a/providers.tf b/providers.tf index e69de29..b393dbe 100644 --- a/providers.tf +++ b/providers.tf @@ -0,0 +1,38 @@ +terraform { + required_version = ">=0.14" + required_providers { + proxmox = { + source = "Telmate/proxmox" + version = "3.0.1-rc1" + } + } +} +variable "root_password" { + type = string + sensitive = true +} + +variable "ssh_public_key" { + type = string + sensitive = true +} + +variable "proxmox_api_url" { + type = string + +} +variable "proxmox_api_token_id" { + type = string + sensitive = true +} +variable "proxmox_api_token_secret" { + type = string + sensitive = true +} + +provider "proxmox" { + pm_tls_insecure = true + pm_api_url = var.proxmox_api_url + pm_api_token_id = var.proxmox_api_token_id + pm_api_token_secret= var.proxmox_api_token_secret +} \ No newline at end of file