feature: Add shell script for further automation
This commit is contained in:
parent
0306493619
commit
86a9c17033
4 changed files with 20 additions and 3 deletions
10
create_vm.sh
Executable file
10
create_vm.sh
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PROXMOX_NODE=$(/bin/proxlb -b)
|
||||||
|
PROXMOX_VM_ID=$(<vmcount.txt)
|
||||||
|
|
||||||
|
echo "Best Proxmox node for next VM placement: $PROXMOX_NODE"
|
||||||
|
echo "Next VM with ID managed-vm$PROXMOX_VM_ID.boxybsd.com will be placed on node: $PROXMOX_NODE"
|
||||||
|
echo "$((++PROXMOX_VM_ID))" > vmcount.txt
|
||||||
|
|
||||||
|
terraform apply -var="hostname=managed-vm$PROXMOX_VM_ID.boxybsd.com" -var="node=$PROXMOX_NODE"
|
6
variables.tf
Normal file
6
variables.tf
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
variable "hostname" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
variable "node" {
|
||||||
|
type = string
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
resource "proxmox_virtual_environment_vm" "managed-vm33" {
|
resource "proxmox_virtual_environment_vm" "main" {
|
||||||
name = "managed-vm33.boxybsd.com"
|
name = var.hostname
|
||||||
description = "Managed by Terraform"
|
description = "Managed by Terraform"
|
||||||
tags = ["terraform"]
|
tags = ["terraform"]
|
||||||
node_name = "virt01"
|
node_name = var.node
|
||||||
|
|
||||||
cpu {
|
cpu {
|
||||||
cores = 1
|
cores = 1
|
||||||
|
|
1
vmcount.txt
Normal file
1
vmcount.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
1
|
Loading…
Reference in a new issue