initial commit

This commit is contained in:
Pin
2022-02-18 18:45:46 -05:00
commit 3d6b8e78fd
3 changed files with 126 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
.terraform*
*.log
*.tfstate
*.tfstate.backup
secret.tf

109
main.tf Normal file
View File

@@ -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}"
}

11
vars.tf Normal file
View File

@@ -0,0 +1,11 @@
variable "proxmox_host" {
default = "LOIC"
}
variable "template_name" {
default = "fcos-template2"
}
variable "ssh_key" {
default = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE/bVQjWtdR9aU3vlnAuOLrj6SLNdC6gsXxVw5Xq6MZQ"
}