add playbook

This commit is contained in:
Benedikt Penner
2026-03-14 20:43:35 +01:00
parent 6d479e5934
commit 6820ba29c3
7 changed files with 76 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
resource "proxmox_vm_qemu" "cloudinit-test1" {
resource "proxmox_vm_qemu" "galera" {
for_each = toset(var.hosts)
name = "${each.value}"
desc = "A test for using terraform and cloudinit"
@@ -48,7 +48,7 @@ resource "proxmox_vm_qemu" "cloudinit-test1" {
network {
id = 0
model = "e1000"
bridge = var.nic_name
bridge = var.nic_name_internal
}
vga {
@@ -71,4 +71,6 @@ resource "proxmox_vm_qemu" "cloudinit-test1" {
ciuser = "clusteruser"
cipassword = "password"
ciupgrade = true
cicustom = "vendor=oldnasisos:snippets/qemu-guest-agent.yml"
}

View File

@@ -0,0 +1,7 @@
resource "local_file" "ansible_inventory" {
content = templatefile("${path.module}/templates/inventory.yml.tftpl", {
galera_servers = proxmox_vm_qemu.galera
bastion = proxmox_vm_qemu.jumphost
})
filename = "${path.module}/../inventory/terraform_hosts.yml"
}

View File

@@ -1,4 +1,4 @@
resource "proxmox_vm_qemu" "cloudinit-test1" {
resource "proxmox_vm_qemu" "jumphost" {
name = "Jumphost"
desc = "A test for using terraform and cloudinit"
@@ -77,4 +77,5 @@ resource "proxmox_vm_qemu" "cloudinit-test1" {
ciuser = "clusteruser"
cipassword = "password"
ciupgrade = true
cicustom = "vendor=oldnasisos:snippets/qemu-guest-agent.yml"
}

View File

@@ -5,6 +5,10 @@ terraform {
source = "telmate/proxmox"
version = "3.0.2-rc07"
}
local = {
source = "hashicorp/local"
version = "2.7.0"
}
}
}

View File

@@ -0,0 +1,17 @@
# terraform/templates/inventory.yml.tftpl
# Auto-generated by Terraform - DO NOT EDIT
all:
children:
bastion:
hosts:
bastion:
ansible_host: "${bastion.default_ipv4_address}"
ansible_user: clusteruser
test_server:
hosts:
%{ for idx, server in galera_servers ~}
${server.name}:
ansible_host: "${server.default_ipv4_address}"
ansible_user: clusteruser
ansible_ssh_common_args: "-o ProxyJump=clusteruser@${bastion.default_ipv4_address}"
%{ endfor ~}