add terraform
This commit is contained in:
parent
98092c1dc0
commit
62f9a5dffc
|
@ -0,0 +1,16 @@
|
||||||
|
terraform {
|
||||||
|
required_version = ">= 0.14"
|
||||||
|
required_providers {
|
||||||
|
proxmox = {
|
||||||
|
source = "registry.example.com/telmate/proxmox"
|
||||||
|
version = ">= 1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "proxmox" {
|
||||||
|
pm_tls_insecure = true
|
||||||
|
pm_api_url = "https://proxmox.jimsgarage.co.uk/api2/json"
|
||||||
|
pm_api_token_secret = "112e04a7-4f15-45c5-b1e1-624e90a55f8b"
|
||||||
|
pm_api_token_id = "root@pam!terraform"
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
resource "proxmox_vm_qemu" "cloudinit-k3s-master" {
|
||||||
|
# Node name has to be the same name as within the cluster
|
||||||
|
# this might not include the FQDN
|
||||||
|
target_node = "proxmox-dell"
|
||||||
|
desc = "Cloudinit Ubuntu"
|
||||||
|
count = 3
|
||||||
|
onboot = true
|
||||||
|
|
||||||
|
# The template name to clone this vm from
|
||||||
|
clone = "23.04-non-KVM"
|
||||||
|
|
||||||
|
# Activate QEMU agent for this VM
|
||||||
|
agent = 0
|
||||||
|
|
||||||
|
os_type = "cloud-init"
|
||||||
|
cores = 2
|
||||||
|
sockets = 2
|
||||||
|
numa = true
|
||||||
|
vcpus = 0
|
||||||
|
cpu = "host"
|
||||||
|
memory = 4096
|
||||||
|
name = "k3s-master-0${count.index + 1}"
|
||||||
|
|
||||||
|
cloudinit_cdrom_storage = "nvme"
|
||||||
|
scsihw = "virtio-scsi-single"
|
||||||
|
bootdisk = "scsi0"
|
||||||
|
|
||||||
|
disks {
|
||||||
|
scsi {
|
||||||
|
scsi0 {
|
||||||
|
disk {
|
||||||
|
storage = "nvme"
|
||||||
|
size = 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Setup the ip address using cloud-init.
|
||||||
|
# Keep in mind to use the CIDR notation for the ip.
|
||||||
|
ipconfig0 = "ip=192.168.3.10${count.index + 1}/24,gw=192.168.3.1"
|
||||||
|
ciuser = "ubuntu"
|
||||||
|
nameserver = "192.168.200.11"
|
||||||
|
sshkeys = <<EOF
|
||||||
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKfn+iQH2HnuXIa67zBzEUfrg4mfH9meVy/CWuzODj2G8K6xWXUx9YTzchqr2xjXxLDQcDC+RDwVY0cAiWZ/OrXd6H8QEkSSEuAc/exWvVmLQGr3e41Ff9BUslqayGEPwFP6fndCWK8FthiwYUUGM5sODLZl4DFcqtgICRzuEcNcRQZFpq/h5NzCYmdPWMrAuQLfF/fW2VRD5gnqaDkgW+pdw+1umut5ey6C4fCPA9/7vkSesDc2RafA3gRkBmO1IxBVhzgl7OLl84iFnl1dEUcrdSCoaRL2AHC36EDvhF5M/Zlv5hebITzc9f7cF88k/rsx2ZnlSOeIHD31/lRhWL root@proxmox-dell
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "proxmox_vm_qemu" "cloudinit-k3s-worker" {
|
||||||
|
# Node name has to be the same name as within the cluster
|
||||||
|
# this might not include the FQDN
|
||||||
|
target_node = "proxmox-dell"
|
||||||
|
desc = "Cloudinit Ubuntu"
|
||||||
|
count = 2
|
||||||
|
onboot = true
|
||||||
|
|
||||||
|
# The template name to clone this vm from
|
||||||
|
clone = "23.04-non-KVM"
|
||||||
|
|
||||||
|
# Activate QEMU agent for this VM
|
||||||
|
agent = 0
|
||||||
|
|
||||||
|
os_type = "cloud-init"
|
||||||
|
cores = 2
|
||||||
|
sockets = 2
|
||||||
|
numa = true
|
||||||
|
vcpus = 0
|
||||||
|
cpu = "host"
|
||||||
|
memory = 4096
|
||||||
|
name = "k3s-worker-0${count.index + 1}"
|
||||||
|
|
||||||
|
cloudinit_cdrom_storage = "nvme"
|
||||||
|
scsihw = "virtio-scsi-single"
|
||||||
|
bootdisk = "scsi0"
|
||||||
|
|
||||||
|
disks {
|
||||||
|
scsi {
|
||||||
|
scsi0 {
|
||||||
|
disk {
|
||||||
|
storage = "nvme"
|
||||||
|
size = 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Setup the ip address using cloud-init.
|
||||||
|
# Keep in mind to use the CIDR notation for the ip.
|
||||||
|
ipconfig0 = "ip=192.168.3.11${count.index + 1}/24,gw=192.168.3.1"
|
||||||
|
ciuser = "ubuntu"
|
||||||
|
sshkeys = <<EOF
|
||||||
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKfn+iQH2HnuXIa67zBzEUfrg4mfH9meVy/CWuzODj2G8K6xWXUx9YTzchqr2xjXxLDQcDC+RDwVY0cAiWZ/OrXd6H8QEkSSEuAc/exWvVmLQGr3e41Ff9BUslqayGEPwFP6fndCWK8FthiwYUUGM5sODLZl4DFcqtgICRzuEcNcRQZFpq/h5NzCYmdPWMrAuQLfF/fW2VRD5gnqaDkgW+pdw+1umut5ey6C4fCPA9/7vkSesDc2RafA3gRkBmO1IxBVhzgl7OLl84iFnl1dEUcrdSCoaRL2AHC36EDvhF5M/Zlv5hebITzc9f7cF88k/rsx2ZnlSOeIHD31/lRhWL root@proxmox-dell
|
||||||
|
EOF
|
||||||
|
}
|
Loading…
Reference in New Issue