Compare commits

...

2 Commits

Author SHA1 Message Date
Benedikt Penner
6820ba29c3 add playbook 2026-03-14 20:43:35 +01:00
Benedikt Penner
6d479e5934 Added Jumphost 2026-03-14 18:05:01 +01:00
8 changed files with 160 additions and 3 deletions

View File

@@ -0,0 +1,19 @@
---
- hosts: glusterfs
gather_facts: true
become: false
tasks:
- name: "Install GlusterFS on all nodes"
ansible.builtin.package:
name: glusterfs-server
state: present
become: true
- name: "Start and enable GlusterFS service"
ansible.builtin.service:
name: glusterd
state: started
enabled: true
become: true

View File

@@ -0,0 +1,23 @@
# terraform/templates/inventory.yml.tftpl
# Auto-generated by Terraform - DO NOT EDIT
all:
children:
bastion:
hosts:
bastion:
ansible_host: "192.168.178.52"
ansible_user: clusteruser
test_server:
hosts:
gluster1:
ansible_host: "10.100.0.3"
ansible_user: clusteruser
ansible_ssh_common_args: "-o ProxyJump=clusteruser@192.168.178.52"
gluster2:
ansible_host: "10.100.0.5"
ansible_user: clusteruser
ansible_ssh_common_args: "-o ProxyJump=clusteruser@192.168.178.52"
gluster3:
ansible_host: "10.100.0.2"
ansible_user: clusteruser
ansible_ssh_common_args: "-o ProxyJump=clusteruser@192.168.178.52"

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

@@ -0,0 +1,81 @@
resource "proxmox_vm_qemu" "jumphost" {
name = "Jumphost"
desc = "A test for using terraform and cloudinit"
# Node name has to be the same name as within the cluster
# this might not include the FQDN
target_node = var.proxmox_host
# The template name to clone this vm from
clone = var.template_name
# Activate QEMU agent for this VM
agent = 1
os_type = "cloud-init"
cpu {
cores = 4
sockets = 2
type = "host"
}
memory = 2048
balloon = 1024
scsihw = "virtio-scsi-single"
# Setup the disk
disks {
ide {
ide3 {
cloudinit {
storage = "local-lvm"
}
}
}
scsi {
scsi0 {
disk {
size = "10G"
storage = var.storage_disks
discard = true
iothread = true
# Can't emulate SSDs in virtio
}
}
}
}
network {
id = 0
model = "e1000"
bridge = var.nic_name_external
}
network {
id = 1
model = "e1000"
bridge = var.nic_name_internal
}
vga {
type = "virtio"
}
startup_shutdown {
order = -1
shutdown_timeout = -1
startup_delay = -1
}
# Setup the ip address using cloud-init.
boot = "order=scsi0"
# Keep in mind to use the CIDR notation for the ip.
ipconfig0 = "ip=dhcp,ip6=dhcp"
ipconfig1 = "ip=dhcp,ip6=dhcp"
skip_ipv6 = true
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 ~}

View File

@@ -10,10 +10,14 @@ variable "storage_disks" {
default = "local-lvm"
}
variable "nic_name" {
variable "nic_name_external" {
default = "vmbr0"
}
variable "nic_name_internal" {
default = "testNet"
}
variable "hosts" {
type = list(string)
default = ["gluster1", "gluster2", "gluster3"]