commit 3d6b8e78fd6e89a3513b4a50484d30d79eafb736 Author: Pin Date: Fri Feb 18 18:45:46 2022 -0500 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10451ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.terraform* +*.log +*.tfstate +*.tfstate.backup + +secret.tf diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..78b22be --- /dev/null +++ b/main.tf @@ -0,0 +1,109 @@ +terraform { + required_providers { + proxmox = { + source = "telmate/proxmox" + version = "2.9.6" + } + } +} + +provider "proxmox" { + pm_api_url = "https://proxmox.pinfosec.dev:8006/api2/json" + + pm_api_token_id = "k8_service_user@pve!k8_token" + pm_api_token_secret = var.apiToken + + pm_tls_insecure = true + pm_timeout = 600 + + pm_log_enable = true + pm_log_file = "terraform-plugin-proxmox.log" + pm_log_levels = { + _default = "debug" + _capturelog = "" + } +} + +resource "proxmox_vm_qemu" "k8master" { + count = 1 + name = "FCOS-Master1" + + target_node = var.proxmox_host + clone = var.template_name + + pool = "K8s" + + agent = 1 + os_type = "cloud-init" + cores = 2 + sockets = 2 + cpu = "host" + memory = 2048 + scsihw = "virtio-scsi-pci" + bootdisk = "scsi0" + vmid = "3120" + + disk { + slot = 0 + size = "10G" + type = "scsi" + storage = "VMStorage" + } + + network { + model = "virtio" + bridge = "vmbr10" + } + + lifecycle { + ignore_changes = [ + network, + ] + } + + ssh_user = "spencer" + sshkeys = "${var.ssh_key}" +} + +resource "proxmox_vm_qemu" "k8runner" { + count = 3 + name = "FCOS-Runner${count.index + 1}" + + #define_connection_info = false + + target_node = var.proxmox_host + clone = var.template_name + + pool = "K8s" + + agent = 1 + os_type = "cloud-init" + cores = 2 + sockets = 2 + cpu = "host" + memory = 2048 + scsihw = "virtio-scsi-pci" + bootdisk = "scsi0" + vmid = "313${count.index}" + + disk { + slot = 0 + size = "10G" + type = "scsi" + storage = "VMStorage" + } + + network { + model = "virtio" + bridge = "vmbr10" + } + + lifecycle { + ignore_changes = [ + network, + ] + } + + ssh_user = "spencer" + sshkeys = "${var.ssh_key}" +} diff --git a/vars.tf b/vars.tf new file mode 100644 index 0000000..0cf808e --- /dev/null +++ b/vars.tf @@ -0,0 +1,11 @@ +variable "proxmox_host" { + default = "LOIC" +} + +variable "template_name" { + default = "fcos-template2" +} + +variable "ssh_key" { + default = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE/bVQjWtdR9aU3vlnAuOLrj6SLNdC6gsXxVw5Xq6MZQ" +}