commit 359378debf965033bca256cda8b6dbb359739637 Author: root Date: Mon Aug 12 21:58:48 2024 +0000 FinalCommit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c29b80 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +credentials.auto.tfvars diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl new file mode 100644 index 0000000..225db56 --- /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.1-rc1" + constraints = "3.0.1-rc1" + hashes = [ + "h1:4xZeGV+uRpYX6Boe0kWI3Dw3B+x8P4tT4JTnUpE1FJU=", + "zh:4c4a5739ed8b0fdec644632de9cc3219a31022b03aaaf6b77d49efe58541d5c1", + "zh:5c97c58a1d15d3b77bade630c70c75f24cf884560625afa78f408f682c09cc05", + "zh:6b3b8a410cdf39a1cd9dffc2e62806ff91e23a77ccc310fd1ea130560a2f6634", + "zh:73fb750e3363cb1eefacd5fc714a93b9cd65f55459981eb27dd7f4ab7ae5aed7", + "zh:7b4bd5db2188cd21df1d7a49cbf893a18aaa915add400242b20f82cba41d3606", + "zh:8427be708a485325bb0cf70ff9470256e388353b80a554772f19103edf208107", + "zh:9bd7ffdcf8e19efcc90bdef55871d9e6c6d8bcaf46d6873d7faa01709154129c", + "zh:9f7dfe0f4c59fb593f936c67901e851fdfa279fa2aa5ae8f5fff29e763487861", + "zh:a61fd2386c116dd4ed1e202c10b4a3378290d29411f47f0460ba7b8d13e14c53", + "zh:cbe1be50efe3608d014c05503d65d8a3a98cec87962a8a0fdd95065b85db6d4f", + "zh:cdb175a0cb863a11090edbd50500b7d55137dbbb0d31fd119d727e12cadc6b4a", + "zh:cee3e0ed0ecaec22e58e5cec4fb202fb4f2a6779a87ef57c464c7b9c825f4c37", + "zh:e5d4e4fc9619bcfaaed159f9404457f29385dcb2f8fc42cf1b2dab4de7bdbf21", + "zh:f39ec72a5e8624949592d48dec11ef6abb811d0ae5a80b6fe356a47392a38a6a", + ] +} diff --git a/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc1/linux_amd64/LICENSE b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc1/linux_amd64/LICENSE new file mode 100644 index 0000000..57395f1 --- /dev/null +++ b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc1/linux_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-rc1/linux_amd64/README.md b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc1/linux_amd64/README.md new file mode 100644 index 0000000..eb7c72c --- /dev/null +++ b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc1/linux_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-rc1/linux_amd64/terraform-provider-proxmox_v3.0.1-rc1 b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc1/linux_amd64/terraform-provider-proxmox_v3.0.1-rc1 new file mode 100755 index 0000000..b1c512d Binary files /dev/null and b/.terraform/providers/registry.terraform.io/telmate/proxmox/3.0.1-rc1/linux_amd64/terraform-provider-proxmox_v3.0.1-rc1 differ diff --git a/lxc_container.tf b/lxc_container.tf new file mode 100644 index 0000000..218add2 --- /dev/null +++ b/lxc_container.tf @@ -0,0 +1,25 @@ +resource "proxmox_lxc" "TerraformDemo" { + target_node = "ThePearl" + hostname = "lxc-terraform" + ostemplate = "local:vztmpl/ubuntu-24.04-standard_24.04-2_amd64.tar.zst" + password = var.root_password + unprivileged = true + memory = 2048 + swap = 512 + cores = 2 + cpulimit = 2 + + ssh_public_keys = var.ssh_public_key + + // Terraform will crash without rootfs defined + rootfs { + storage = "TheTower" + size = "4G" + } + + network { + name = "eth0" + bridge = "vmbr0" + ip = "dhcp" + } +} diff --git a/providers.tf b/providers.tf new file mode 100644 index 0000000..b393dbe --- /dev/null +++ b/providers.tf @@ -0,0 +1,38 @@ +terraform { + required_version = ">=0.14" + required_providers { + proxmox = { + source = "Telmate/proxmox" + version = "3.0.1-rc1" + } + } +} +variable "root_password" { + type = string + sensitive = true +} + +variable "ssh_public_key" { + type = string + sensitive = true +} + +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_tls_insecure = true + 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 +} \ No newline at end of file diff --git a/terraform.tfstate b/terraform.tfstate new file mode 100644 index 0000000..fb8ff9d --- /dev/null +++ b/terraform.tfstate @@ -0,0 +1,112 @@ +{ + "version": 4, + "terraform_version": "1.9.4", + "serial": 1, + "lineage": "c2134f7c-ff6f-34a1-712f-396174394260", + "outputs": {}, + "resources": [ + { + "mode": "managed", + "type": "proxmox_lxc", + "name": "TerraformDemo", + "provider": "provider[\"registry.terraform.io/telmate/proxmox\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arch": "amd64", + "bwlimit": 0, + "clone": null, + "clone_storage": null, + "cmode": "tty", + "console": true, + "cores": 2, + "cpulimit": 2, + "cpuunits": 1024, + "description": "", + "features": [], + "force": false, + "full": null, + "hagroup": "", + "hastate": "", + "hookscript": "", + "hostname": "lxc-terraform", + "id": "ThePearl/lxc/119", + "ignore_unpack_errors": false, + "lock": "", + "memory": 2048, + "mountpoint": [], + "nameserver": "", + "network": [ + { + "bridge": "vmbr0", + "firewall": false, + "gw": "", + "gw6": "", + "hwaddr": "BC:24:11:9F:84:3B", + "id": 0, + "ip": "dhcp", + "ip6": "", + "mtu": 0, + "name": "eth0", + "rate": 0, + "tag": 0, + "trunks": "", + "type": "veth" + } + ], + "onboot": false, + "ostemplate": "local:vztmpl/ubuntu-24.04-standard_24.04-2_amd64.tar.zst", + "ostype": "ubuntu", + "password": "Zakaria1986!!!", + "pool": null, + "protection": false, + "restore": false, + "rootfs": [ + { + "acl": false, + "quota": false, + "replicate": false, + "ro": false, + "shared": false, + "size": "4G", + "storage": "TheTower", + "volume": "TheTower:subvol-119-disk-0" + } + ], + "searchdomain": "", + "ssh_public_keys": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO65p1xPly/h1Pso+G44zFnIBX2x7OfrZkXIb22JmW8J k_ansible", + "start": false, + "startup": "", + "swap": 512, + "tags": "", + "target_node": "ThePearl", + "template": false, + "timeouts": null, + "tty": 2, + "unique": false, + "unprivileged": true, + "unused": [], + "vmid": null + }, + "sensitive_attributes": [ + [ + { + "type": "get_attr", + "value": "password" + } + ], + [ + { + "type": "get_attr", + "value": "ssh_public_keys" + } + ] + ], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWZhdWx0IjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDAsInJlYWQiOjEyMDAwMDAwMDAwMDAsInVwZGF0ZSI6MTIwMDAwMDAwMDAwMH19" + } + ] + } + ], + "check_results": null +}