chore: add Terraform config for GlusterFS

This commit is contained in:
Benedikt Penner
2026-03-14 12:31:44 +01:00
parent 62abbf35fd
commit 1de82598cf
15 changed files with 664 additions and 0 deletions

24
glusterfs/terraform/.terraform.lock.hcl generated Normal file
View File

@@ -0,0 +1,24 @@
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/telmate/proxmox" {
version = "3.0.2-rc07"
constraints = "3.0.2-rc07"
hashes = [
"h1:zp5hpQJQ4t4zROSLqdltVpBO+Riy9VugtfFbpyTw1aM=",
"zh:2ee860cd0a368b3eaa53f4a9ea46f16dab8a97929e813ea6ef55183f8112c2ca",
"zh:415965fd915bae2040d7f79e45f64d6e3ae61149c10114efeac1b34687d7296c",
"zh:6584b2055df0e32062561c615e3b6b2c291ca8c959440adda09ef3ec1e1436bd",
"zh:65dcfad71928e0a8dd9befc22524ed686be5020b0024dc5cca5184c7420eeb6b",
"zh:7253dc29bd265d33f2791ac4f779c5413f16720bb717de8e6c5fcb2c858648ea",
"zh:7ec8993da10a47606670f9f67cfd10719a7580641d11c7aa761121c4a2bd66fb",
"zh:999a3f7a9dcf517967fc537e6ec930a8172203642fb01b8e1f78f908373db210",
"zh:a50e6df7280eb6584a5fd2456e3f5b6df13b2ec8a7fa4605511e438e1863be42",
"zh:b25b329a1e42681c509d027fee0365414f0cc5062b65690cfc3386aab16132ae",
"zh:c028877fdb438ece48f7bc02b65bbae9ca7b7befbd260e519ccab6c0cbb39f26",
"zh:cf0eaa3ea9fcc6d62793637947f1b8d7c885b6ad74695ab47e134e4ff132190f",
"zh:d5ade3fae031cc629b7c512a7b60e46570f4c41665e88a595d7efd943dde5ab2",
"zh:f388c15ad1ecfc09e7361e3b98bae9b627a3a85f7b908c9f40650969c949901c",
"zh:f415cc6f735a3971faae6ac24034afdb9ee83373ef8de19a9631c187d5adc7db",
]
}

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,53 @@
[![Build Status](https://travis-ci.com/Telmate/terraform-provider-proxmox.svg?branch=master)](https://travis-ci.com/Telmate/terraform-provider-proxmox)
# Terraform provider plugin for Proxmox
This repository provides a Terraform provider for
the [Proxmox virtualization platform](https://pve.proxmox.com/pve-docs/) and exposes Terraform resources to provision
QEMU VMs and LXC Containers.
## Getting Started
In order to get started, use [the documentation included in this repository](docs/index.md). The documentation contains
a list of the options for the provider. Moreover, there are some guides available how to combine options and start
specific VMs.
## Quick Start
Follow this [install guide](docs/guides/installation.md) to install the plugin.
## Known Limitations
* `proxmox_vm_qemu`.`disk`.`size` attribute does not match what is displayed in the Proxmox UI.
* Updates to `proxmox_vm_qemu` resources almost always result as a failed task within the Proxmox UI. This appears to be
harmless and the desired configuration changes do get applied.
* `proxmox_vm_qemu` does not (yet) validate vm names, be sure to only use alphanumeric and dashes otherwise you may get
an opaque 400 Parameter Verification failed (indicating a bad value was sent to proxmox).
* When using the `proxmox_lxc` resource, the provider will crash unless `rootfs` is defined.
* When using the Network Boot mode (PXE), a valid NIC must be defined for the VM, and the boot order must specify network first.
## Contributing
When contributing, please also add documentation to help other users.
### Debugging the provider
Debugging is available for this provider through the Terraform Plugin SDK versions 2.0.0. Therefore, the plugin can be
started with the debugging flag `--debug`.
For example (using [delve](https://github.com/go-delve/delve) as Debugger):
```bash
dlv exec --headless ./terraform-provider-my-provider -- --debug
```
For more information about debugging a provider please
see: [Debugger-Based Debugging](https://www.terraform.io/docs/extend/debugging.html#debugger-based-debugging)
## Useful links
* [Proxmox](https://www.proxmox.com/en/)
* [Proxmox documentation](https://pve.proxmox.com/pve-docs/)
* [Terraform](https://www.terraform.io/)
* [Terraform documentation](https://www.terraform.io/docs/index.html)
* [Recommended ISO builder](https://github.com/Telmate/terraform-ubuntu-proxmox-iso)

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,51 @@
[![Build Status](https://travis-ci.com/Telmate/terraform-provider-proxmox.svg?branch=master)](https://travis-ci.com/Telmate/terraform-provider-proxmox)
# Terraform provider plugin for Proxmox
This repository provides a Terraform provider for
the [Proxmox virtualization platform](https://pve.proxmox.com/pve-docs/) and exposes Terraform resources to provision
QEMU VMs and LXC Containers.
## Getting Started
In order to get started, use [the documentation included in this repository](docs/index.md). The documentation contains
a list of the options for the provider. Moreover, there are some guides available how to combine options and start
specific VMs.
## Quick Start
Follow this [install guide](docs/guides/installation.md) to install the plugin.
## Known Limitations
* `proxmox_vm_qemu`.`disk`.`size` attribute does not match what is displayed in the Proxmox UI.
* Updates to `proxmox_vm_qemu` resources almost always result as a failed task within the Proxmox UI. This appears to be
harmless and the desired configuration changes do get applied.
* When using the `proxmox_lxc` resource, the provider will crash unless `rootfs` is defined.
* When using the Network Boot mode (PXE), a valid NIC must be defined for the VM, and the boot order must specify network first.
## Contributing
When contributing, please also add documentation to help other users.
### Debugging the provider
Debugging is available for this provider through the Terraform Plugin SDK versions 2.0.0. Therefore, the plugin can be
started with the debugging flag `--debug`.
For example (using [delve](https://github.com/go-delve/delve) as Debugger):
```bash
dlv exec --headless ./terraform-provider-my-provider -- --debug
```
For more information about debugging a provider please
see: [Debugger-Based Debugging](https://www.terraform.io/docs/extend/debugging.html#debugger-based-debugging)
## Useful links
* [Proxmox](https://www.proxmox.com/en/)
* [Proxmox documentation](https://pve.proxmox.com/pve-docs/)
* [Terraform](https://www.terraform.io/)
* [Terraform documentation](https://www.terraform.io/docs/index.html)
* [Recommended ISO builder](https://github.com/Telmate/terraform-ubuntu-proxmox-iso)

View File

@@ -0,0 +1,61 @@
{
"version": 3,
"terraform_version": "1.14.6",
"backend": {
"type": "s3",
"config": {
"access_key": "GK18b7f5c00d05fc949038a389",
"acl": null,
"allowed_account_ids": null,
"assume_role": null,
"assume_role_with_web_identity": null,
"bucket": "terraform",
"custom_ca_bundle": null,
"dynamodb_endpoint": null,
"dynamodb_table": null,
"ec2_metadata_service_endpoint": null,
"ec2_metadata_service_endpoint_mode": null,
"encrypt": null,
"endpoint": null,
"endpoints": {
"dynamodb": null,
"iam": null,
"s3": "http://192.168.178.227:3900",
"sso": null,
"sts": null
},
"forbidden_account_ids": null,
"force_path_style": true,
"http_proxy": null,
"https_proxy": null,
"iam_endpoint": null,
"insecure": null,
"key": "glusterfs/terraform/terraform.tfstate",
"kms_key_id": null,
"max_retries": null,
"no_proxy": null,
"profile": null,
"region": "eu-central-1",
"retry_mode": null,
"secret_key": "bff63c14e01c067eba9753fa80db27192f3786e853a1a444bd909a066f2f09bf",
"shared_config_files": null,
"shared_credentials_file": null,
"shared_credentials_files": null,
"skip_credentials_validation": true,
"skip_metadata_api_check": true,
"skip_region_validation": true,
"skip_requesting_account_id": true,
"skip_s3_checksum": null,
"sse_customer_key": null,
"sts_endpoint": null,
"sts_region": null,
"token": null,
"use_dualstack_endpoint": null,
"use_fips_endpoint": null,
"use_lockfile": null,
"use_path_style": null,
"workspace_key_prefix": null
},
"hash": 2697435160
}
}

View File

@@ -0,0 +1,20 @@
terraform {
backend "s3" {
bucket = "terraform"
key = "glusterfs/terraform/terraform.tfstate"
region = "eu-central-1"
#region = "garage" # Matches Garage's s3_region
endpoints = {
s3 = "http://192.168.178.227:3900"
}
access_key = "GK18b7f5c00d05fc949038a389"
secret_key = "bff63c14e01c067eba9753fa80db27192f3786e853a1a444bd909a066f2f09bf"
skip_credentials_validation = true
skip_requesting_account_id = true # New: skips STS/IAM calls
skip_metadata_api_check = true
force_path_style = true
skip_region_validation = true
#skip_requests_to_secondary_region = true
}
}

View File

@@ -0,0 +1,3 @@
proxmox_api_url = "https://192.168.178.148:8006/api2/json"
proxmox_api_token_id = "root@pam!terraform"
proxmox_api_token_secret = "a6c27670-18ff-4002-9e67-75e296a0993f"

View File

@@ -0,0 +1,67 @@
resource "proxmox_vm_qemu" "cloudinit-test1" {
for_each = toset(var.hosts)
name = "${each.value}"
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 = 2
sockets = 1
type = "host"
}
memory = 4096
balloon = 1024
scsihw = "virtio-scsi-single"
# Setup the disk
disks {
ide {
ide3 {
cloudinit {
storage = "local-lvm"
}
}
}
scsi {
scsi0 {
disk {
size = "32G"
storage = var.storage_disks
discard = true
iothread = true
# Can't emulate SSDs in virtio
}
}
}
}
network {
id = 0
model = "e1000"
bridge = var.nic_name
}
vga {
type = "virtio"
}
# 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"
skip_ipv6 = true
ciuser = "clusteruser"
cipassword = "password"
ciupgrade = true
}

View File

@@ -0,0 +1,31 @@
terraform {
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "3.0.2-rc07"
}
}
}
variable "proxmox_api_url" {
type = string
}
variable "proxmox_api_token_id" {
type = string
sensitive = true
}
variable "proxmox_api_token_secret" {
type = string
sensitive = true
}
provider "proxmox" {
pm_api_url= var.proxmox_api_url
pm_api_token_id = var.proxmox_api_token_id
pm_api_token_secret = var.proxmox_api_token_secret
pm_tls_insecure = true
}

View File

@@ -0,0 +1,9 @@
{
"version": 4,
"terraform_version": "1.14.6",
"serial": 30,
"lineage": "d836755f-ecfa-60b3-e3cf-b9c4ab78bfdc",
"outputs": {},
"resources": [],
"check_results": null
}

View File

@@ -0,0 +1,283 @@
{
"version": 4,
"terraform_version": "1.14.6",
"serial": 28,
"lineage": "d836755f-ecfa-60b3-e3cf-b9c4ab78bfdc",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "proxmox_vm_qemu",
"name": "cloudinit-test1",
"provider": "provider[\"registry.terraform.io/telmate/proxmox\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"additional_wait": 5,
"agent": 1,
"agent_timeout": 90,
"args": "",
"automatic_reboot": true,
"automatic_reboot_severity": "error",
"balloon": 1024,
"bios": "seabios",
"boot": "order=scsi0",
"bootdisk": "",
"ci_wait": null,
"cicustom": null,
"cipassword": "password",
"ciupgrade": true,
"ciuser": "clusteruser",
"clone": "ubuntu-cloud-init-template",
"clone_id": null,
"clone_wait": 10,
"cores": 0,
"cpu": [
{
"affinity": "",
"cores": 2,
"flags": [],
"limit": 0,
"numa": false,
"sockets": 1,
"type": "host",
"units": 0,
"vcores": 0
}
],
"cpu_type": "",
"current_node": "pve-testing",
"default_ipv4_address": "",
"default_ipv6_address": "",
"define_connection_info": true,
"desc": "A test for using terraform and cloudinit",
"description": "Managed by Terraform.",
"disk": [],
"disks": [
{
"ide": [
{
"ide0": [],
"ide1": [],
"ide2": [],
"ide3": [
{
"cdrom": [],
"cloudinit": [
{
"storage": "local-lvm"
}
],
"disk": [],
"ignore": false,
"passthrough": []
}
]
}
],
"sata": [],
"scsi": [
{
"scsi0": [
{
"cdrom": [],
"cloudinit": [],
"disk": [
{
"asyncio": "",
"backup": true,
"cache": "",
"discard": true,
"emulatessd": false,
"format": "raw",
"id": 0,
"iops_r_burst": 0,
"iops_r_burst_length": 0,
"iops_r_concurrent": 0,
"iops_wr_burst": 0,
"iops_wr_burst_length": 0,
"iops_wr_concurrent": 0,
"iothread": true,
"linked_disk_id": -1,
"mbps_r_burst": 0,
"mbps_r_concurrent": 0,
"mbps_wr_burst": 0,
"mbps_wr_concurrent": 0,
"readonly": false,
"replicate": false,
"serial": "",
"size": "32G",
"storage": "local-lvm",
"wwn": ""
}
],
"ignore": false,
"passthrough": []
}
],
"scsi1": [],
"scsi10": [],
"scsi11": [],
"scsi12": [],
"scsi13": [],
"scsi14": [],
"scsi15": [],
"scsi16": [],
"scsi17": [],
"scsi18": [],
"scsi19": [],
"scsi2": [],
"scsi20": [],
"scsi21": [],
"scsi22": [],
"scsi23": [],
"scsi24": [],
"scsi25": [],
"scsi26": [],
"scsi27": [],
"scsi28": [],
"scsi29": [],
"scsi3": [],
"scsi30": [],
"scsi4": [],
"scsi5": [],
"scsi6": [],
"scsi7": [],
"scsi8": [],
"scsi9": []
}
],
"virtio": []
}
],
"efidisk": [],
"force_create": false,
"force_recreate_on_change_of": null,
"full_clone": true,
"hagroup": "",
"hastate": "",
"hostpci": [],
"hotplug": "network,disk,usb",
"id": "pve-testing/qemu/101",
"ipconfig0": "ip=dhcp,ip6=dhcp",
"ipconfig1": null,
"ipconfig10": null,
"ipconfig11": null,
"ipconfig12": null,
"ipconfig13": null,
"ipconfig14": null,
"ipconfig15": null,
"ipconfig2": null,
"ipconfig3": null,
"ipconfig4": null,
"ipconfig5": null,
"ipconfig6": null,
"ipconfig7": null,
"ipconfig8": null,
"ipconfig9": null,
"kvm": true,
"linked_vmid": 0,
"machine": "",
"memory": 2048,
"name": "terraform-test-vm",
"nameserver": null,
"network": [
{
"bridge": "vmbr0",
"firewall": false,
"id": 0,
"link_down": false,
"macaddr": "bc:24:11:42:9b:07",
"model": "e1000",
"mtu": 0,
"queues": 0,
"rate": 0,
"tag": 0
}
],
"numa": false,
"onboot": null,
"os_network_config": null,
"os_type": "cloud-init",
"pci": [],
"pcis": [],
"pool": "",
"protection": false,
"pxe": null,
"qemu_os": "other",
"reboot_required": false,
"rng": [],
"scsihw": "virtio-scsi-single",
"searchdomain": null,
"serial": [],
"skip_ipv4": false,
"skip_ipv6": true,
"smbios": [
{
"family": "",
"manufacturer": "",
"product": "",
"serial": "",
"sku": "",
"uuid": "4a4ba40e-3d3f-4b2e-9945-d6725bd771da",
"version": ""
}
],
"sockets": 0,
"ssh_forward_ip": null,
"ssh_host": "",
"ssh_port": "22",
"ssh_private_key": null,
"ssh_user": null,
"sshkeys": null,
"start_at_node_boot": false,
"startup": null,
"startup_shutdown": [
{
"order": -1,
"shutdown_timeout": -1,
"startup_delay": -1
}
],
"tablet": true,
"tags": "",
"target_node": "pve-testing",
"target_nodes": null,
"timeouts": null,
"tpm_state": [],
"unused_disk": [],
"usb": [],
"usbs": [],
"vcpus": 0,
"vga": [
{
"memory": null,
"type": "virtio"
}
],
"vm_state": "running",
"vmid": 101
},
"sensitive_attributes": [
[
{
"type": "get_attr",
"value": "cipassword"
}
],
[
{
"type": "get_attr",
"value": "ssh_private_key"
}
]
],
"identity_schema_version": 0,
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWZhdWx0IjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDAsInJlYWQiOjEyMDAwMDAwMDAwMDAsInVwZGF0ZSI6MTIwMDAwMDAwMDAwMH19"
}
]
}
],
"check_results": null
}

View File

@@ -0,0 +1,20 @@
variable "proxmox_host" {
default = "pve-testing"
}
variable "template_name" {
default = "ubuntu-2404-ci"
}
variable "storage_disks" {
default = "local-lvm"
}
variable "nic_name" {
default = "vmbr0"
}
variable "hosts" {
type = list(string)
default = ["gluster1", "gluster2", "gluster3"]
}