From 6820ba29c3ffdec1e08b33c46ff707798ea89da6 Mon Sep 17 00:00:00 2001 From: Benedikt Penner Date: Sat, 14 Mar 2026 20:43:35 +0100 Subject: [PATCH] add playbook --- glusterfs/ansible/setup_galery.yml | 19 +++++++++++++++ glusterfs/inventory/terraform_hosts.yml | 23 +++++++++++++++++++ glusterfs/terraform/glusternode.tf | 6 +++-- glusterfs/terraform/inventory.tf | 7 ++++++ glusterfs/terraform/jumphost.tf | 3 ++- glusterfs/terraform/provider.tf | 4 ++++ .../terraform/templates/inventory.yml.tftpl | 17 ++++++++++++++ 7 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 glusterfs/ansible/setup_galery.yml create mode 100755 glusterfs/inventory/terraform_hosts.yml create mode 100644 glusterfs/terraform/inventory.tf create mode 100644 glusterfs/terraform/templates/inventory.yml.tftpl diff --git a/glusterfs/ansible/setup_galery.yml b/glusterfs/ansible/setup_galery.yml new file mode 100644 index 0000000..8217daa --- /dev/null +++ b/glusterfs/ansible/setup_galery.yml @@ -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 \ No newline at end of file diff --git a/glusterfs/inventory/terraform_hosts.yml b/glusterfs/inventory/terraform_hosts.yml new file mode 100755 index 0000000..5b0d9b9 --- /dev/null +++ b/glusterfs/inventory/terraform_hosts.yml @@ -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" diff --git a/glusterfs/terraform/glusternode.tf b/glusterfs/terraform/glusternode.tf index 74dc514..d834c8a 100644 --- a/glusterfs/terraform/glusternode.tf +++ b/glusterfs/terraform/glusternode.tf @@ -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" + } \ No newline at end of file diff --git a/glusterfs/terraform/inventory.tf b/glusterfs/terraform/inventory.tf new file mode 100644 index 0000000..5db63dd --- /dev/null +++ b/glusterfs/terraform/inventory.tf @@ -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" +} diff --git a/glusterfs/terraform/jumphost.tf b/glusterfs/terraform/jumphost.tf index 344047b..6fbedef 100644 --- a/glusterfs/terraform/jumphost.tf +++ b/glusterfs/terraform/jumphost.tf @@ -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" } \ No newline at end of file diff --git a/glusterfs/terraform/provider.tf b/glusterfs/terraform/provider.tf index 091b628..4a9f6c0 100644 --- a/glusterfs/terraform/provider.tf +++ b/glusterfs/terraform/provider.tf @@ -5,6 +5,10 @@ terraform { source = "telmate/proxmox" version = "3.0.2-rc07" } + local = { + source = "hashicorp/local" + version = "2.7.0" + } } } diff --git a/glusterfs/terraform/templates/inventory.yml.tftpl b/glusterfs/terraform/templates/inventory.yml.tftpl new file mode 100644 index 0000000..c9cc9d9 --- /dev/null +++ b/glusterfs/terraform/templates/inventory.yml.tftpl @@ -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 ~} \ No newline at end of file