add first terraform project with bpg-proxmox to create a simple cloud-init VM (not really working...)
This commit is contained in:
parent
5ac27af6cb
commit
428f9588c7
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# Terraform
|
||||
**/.terraform*
|
||||
*.tfstate*
|
||||
*credentials.auto.tfvars
|
64
terraform/bgp-simple-vm/bpg-simple-vm.tf
Normal file
64
terraform/bgp-simple-vm/bpg-simple-vm.tf
Normal file
@ -0,0 +1,64 @@
|
||||
data "proxmox_virtual_environment_vms" "template" {
|
||||
filter {
|
||||
name = "name"
|
||||
values = ["ubuntu-cloud"]
|
||||
}
|
||||
}
|
||||
resource "proxmox_virtual_environment_vm" "simple_vm" {
|
||||
name = "simple-vm"
|
||||
node_name = "zenith"
|
||||
tags = ["terraform", "test"]
|
||||
|
||||
|
||||
agent {
|
||||
enabled = false
|
||||
}
|
||||
# if agent is not enabled, the VM may not be able to shutdown properly, and may need to be forced off
|
||||
stop_on_destroy = true
|
||||
|
||||
clone {
|
||||
vm_id = data.proxmox_virtual_environment_vms.template.vms[0].vm_id
|
||||
}
|
||||
|
||||
cpu {
|
||||
cores = 2
|
||||
type = "x86-64-v2-AES" # recommended for modern CPUs
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = 2048
|
||||
floating = 2048 # set equal to dedicated to enable ballooning
|
||||
}
|
||||
|
||||
disk {
|
||||
datastore_id = "ceph-workload"
|
||||
#file_id = proxmox_virtual_environment_download_file.latest_ubuntu_22_jammy_qcow2_img.id
|
||||
interface = "scsi0"
|
||||
}
|
||||
|
||||
initialization {
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "dhcp"
|
||||
}
|
||||
}
|
||||
|
||||
#user_account {
|
||||
# keys = [trimspace(tls_private_key.ubuntu_vm_key.public_key_openssh)]
|
||||
# password = random_password.ubuntu_vm_password.result
|
||||
# username = "ubuntu"
|
||||
#}
|
||||
|
||||
#user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
}
|
||||
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
|
||||
|
||||
}
|
17
terraform/bgp-simple-vm/provider.tf
Normal file
17
terraform/bgp-simple-vm/provider.tf
Normal file
@ -0,0 +1,17 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
endpoint = var.proxmox_endpoint
|
||||
api_token = var.proxmox_api_token
|
||||
insecure = false
|
||||
ssh {
|
||||
agent = true
|
||||
username = "root"
|
||||
}
|
||||
}
|
10
terraform/bgp-simple-vm/variables.tf
Normal file
10
terraform/bgp-simple-vm/variables.tf
Normal file
@ -0,0 +1,10 @@
|
||||
variable "proxmox_endpoint" {
|
||||
description = "Proxmox URL endpoint"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "proxmox_api_token" {
|
||||
description = "Proxmox API token"
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
14
terraform/telmate-simple-vm/provider.tf
Normal file
14
terraform/telmate-simple-vm/provider.tf
Normal file
@ -0,0 +1,14 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "telmate/proxmox"
|
||||
version = "3.0.1-rc6"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
pm_api_url = var.proxmox_api_url
|
||||
pm_api_token_id = var.proxmox_api_token_id
|
||||
pm_api_token_secret = var.proxmox_api_token_secret
|
||||
}
|
67
terraform/telmate-simple-vm/telmate-simple-vm.tf
Normal file
67
terraform/telmate-simple-vm/telmate-simple-vm.tf
Normal file
@ -0,0 +1,67 @@
|
||||
|
||||
resource "proxmox_vm_qemu" "cloudinit-test" {
|
||||
name = "terraform-test-vm"
|
||||
desc = "A test for using terraform and cloudinit"
|
||||
tags = "test"
|
||||
|
||||
target_node = "zenith"
|
||||
|
||||
clone = "ubuntu-cloud"
|
||||
|
||||
agent = 0
|
||||
|
||||
os_type = "cloud-init"
|
||||
bios = "ovmf"
|
||||
|
||||
cores = 2
|
||||
sockets = 1
|
||||
vcpus = 0
|
||||
cpu_type = "host"
|
||||
memory = 2048
|
||||
|
||||
scsihw = "virtio-scsi-pci"
|
||||
disks {
|
||||
scsi {
|
||||
scsi0 {
|
||||
disk {
|
||||
storage = "ceph-workload"
|
||||
size = "4G"
|
||||
}
|
||||
}
|
||||
scsi1 {
|
||||
cloudinit {
|
||||
storage = "ceph-workload"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
network {
|
||||
id = 0
|
||||
model = "virtio"
|
||||
bridge = "vmbr0"
|
||||
tag = 66
|
||||
}
|
||||
|
||||
vga {
|
||||
type = "std"
|
||||
}
|
||||
|
||||
# Setup the disk
|
||||
|
||||
|
||||
# Setup the network interface and assign a vlan tag: 256
|
||||
|
||||
|
||||
# Setup the ip address using cloud-init.
|
||||
boot = "order=scsi0"
|
||||
# Keep in mind to use the CIDR notation for the ip.
|
||||
ipconfig0 = "ip=dhcp"
|
||||
ciuser = "vez"
|
||||
ciupgrade = true
|
||||
sshkeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICxWxrBF6W6N2ZrzoKhTwDTZ49tlYzvki+4naHjo8DhB vez-key"
|
||||
|
||||
|
||||
|
||||
}
|
16
terraform/telmate-simple-vm/variables.tf
Normal file
16
terraform/telmate-simple-vm/variables.tf
Normal file
@ -0,0 +1,16 @@
|
||||
variable "proxmox_api_url" {
|
||||
description = "Proxmox URL endpoint"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "proxmox_api_token_id" {
|
||||
description = "Proxmox API token ID"
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "proxmox_api_token_secret" {
|
||||
description = "Proxmox API token secret"
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user