docs: add pve, opentofu, cloudinit article
This commit is contained in:
parent
c48ee905df
commit
ecaea9db49
7 changed files with 544 additions and 0 deletions
|
@ -0,0 +1,10 @@
|
|||
#cloud-config
|
||||
hostname: test-debian-12
|
||||
users:
|
||||
- name: ephase
|
||||
gecos: My simple user
|
||||
ssh_authorized_keys:
|
||||
- ssh-ed25519 AAbB...
|
||||
lock_passwd: false
|
||||
sudo: ['ALL=(ALL) NOPASSWD:ALL']
|
||||
shell: /bin/bash
|
|
@ -0,0 +1,6 @@
|
|||
#cloud-config
|
||||
package_update: true
|
||||
packages:
|
||||
- qemu-guest-agent
|
||||
runcmd:
|
||||
- systemctl enable --now qemu-guest-agent
|
|
@ -0,0 +1,85 @@
|
|||
resource "proxmox_virtual_environment_download_file" "debian_12" {
|
||||
content_type = "iso"
|
||||
datastore_id = "local"
|
||||
file_name = "debian-12-generic-amd64.img"
|
||||
node_name = var.pve_node
|
||||
url = var.debian_image_url
|
||||
checksum = var.debian_image_checksum
|
||||
checksum_algorithm = var.debian_image_checksum_algorithm
|
||||
overwrite = true
|
||||
overwrite_unmanaged = true
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_file" "user_config" {
|
||||
content_type = "snippets"
|
||||
datastore_id = "local"
|
||||
node_name = var.pve_node
|
||||
|
||||
source_raw {
|
||||
data = file("cloud-init/user-config.yaml")
|
||||
file_name = "user-config.yaml"
|
||||
}
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_file" "vendor_config" {
|
||||
content_type = "snippets"
|
||||
datastore_id = "local"
|
||||
node_name = var.pve_node
|
||||
|
||||
source_raw {
|
||||
data = file("cloud-init/vendor-config.yaml")
|
||||
file_name = "vendor-config.yaml"
|
||||
}
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_vm" "debian_12_test" {
|
||||
depends_on = [
|
||||
proxmox_virtual_environment_file.user_config,
|
||||
proxmox_virtual_environment_file.vendor_config
|
||||
]
|
||||
name = "debian-12"
|
||||
description = "Debian 12 created with Terraform"
|
||||
tags = ["terraform", "debian"]
|
||||
node_name = var.pve_node
|
||||
|
||||
cpu {
|
||||
cores = 2
|
||||
}
|
||||
memory {
|
||||
dedicated = 2048
|
||||
floating = 2048
|
||||
}
|
||||
|
||||
disk {
|
||||
datastore_id = "local-lvm"
|
||||
file_id = proxmox_virtual_environment_download_file.debian_12.id
|
||||
interface = "virtio0"
|
||||
iothread = true
|
||||
discard = "on"
|
||||
ssd = true
|
||||
}
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
model = "virtio"
|
||||
}
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
initialization {
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "dhcp"
|
||||
}
|
||||
}
|
||||
# Link cloud-init yaml files
|
||||
user_data_file_id = proxmox_virtual_environment_file.user_config.id
|
||||
vendor_data_file_id = proxmox_virtual_environment_file.vendor_config.id
|
||||
}
|
||||
}
|
||||
|
||||
output "debian_12_test_ip_address" {
|
||||
value = proxmox_virtual_environment_vm.debian_12_test.ipv4_addresses
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
terraform {
|
||||
required_version = "> 1.6.0"
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = "0.64.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
endpoint = var.pve_endpoint
|
||||
username = var.pve_username
|
||||
password = var.pve_password
|
||||
insecure = var.pve_insecure
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
variable "pve_insecure" {
|
||||
type = bool
|
||||
description = "Enable insecure connexion"
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "pve_endpoint" {
|
||||
type = string
|
||||
description = "API endpoint URL"
|
||||
}
|
||||
|
||||
variable "pve_password" {
|
||||
type = string
|
||||
description = "Password"
|
||||
}
|
||||
|
||||
variable "pve_username" {
|
||||
type = string
|
||||
description = "Username"
|
||||
}
|
||||
variable "pve_node" {
|
||||
type = string
|
||||
description = "Node where install elements"
|
||||
default = ""
|
||||
}
|
||||
variable "debian_image_url" {
|
||||
type = string
|
||||
description = "The URL for the latest Debian 12 Bookworm qcow2 image"
|
||||
default = ""
|
||||
}
|
||||
variable "debian_image_checksum_algorithm" {
|
||||
type = string
|
||||
description = "Checksum algo used by image"
|
||||
default = "sha512"
|
||||
}
|
||||
|
||||
variable "debian_image_checksum" {
|
||||
type = string
|
||||
description = "SHA Digest of the image"
|
||||
default = ""
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue