diff --git a/.vscode/settings.json b/.vscode/settings.json index ff6e40d9..08f76250 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,7 @@ "proxmoxtf", "qcow", "rootfs", + "signoff", "tflog", "unmanaged", "virtio", diff --git a/Makefile b/Makefile index 1ba676e3..41c4f83e 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,22 @@ -GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor) NAME=terraform-provider-proxmox TARGETS=darwin linux windows TERRAFORM_PLUGIN_EXTENSION= VERSION=0.44.0# x-release-please-version +# check if opentofu is installed and use it if it is, +# otherwise use terraform +ifeq ($(shell tofu -version 2>/dev/null),) + TERRAFORM_EXECUTABLE=terraform +else + TERRAFORM_EXECUTABLE=tofu +endif + ifeq ($(OS),Windows_NT) TERRAFORM_PLATFORM=windows_amd64 TERRAFORM_PLUGIN_CACHE_DIRECTORY=$$(cygpath -u "$(shell pwd -P)")/cache/plugins TERRAFORM_PLUGIN_EXTENSION=.exe else - TERRAFORM_PLATFORM=$$(terraform -version | awk 'FNR == 2 {print $$2}') + TERRAFORM_PLATFORM=$$($(TERRAFORM_EXECUTABLE) -version | awk 'FNR == 2 {print $$2}') TERRAFORM_PLUGIN_CACHE_DIRECTORY=$(shell pwd -P)/cache/plugins endif @@ -40,7 +47,7 @@ example-apply: && export TF_DISABLE_CHECKPOINT="true" \ && export TF_PLUGIN_CACHE_DIR="$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)" \ && cd ./example \ - && terraform apply -auto-approve + && $(TERRAFORM_EXECUTABLE) apply -auto-approve .PHONY: example-build example-build: @@ -54,7 +61,7 @@ example-destroy: && export TF_DISABLE_CHECKPOINT="true" \ && export TF_PLUGIN_CACHE_DIR="$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)" \ && cd ./example \ - && terraform destroy -auto-approve + && $(TERRAFORM_EXECUTABLE) destroy -auto-approve .PHONY: example-init example-init: @@ -63,7 +70,7 @@ example-init: && export TF_PLUGIN_CACHE_DIR="$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)" \ && cd ./example \ && rm -f .terraform.lock.hcl \ - && terraform init + && $(TERRAFORM_EXECUTABLE) init .PHONY: example-plan example-plan: @@ -71,11 +78,11 @@ example-plan: && export TF_DISABLE_CHECKPOINT="true" \ && export TF_PLUGIN_CACHE_DIR="$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)" \ && cd ./example \ - && terraform plan + && $(TERRAFORM_EXECUTABLE) plan .PHONY: fmt fmt: - gofmt -s -w $(GOFMT_FILES) + gofmt -s -w $$(find . -name '*.go') .PHONY: init init: diff --git a/README.md b/README.md index 032111b8..c29a9570 100644 --- a/README.md +++ b/README.md @@ -9,32 +9,28 @@ [![Conventional Commits](https://img.shields.io/badge/conventional%20commits-v1.0.0-ff69b4)](https://www.conventionalcommits.org/en/v1.0.0/) [![Buy Me A Coffee](https://img.shields.io/badge/-buy%20me%20a%20coffee-5F7FFF?logo=buymeacoffee&labelColor=gray&logoColor=FFDD00)](https://www.buymeacoffee.com/bpgca) -A Terraform Provider which adds support for Proxmox solutions. +A Terraform / OpenTofu Provider which adds support for Proxmox solutions. -This repository is a fork -of -which is no longer maintained. +This repository is a fork of which is no longer maintained. ## Compatibility promise -This provider is compatible with the latest version of Proxmox VE (currently -8.0). While it may work with older 7.x versions, it is not guaranteed to do so. +This provider is compatible with the latest version of Proxmox VE (currently 8.0). +While it may work with older 7.x versions, it is not guaranteed to do so. -While provider is on version 0.x, it is not guaranteed to be backwards -compatible with all previous minor versions. However, we will try to keep the -backwards compatibility between provider versions as much as possible. +While provider is on version 0.x, it is not guaranteed to be backwards compatible with all previous minor versions. +However, we will try to keep the backwards compatibility between provider versions as much as possible. ## Requirements - [Proxmox Virtual Environment](https://www.proxmox.com/en/proxmox-virtual-environment/) 8.x -- TLS 1.3 for the Proxmox API endpoint -- [Terraform](https://www.terraform.io/downloads.html) 1.4+ +- TLS 1.3 for the Proxmox API endpoint (legacy TLS 1.2 is optionally supported) +- [Terraform](https://www.terraform.io/downloads.html) 1.5.x+ or [OpenTofu](https://opentofu.org) 1.6.x - [Go](https://golang.org/doc/install) 1.21 (to build the provider plugin) ## Using the provider -You can find the latest release and its documentation in -the [Terraform Registry](https://registry.terraform.io/providers/bpg/proxmox/latest). +You can find the latest release and its documentation in the [Terraform Registry](https://registry.terraform.io/providers/bpg/proxmox/latest). ## Testing the provider @@ -46,17 +42,14 @@ make test Tests are limited to regression tests, ensuring backwards compatibility. -A limited number of acceptance tests are available in the `proxmoxtf/test` directory, mostly -for "new" functionality implemented using the Terraform Provider Framework. These tests -are not run by default, as they require a Proxmox VE environment to be available. -They can be run using `make testacc`, the Proxmox connection can be configured using -environment variables, see provider documentation for details. +A limited number of acceptance tests are available in the `proxmoxtf/test` directory, mostly for "new" functionality implemented using the Terraform Provider Framework. +These tests are not run by default, as they require a Proxmox VE environment to be available. +They can be run using `make testacc`, the Proxmox connection can be configured using environment variables, see provider documentation for details. ## Deploying the example resources -There are number of TF examples in the `example` directory, which can be used -to deploy a Container, VM, or other Proxmox resources on your test Proxmox -environment. The following assumptions are made about the test environment: +There are number of TF examples in the `example` directory, which can be used to deploy a Container, VM, or other Proxmox resources on your test Proxmox environment. +The following assumptions are made about the test environment: - It has one node named `pve` - The node has local storages named `local` and `local-lvm` @@ -72,28 +65,23 @@ virtual_environment_endpoint = "https://:8006/" Then run `make example` to deploy the example resources. -If you don't have free proxmox cluster to play with, there is dedicated [how-to tutorial](howtos/setup-proxmox-for-make-example/README.md) how to setup Proxmox inside VM and run `make example` on it. +If you don't have free proxmox cluster to play with, there is dedicated [how-to tutorial](howtos/setup-proxmox-for-tests/README.md) how to setup Proxmox inside VM and run `make example` on it. ## Future work -The provider is using -the [Terraform SDKv2](https://developer.hashicorp.com/terraform/plugin/sdkv2), -which is considered legacy and is in maintenance mode. -The work has started to migrate the provider to the -new [Terraform Plugin Framework](https://www.terraform.io/docs/extend/plugin-sdk.html), -with aim to release it as a new major version **1.0**. +The provider is using the [Terraform SDKv2](https://developer.hashicorp.com/terraform/plugin/sdkv2), which is considered legacy and is in maintenance mode. +The work has started to migrate the provider to the new [Terraform Plugin Framework](https://www.terraform.io/docs/extend/plugin-sdk.html), with aim to release it as a new major version **1.0**. ## Known issues ### Disk images cannot be imported by non-PAM accounts -Due to limitations in the Proxmox VE API, certain actions need to be performed -using SSH. This requires the use of a PAM account (standard Linux account). +Due to limitations in the Proxmox VE API, certain actions need to be performed using SSH. This requires the use of a PAM account (standard Linux account). ### Disk images from VMware cannot be uploaded or imported -Proxmox VE is not currently supporting VMware disk images directly. However, you -can still use them as disk images by using this workaround: +Proxmox VE is not currently supporting VMware disk images directly. +However, you can still use them as disk images by using this workaround: ```hcl resource "proxmox_virtual_environment_file" "vmdk_disk_image" { @@ -125,8 +113,8 @@ resource "proxmox_virtual_environment_vm" "example" { ### Snippets cannot be uploaded by non-PAM accounts -Due to limitations in the Proxmox VE API, certain files need to be uploaded -using SFTP. This requires the use of a PAM account (standard Linux account). +Due to limitations in the Proxmox VE API, certain files (snippets, backups) need to be uploaded using SFTP. +This requires the use of a PAM account (standard Linux account). ## Contributors