commit 5eb40abcb0f1283cff1643fd9aca2edb4b8fcf72 Author: reyo Date: Wed Oct 29 20:52:42 2025 +0700 first add diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl new file mode 100644 index 0000000..ae004d8 --- /dev/null +++ b/.terraform.lock.hcl @@ -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-rc05" + constraints = "3.0.2-rc05" + hashes = [ + "h1:lHJMTQsDokWsDYmFVCbbe7M0Y2iLH0o7BKmYS7X7bvs=", + "zh:042d748367f33aaf440698644be4f2a2875f9db31915c1ef84616f176fc6174f", + "zh:1488781da1920d60d933c8ce926c34b5e989ffae58e3fbe437973d2b1d2faafc", + "zh:283dd6f74627f1d1d75d616b31f8ced3f97fd5277a07c9535e85cfa765d7a321", + "zh:378f1c2da21aeea083ac2e632db274a02c7a01e2486a40d3c813d05a21142db3", + "zh:38d63d0961f8c32273392caaace30f50cff8ab06e5dda17f67a8827ebffeba98", + "zh:52159782df101ec98f20faff81e8f2d9d92cb4ec903314fcddcc57ec16cdaacb", + "zh:6ca47b90c66b1d2706cb3cbb05da8b3f90a202c4865010202b2962e2b64d217e", + "zh:6e7b85cb2380e4dc0be694dd0e4a24927f7f66df41960eca3cfe907443d4f0b9", + "zh:758775f733673ab5c196db6a33648458037746f94d4bef7ce148cb01474efe2d", + "zh:7c31a3ca6d52db39da2bdd60be37af71d59d808fc206de50fe661535ea436da3", + "zh:af16984350a2f4d77c21f66a479007801e2527543310567c99cd82eb421e249e", + "zh:c1f965d3f96cf3f87af2c12ab9d4bde42f8ef660f8dc34ba3cfc9b20435a7269", + "zh:c2b9022a31103919a5ffbac6ee8d7feb6c4f5f580c1766f769569c2e8e4ce7f1", + "zh:e90162c42f1237323291e3d0de0c62701b3f89350fae18246da06702f41a6123", + ] +} diff --git a/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc3/windows_amd64/LICENSE b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc3/windows_amd64/LICENSE new file mode 100644 index 0000000..57395f1 --- /dev/null +++ b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc3/windows_amd64/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 + +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. \ No newline at end of file diff --git a/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc3/windows_amd64/README.md b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc3/windows_amd64/README.md new file mode 100644 index 0000000..eb7c72c --- /dev/null +++ b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc3/windows_amd64/README.md @@ -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) diff --git a/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc3/windows_amd64/terraform-provider-proxmox_v3.0.1-rc3.exe b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc3/windows_amd64/terraform-provider-proxmox_v3.0.1-rc3.exe new file mode 100644 index 0000000..572ad33 Binary files /dev/null and b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc3/windows_amd64/terraform-provider-proxmox_v3.0.1-rc3.exe differ diff --git a/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.2-rc05/windows_amd64/LICENSE b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.2-rc05/windows_amd64/LICENSE new file mode 100644 index 0000000..57395f1 --- /dev/null +++ b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.2-rc05/windows_amd64/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 + +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. \ No newline at end of file diff --git a/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.2-rc05/windows_amd64/README.md b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.2-rc05/windows_amd64/README.md new file mode 100644 index 0000000..eb7c72c --- /dev/null +++ b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.2-rc05/windows_amd64/README.md @@ -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) diff --git a/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.2-rc05/windows_amd64/terraform-provider-proxmox_v3.0.2-rc05.exe b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.2-rc05/windows_amd64/terraform-provider-proxmox_v3.0.2-rc05.exe new file mode 100644 index 0000000..edb8b28 Binary files /dev/null and b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.2-rc05/windows_amd64/terraform-provider-proxmox_v3.0.2-rc05.exe differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..38bd7be --- /dev/null +++ b/README.md @@ -0,0 +1,236 @@ +# Terraform + Proxmox Cloud-Init Setup + +## Описание + +Этот проект демонстрирует, как: + +1. Создать **Debian/Ubuntu шаблон** с поддержкой Cloud-Init в Proxmox. +2. Подготовить шаблон для клонирования. +3. Создать виртуальную машину через **Terraform** с использованием шаблона, с настройкой CPU, диска, сети, IP и SSH-ключей. + +--- +## Шаг 0: Установка Terraform + +### Windows + +1. Скачайте Terraform: [Terraform Download](https://developer.hashicorp.com/terraform/downloads) +2. Распакуйте архив в удобную папку, например `C:\terraform` +3. Добавьте путь в `PATH`: + ```powershell + setx PATH "$env:PATH;C:\terraform" + ``` +4. Проверьте установку: + ```powershell + terraform version + ``` + +## Шаг 1: Создание Cloud-Init шаблона в Proxmox + +### 1. Скачивание ISO Debian/Ubuntu + +- Скачайте минимальный образ Debian или Ubuntu (например netinst): + - [Debian netinst](https://www.debian.org/distrib/netinst) + - [Ubuntu Server](https://ubuntu.com/download/server) + +- Загрузите ISO в Proxmox: + **Datacenter → local → ISO Images → Upload** + +--- + +### 2. Создание новой VM в Proxmox + +Пример через CLI: + +```bash +qm create 9000 --name "debian-template" --memory 2048 --cores 2 --net0 virtio,bridge=vmbr0 +qm set 9000 --scsihw virtio-scsi-pci --scsi0 local-lvm:10 +qm set 9000 --ide2 local:iso/debian-13.0.0-amd64-netinst.iso,media=cdrom +qm set 9000 --boot c --bootdisk scsi0 +``` + +Запустите VM и установите минимальную систему Debian/Ubuntu. + +--- + +### 3. Установка Cloud-Init и QEMU Guest Agent + +После установки: + +```bash +apt update +apt install -y cloud-init qemu-guest-agent +systemctl enable qemu-guest-agent +``` + +--- + +### 4. Настройка serial-консоли для Cloud-Init + +Чтобы Cloud-Init корректно работал через Proxmox: + +```bash +nano /etc/default/grub +``` + +Измените: + +``` +GRUB_CMDLINE_LINUX_DEFAULT="quiet" +``` + +на: + +``` +GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8" +``` + +Применяем: + +```bash +update-grub +systemctl enable serial-getty@ttyS0.service +``` + +--- + +### 5. Очистка шаблона + +```bash +cloud-init clean +apt clean +history -c +poweroff +``` + +--- + +### 6. Преобразование VM в шаблон + +```bash +qm template 9000 +``` + +Теперь шаблон готов для клонирования. + +--- + +## Шаг 2: Настройка Terraform + +### 1. Структура проекта + +``` +terraform-proxmox/ +├── main.tf +├── variables.tf # если используете переменные +└── terraform.tfvars +``` + +--- + +### 2. Пример `main.tf` + +```hcl +terraform { + required_providers { + proxmox = { + source = "Telmate/proxmox" + version = "3.0.2-rc05" + } + } +} + +provider "proxmox" { + pm_tls_insecure = true + pm_api_url = "https://192.168.251.251:8006/api2/json" + pm_user = "terraform@pve" + pm_password = "P@ssw0rd" +} + +resource "proxmox_vm_qemu" "vm1" { + name = "terraform-vm1" + description = "Debian VM cloned from Cloud-Init template" + target_node = "pve0" + clone = "debian-template" + # full_clone = true + agent = 1 + os_type = "cloud-init" + + # CPU and Memory + + memory = 4096 + scsihw = "virtio-scsi-pci" + bootdisk = "scsi0" + + # CPU Block is now REQUIRED[citation:5] + cpu { + type = "host" + cores = 4 # Количество ядер на сокет + sockets = 1 + + } + + # Disks must now be defined in nested `disks` blocks[citation:1][citation:3] + disks { + scsi { + scsi0 { + disk { + size = 20 + storage = "ssd1" + } + } + } + ide { + ide3 { + cloudinit { + storage = "ssd1" + } + } + } + } + + # Network must be defined in a `network` block with an ID[citation:5] + network { + id = 0 # The network ID is now required and must be in sequence (0, 1, 2...)[citation:5] + model = "virtio" + bridge = "vmbr0" + } + + # Cloud-Init + ciuser = "debian" + cipassword = "Password123!" + ipconfig0 = "ip=192.168.251.100/24,gw=192.168.251.254" +serial { + id = 0 + type = "socket" +} + # sshkeys = <