init
This commit is contained in:
commit
f4a25faaf3
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
./terraform/.terraform
|
||||
./terraform/terraform.tfvars
|
||||
terraform.tfvars
|
||||
*.tfvars
|
||||
terraform/.terraform/
|
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1744463964,
|
||||
"narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
35
flake.nix
Normal file
35
flake.nix
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
description = "Terraform + Proxmox Dev Shell";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
in {
|
||||
devShells.default = pkgs.mkShell {
|
||||
name = "terraform-proxmox-env";
|
||||
|
||||
buildInputs = [
|
||||
pkgs.terraform
|
||||
pkgs.curl # for debugging Proxmox API
|
||||
pkgs.jq # useful for handling JSON responses
|
||||
pkgs.git
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
fish
|
||||
echo "🌱 Terraform + Proxmox dev shell ready"
|
||||
echo "→ Run 'terraform init' in your terraform/ directory"
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
|
19
terraform/.gitea/workflows/demo.yaml
Normal file
19
terraform/.gitea/workflows/demo.yaml
Normal file
@ -0,0 +1,19 @@
|
||||
name: Gitea Actions Demo
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
Explore-Gitea-Actions:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||
- name: List files in the repository
|
||||
run: |
|
||||
ls ${{ gitea.workspace }}
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
24
terraform/.terraform.lock.hcl
generated
Normal file
24
terraform/.terraform.lock.hcl
generated
Normal 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.1-rc8"
|
||||
constraints = "3.0.1-rc8"
|
||||
hashes = [
|
||||
"h1:W5X4T5AZUaqO++aAequNECUKJaXLC5upcws6Vp7mkBk=",
|
||||
"zh:0272f1600251abf9b139c2683f83cde0a907ac762f5ead058b84de18ddc1d78e",
|
||||
"zh:328e708a8063a133516612b17c8983a9372fa42766530925d1d37aeb1daa30ec",
|
||||
"zh:3449150e4d57f79af6f9583e93e3a5ab84fb475bc594de75b968534f57af2871",
|
||||
"zh:58d803a0203241214f673c80350d43ce1a5ce57b21b83ba08d0d08e8c389dcc4",
|
||||
"zh:59e3e99afc1ea404e530100725403c1610d682cfd27eeeaf35190c119b76a4db",
|
||||
"zh:666cb7d299824152714202e8fda000c2e37346f2ae6d0a0e3c6f6bd68ef5d9ca",
|
||||
"zh:6a1290b85e7bf953664b21b2a1ea554923a060f2a8347d8d5bb3d2b5157f85d2",
|
||||
"zh:72230960c49fe7050a5e80ee10fa24cdac94dbab82744bccb6aa251741eb5aa9",
|
||||
"zh:91f655c41f5af9a9fdcf6104c3d0a553eaa0fb3390af81051e744f30accd5b52",
|
||||
"zh:aa08a22bf737d5840573bb6030617ab6bba2a292f4b9c88b20477cdcfb9676a9",
|
||||
"zh:b72012cc284cad488207532b6668c58999c972d837b5f486db1d7466d686d5fd",
|
||||
"zh:e24f934249a6ab4d3705c1398226d4d9df1e81ef8a36592389be02bc35cc661f",
|
||||
"zh:e9e6bcef8b6a6b5ff2317168c2c23e4c55ae23f883ba158d2c4fd6324a0413e5",
|
||||
"zh:ffa1e742a8c50babd8dbfcd6884740f9bea8453ec4d832717ff006a4fbfffa91",
|
||||
]
|
||||
}
|
45
terraform/main.tf
Normal file
45
terraform/main.tf
Normal file
@ -0,0 +1,45 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "Telmate/proxmox"
|
||||
version = "3.0.1-rc8"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
pm_api_url = var.pm_api_url
|
||||
pm_user = var.pm_user
|
||||
pm_password = var.proxmox_password
|
||||
pm_tls_insecure = true
|
||||
}
|
||||
|
||||
resource "proxmox_vm_qemu" "alpine" {
|
||||
count = var.vm_count
|
||||
vmid = 400 + count.index + 1
|
||||
name = "Alpine-${count.index + 1}"
|
||||
target_node = var.target_node
|
||||
clone = var.clone_template
|
||||
sockets = var.sockets
|
||||
cores = var.cores
|
||||
memory = var.memory
|
||||
agent = 1
|
||||
boot = "order=scsi0"
|
||||
os_type = "cloud-init"
|
||||
|
||||
disk {
|
||||
slot = "scsi0"
|
||||
type = "disk"
|
||||
size = var.disk_size
|
||||
storage = var.storage
|
||||
}
|
||||
|
||||
network {
|
||||
id = 0
|
||||
model = "virtio"
|
||||
bridge = var.bridge
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
22
terraform/outputs.tf
Normal file
22
terraform/outputs.tf
Normal file
@ -0,0 +1,22 @@
|
||||
output "vm_ids" {
|
||||
description = "VM IDs by name"
|
||||
value = {
|
||||
for i in range(var.vm_count) :
|
||||
"Alpine-${i + 1}" => proxmox_vm_qemu.alpine[i].vmid
|
||||
}
|
||||
}
|
||||
|
||||
output "vm_names" {
|
||||
description = "VM names"
|
||||
value = [
|
||||
for vm in proxmox_vm_qemu.alpine : vm.name
|
||||
]
|
||||
}
|
||||
|
||||
output "vm_clones" {
|
||||
description = "Template names each VM was cloned from"
|
||||
value = [
|
||||
for vm in proxmox_vm_qemu.alpine : vm.clone
|
||||
]
|
||||
}
|
||||
|
9
terraform/terraform.tfstate
Normal file
9
terraform/terraform.tfstate
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"version": 4,
|
||||
"terraform_version": "1.11.4",
|
||||
"serial": 25,
|
||||
"lineage": "7a39dd41-1655-172c-950b-b8c5398caf69",
|
||||
"outputs": {},
|
||||
"resources": [],
|
||||
"check_results": null
|
||||
}
|
226
terraform/terraform.tfstate.backup
Normal file
226
terraform/terraform.tfstate.backup
Normal file
@ -0,0 +1,226 @@
|
||||
{
|
||||
"version": 4,
|
||||
"terraform_version": "1.11.4",
|
||||
"serial": 23,
|
||||
"lineage": "7a39dd41-1655-172c-950b-b8c5398caf69",
|
||||
"outputs": {
|
||||
"vm_clones": {
|
||||
"value": [
|
||||
"Alpine-Template"
|
||||
],
|
||||
"type": [
|
||||
"tuple",
|
||||
[
|
||||
"string"
|
||||
]
|
||||
]
|
||||
},
|
||||
"vm_ids": {
|
||||
"value": {
|
||||
"Alpine-1": 400
|
||||
},
|
||||
"type": [
|
||||
"object",
|
||||
{
|
||||
"Alpine-1": "number"
|
||||
}
|
||||
]
|
||||
},
|
||||
"vm_names": {
|
||||
"value": [
|
||||
"Alpine-1"
|
||||
],
|
||||
"type": [
|
||||
"tuple",
|
||||
[
|
||||
"string"
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "proxmox_vm_qemu",
|
||||
"name": "alpine",
|
||||
"provider": "provider[\"registry.terraform.io/telmate/proxmox\"]",
|
||||
"instances": [
|
||||
{
|
||||
"index_key": 0,
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"additional_wait": 5,
|
||||
"agent": 1,
|
||||
"agent_timeout": 90,
|
||||
"args": "",
|
||||
"automatic_reboot": true,
|
||||
"balloon": 0,
|
||||
"bios": "seabios",
|
||||
"boot": "order=scsi0",
|
||||
"bootdisk": "",
|
||||
"ci_wait": null,
|
||||
"cicustom": null,
|
||||
"cipassword": "",
|
||||
"ciupgrade": false,
|
||||
"ciuser": "",
|
||||
"clone": "Alpine-Template",
|
||||
"clone_id": null,
|
||||
"clone_wait": 10,
|
||||
"cores": 2,
|
||||
"cpu": null,
|
||||
"cpu_type": "host",
|
||||
"current_node": "flex",
|
||||
"default_ipv4_address": "",
|
||||
"default_ipv6_address": "",
|
||||
"define_connection_info": true,
|
||||
"desc": "Managed by Terraform.",
|
||||
"disk": [
|
||||
{
|
||||
"asyncio": "",
|
||||
"backup": true,
|
||||
"cache": "",
|
||||
"discard": false,
|
||||
"disk_file": "",
|
||||
"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": false,
|
||||
"iso": "",
|
||||
"linked_disk_id": -1,
|
||||
"mbps_r_burst": 0,
|
||||
"mbps_r_concurrent": 0,
|
||||
"mbps_wr_burst": 0,
|
||||
"mbps_wr_concurrent": 0,
|
||||
"passthrough": false,
|
||||
"readonly": false,
|
||||
"replicate": false,
|
||||
"serial": "",
|
||||
"size": "15G",
|
||||
"slot": "scsi0",
|
||||
"storage": "Flash",
|
||||
"type": "disk",
|
||||
"wwn": ""
|
||||
}
|
||||
],
|
||||
"disks": [],
|
||||
"efidisk": [],
|
||||
"force_create": false,
|
||||
"force_recreate_on_change_of": null,
|
||||
"full_clone": true,
|
||||
"hagroup": "",
|
||||
"hastate": "",
|
||||
"hostpci": [],
|
||||
"hotplug": "network,disk,usb",
|
||||
"id": "flex/qemu/400",
|
||||
"ipconfig0": null,
|
||||
"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": "Alpine-1",
|
||||
"nameserver": null,
|
||||
"network": [
|
||||
{
|
||||
"bridge": "vmbr0",
|
||||
"firewall": false,
|
||||
"id": 0,
|
||||
"link_down": false,
|
||||
"macaddr": "bc:24:11:42:6e:29",
|
||||
"model": "virtio",
|
||||
"mtu": 0,
|
||||
"queues": 0,
|
||||
"rate": 0,
|
||||
"tag": 0
|
||||
}
|
||||
],
|
||||
"numa": false,
|
||||
"onboot": false,
|
||||
"os_network_config": null,
|
||||
"os_type": "cloud-init",
|
||||
"pci": [],
|
||||
"pcis": [],
|
||||
"pool": "",
|
||||
"protection": false,
|
||||
"pxe": null,
|
||||
"qemu_os": "l26",
|
||||
"reboot_required": false,
|
||||
"scsihw": "lsi",
|
||||
"searchdomain": null,
|
||||
"serial": [],
|
||||
"skip_ipv4": false,
|
||||
"skip_ipv6": false,
|
||||
"smbios": [
|
||||
{
|
||||
"family": "",
|
||||
"manufacturer": "",
|
||||
"product": "",
|
||||
"serial": "",
|
||||
"sku": "",
|
||||
"uuid": "7e462704-9013-4e96-9652-37e66a7cdf5f",
|
||||
"version": ""
|
||||
}
|
||||
],
|
||||
"sockets": 1,
|
||||
"ssh_forward_ip": null,
|
||||
"ssh_host": "",
|
||||
"ssh_port": "22",
|
||||
"ssh_private_key": null,
|
||||
"ssh_user": null,
|
||||
"sshkeys": null,
|
||||
"startup": "",
|
||||
"tablet": true,
|
||||
"tags": "",
|
||||
"target_node": "flex",
|
||||
"target_nodes": null,
|
||||
"timeouts": null,
|
||||
"tpm_state": [],
|
||||
"unused_disk": [],
|
||||
"usb": [],
|
||||
"usbs": [],
|
||||
"vcpus": 0,
|
||||
"vga": [],
|
||||
"vm_state": "running",
|
||||
"vmid": 400
|
||||
},
|
||||
"sensitive_attributes": [
|
||||
[
|
||||
{
|
||||
"type": "get_attr",
|
||||
"value": "cipassword"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"type": "get_attr",
|
||||
"value": "ssh_private_key"
|
||||
}
|
||||
]
|
||||
],
|
||||
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWZhdWx0IjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDAsInJlYWQiOjEyMDAwMDAwMDAwMDAsInVwZGF0ZSI6MTIwMDAwMDAwMDAwMH19"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"check_results": null
|
||||
}
|
58
terraform/variables.tf
Normal file
58
terraform/variables.tf
Normal file
@ -0,0 +1,58 @@
|
||||
variable "proxmox_password" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "target_node" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "clone_template" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "vm_name" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "cores" {
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "memory" {
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "disk_size" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "sockets" {
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "bridge" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "disk_type" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "storage" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "pm_api_url" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "pm_user" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "vm_count" {
|
||||
type = number
|
||||
description = "How many Alpine VMs to create"
|
||||
default = 3
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user