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

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

View File

@@ -5,6 +5,10 @@ terraform {
source = "telmate/proxmox" source = "telmate/proxmox"
version = "3.0.2-rc07" 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 ~}