adding main terraform files

This commit is contained in:
Pin
2022-04-07 17:14:32 -04:00
parent 3d6b8e78fd
commit 335a0f0ac3
3 changed files with 28 additions and 31 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@
*.tfstate.backup
secret.tf
vars.tf

47
main.tf
View File

@@ -8,30 +8,31 @@ terraform {
}
provider "proxmox" {
pm_api_url = "https://proxmox.pinfosec.dev:8006/api2/json"
pm_api_url = var.proxmox_api_url
pm_api_token_id = "k8_service_user@pve!k8_token"
pm_api_token_id = var.apiTokenID
pm_api_token_secret = var.apiToken
pm_tls_insecure = true
pm_timeout = 600
pm_timeout = 1200
pm_log_enable = true
pm_log_file = "terraform-plugin-proxmox.log"
pm_log_levels = {
_default = "debug"
_capturelog = ""
}
pm_log_file = "terraform-plugin-proxmox.log"
pm_log_levels = {
_default = "debug"
_capturelog = ""
}
}
resource "proxmox_vm_qemu" "k8master" {
count = 1
name = "FCOS-Master1"
name = "FCOS-K3Master-1"
target_node = var.proxmox_host
clone = var.template_name
pool = "K8s"
pool = "${var.vm_pool}"
agent = 1
os_type = "cloud-init"
@@ -47,12 +48,12 @@ resource "proxmox_vm_qemu" "k8master" {
slot = 0
size = "10G"
type = "scsi"
storage = "VMStorage"
storage = "${var.vm_storage_disk}"
}
network {
model = "virtio"
bridge = "vmbr10"
bridge = "${var.vm_network_bridge}"
}
lifecycle {
@@ -61,20 +62,22 @@ resource "proxmox_vm_qemu" "k8master" {
]
}
ssh_user = "spencer"
ssh_user = "${var.ssh_user}"
sshkeys = "${var.ssh_key}"
timeouts {
create = "30m"
delete = "2h"
}
}
resource "proxmox_vm_qemu" "k8runner" {
count = 3
name = "FCOS-Runner${count.index + 1}"
#define_connection_info = false
name = "FCOS-K3Runner-${count.index + 1}"
target_node = var.proxmox_host
clone = var.template_name
pool = "K8s"
pool = "${var.vm_pool}"
agent = 1
os_type = "cloud-init"
@@ -90,12 +93,12 @@ resource "proxmox_vm_qemu" "k8runner" {
slot = 0
size = "10G"
type = "scsi"
storage = "VMStorage"
storage = "${var.vm_storage_disk}"
}
network {
model = "virtio"
bridge = "vmbr10"
bridge = "${var.vm_network_bridge}"
}
lifecycle {
@@ -104,6 +107,10 @@ resource "proxmox_vm_qemu" "k8runner" {
]
}
ssh_user = "spencer"
ssh_user = "${var.ssh_user}"
sshkeys = "${var.ssh_key}"
timeouts {
create = "30m"
delete = "2h"
}
}

11
vars.tf
View File

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