0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-06-30 02:31:10 +00:00

misc: update documentation

Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
Pavel Boldyrev 2024-05-05 15:23:21 -04:00
parent ce47411f99
commit b6af836386
No known key found for this signature in database
GPG Key ID: 02A24794ADAC7455
40 changed files with 139 additions and 89 deletions

View File

@ -37,7 +37,8 @@ If applicable, add screenshots to help explain your problem.
Add any other context about the problem here.
- Single or clustered Proxmox:
- Proxmox version:
- Provider version (ideally it should be the latest version):
- Terraform version:
- OS (where you run Terraform from):
- Terraform/OpenTofu version:
- OS (where you run Terraform/OpenTofu from):
- Debug logs (`TF_LOG=DEBUG terraform apply`):

View File

@ -78,7 +78,7 @@ testing changes to the provider before submitting a PR.
- Create a $HOME/.terraformrc (POSIX) or %APPDATA%/terraform.rc (Windows) file with the following contents:
```terraform
```hcl
provider_installation {
dev_overrides {

View File

@ -142,3 +142,10 @@ See [CONTRIBUTORS.md](CONTRIBUTORS.md) for a list of contributors to this projec
- [Ben Bouillet](https://github.com/benbouillet)
Thanks again for your support, it is much appreciated! 🙏
## Acknowledgements
This project has been developed with **GoLand** IDE under the [JetBrains Open Source license](https://www.jetbrains.com/community/opensource/#support), generously provided by JetBrains s.r.o.
<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/GoLand_icon.png" alt="GoLand logo" width="80">

View File

@ -11,7 +11,7 @@ Retrieves information about all the datastores available to a specific node.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_datastores" "first_node" {
node_name = "first-node"
}

View File

@ -11,7 +11,7 @@ Retrieves the DNS configuration for a specific node.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_dns" "first_node" {
node_name = "first-node"
}

View File

@ -11,7 +11,7 @@ Retrieves information about a specific user group.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_group" "operations_team" {
group_id = "operations-team"
}

View File

@ -11,7 +11,7 @@ Retrieves basic information about all available user groups.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_groups" "available_groups" {}
```

View File

@ -11,7 +11,7 @@ Retrieves all the host entries from a specific node.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_hosts" "first_node_host_entries" {
node_name = "first-node"
}

View File

@ -11,7 +11,7 @@ Retrieves information about node.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_node" "node" {}
```

View File

@ -11,7 +11,7 @@ Retrieves information about all available nodes.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_nodes" "available_nodes" {}
```

View File

@ -11,7 +11,7 @@ Retrieves information about a specific resource pool.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_pool" "operations_pool" {
pool_id = "operations"
}

View File

@ -11,7 +11,7 @@ Retrieves the identifiers for all the available resource pools.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_pools" "available_pools" {}
```

View File

@ -11,7 +11,7 @@ Retrieves information about a specific role.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_role" "operations_role" {
role_id = "operations"
}

View File

@ -11,7 +11,7 @@ Retrieves information about all the available roles.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_roles" "available_roles" {}
```

View File

@ -11,7 +11,7 @@ Retrieves the current time for a specific node.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_time" "first_node_time" {
node_name = "first-node"
}

View File

@ -11,7 +11,7 @@ Retrieves information about a specific user.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_user" "operations_user" {
user_id = "operation@pam"
}

View File

@ -11,7 +11,7 @@ Retrieves information about all the available users.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_users" "available_users" {}
```

View File

@ -11,7 +11,7 @@ Retrieves information about a specific VM.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_vm" "test_vm" {
node_name = "test"
vm_id = 100

View File

@ -11,7 +11,7 @@ Retrieves information about all VMs in the Proxmox cluster.
## Example Usage
```terraform
```hcl
data "proxmox_virtual_environment_vms" "ubuntu_vms" {
tags = ["ubuntu"]
}

View File

@ -12,7 +12,7 @@ Use the navigation to the left to read about the available resources.
## Example Usage
```terraform
```hcl
provider "proxmox" {
endpoint = "https://10.0.0.2:8006/"
# TODO: use terraform variable or remove the line, and use PROXMOX_VE_USERNAME environment variable
@ -41,7 +41,7 @@ Static credentials can be provided to the `proxmox` block through either a `api_
Static credentials can be provided by adding a `username` and `password`, or `api_token` in-line in the Proxmox provider block:
```terraform
```hcl
provider "proxmox" {
endpoint = "https://10.0.0.2:8006/"
username = "username@realm"
@ -51,7 +51,7 @@ provider "proxmox" {
A better approach is to extract these values into Terraform variables, and reference the variables instead:
```terraform
```hcl
provider "proxmox" {
endpoint = var.virtual_environment_endpoint
username = var.virtual_environment_username
@ -67,7 +67,7 @@ See the [Terraform documentation](https://www.terraform.io/docs/configuration/va
Instead of using static arguments, credentials can be handled through the use of environment variables.
For example:
```terraform
```hcl
provider "proxmox" {
endpoint = "https://10.0.0.2:8006/"
}
@ -91,7 +91,7 @@ For example, to import VM disks, or to uploading certain type of resources, such
The SSH connection configuration is provided via the optional `ssh` block in the `provider` block:
```terraform
```hcl
provider "proxmox" {
endpoint = "https://10.0.0.2:8006/"
username = "username@realm"
@ -124,7 +124,7 @@ you can use the `private_key` argument in the `ssh` block (or alternatively `PRO
The private key mut not be encrypted, and must be in PEM format.
You can provide the private key from a file:
```terraform
```hcl
provider "proxmox" {
// ...
ssh {
@ -135,20 +135,20 @@ provider "proxmox" {
```
Alternatively, although not recommended due to the increased risk of exposing an unprotected key, heredoc syntax can be used to supply the private key as a string.
Note that the content of the private key must not be indented:
```terraform
Note that the content of the private key is injected using `<<-` format to ignore indentation:
```hcl
provider "proxmox" {
// ...
ssh {
agent = false
private_key = <<EOF
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
<SKIPPED>
DMUWUEaH7yMCKl7uCZ9xAAAAAAECAwQF
-----END OPENSSH PRIVATE KEY-----
EOF
private_key = <<-EOF
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
<SKIPPED>
DMUWUEaH7yMCKl7uCZ9xAAAAAAECAwQF
-----END OPENSSH PRIVATE KEY-----
EOF
}
}
```
@ -158,7 +158,7 @@ EOF
By default, the provider will use the same username for the SSH connection as the one used for the Proxmox API connection (when using PAM authentication).
This can be overridden by specifying the `username` argument in the `ssh` block (or alternatively a username in the `PROXMOX_VE_SSH_USERNAME` environment variable):
```terraform
```hcl
provider "proxmox" {
// ...
@ -234,7 +234,7 @@ In some cases this may not be the desired behavior, for example, when the node h
To override the node IP address used for SSH connection, you can use the optional `node` blocks in the `ssh` block, and specify the desired IP address (or FQDN) for each node.
For example:
```terraform
```hcl
provider "proxmox" {
// ...
ssh {
@ -257,7 +257,7 @@ The provider supports SSH connection to the target node via a SOCKS5 proxy.
To enable the SOCKS5 proxy, you need to configure the `ssh` block in the `provider` block, and specify the `socks5_server` argument:
```terraform
```hcl
provider "proxmox" {
// ...
ssh {
@ -309,7 +309,7 @@ Refer to the upstream docs as needed for additional details concerning [PVE User
Generating the token will output a table containing the token's ID and secret which are meant to be concatenated into a single string for use with either the `api_token` field of the `provider` block (fine for testing but should be avoided) or sourced from the `PROXMOX_VE_API_TOKEN` environment variable.
```terraform
```hcl
provider "proxmox" {
endpoint = var.virtual_environment_endpoint
api_token = "terraform@pve!provider=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

View File

@ -11,7 +11,7 @@ Manages the custom SSL/TLS certificate for a specific node.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_certificate" "example" {
certificate = tls_self_signed_cert.proxmox_virtual_environment_certificate.cert_pem
node_name = "first-node"

View File

@ -11,7 +11,7 @@ Manages firewall options on the cluster level.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_cluster_firewall" "example" {
enabled = false

View File

@ -13,7 +13,7 @@ with rules to open the http and https ports.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_cluster_firewall_security_group" "webserver" {
name = "webserver"
comment = "Managed by Terraform"

View File

@ -11,7 +11,7 @@ Manages a container.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_container" "ubuntu_container" {
description = "Managed by Terraform"

View File

@ -11,7 +11,7 @@ Manages the DNS configuration for a specific node.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_dns" "first_node_dns_configuration" {
domain = data.proxmox_virtual_environment_dns.first_node_dns_configuration.domain
node_name = data.proxmox_virtual_environment_dns.first_node_dns_configuration.node_name

View File

@ -15,7 +15,7 @@ Manages a file.
-> The resource with this content type uses SSH access to the node. You might need to configure the [`ssh` option in the `provider` section](../index.md#node-ip-address-used-for-ssh-connection).
```terraform
```hcl
resource "proxmox_virtual_environment_file" "backup" {
content_type = "dump"
datastore_id = "local"
@ -31,7 +31,7 @@ resource "proxmox_virtual_environment_file" "backup" {
-> Consider using `proxmox_virtual_environment_download_file` resource instead. Using this resource for images is less efficient (requires to transfer uploaded image to node) though still supported.
```terraform
```hcl
resource "proxmox_virtual_environment_file" "ubuntu_container_template" {
content_type = "iso"
datastore_id = "local"
@ -49,7 +49,7 @@ resource "proxmox_virtual_environment_file" "ubuntu_container_template" {
-> The resource with this content type uses SSH access to the node. You might need to configure the [`ssh` option in the `provider` section](../index.md#node-ip-address-used-for-ssh-connection).
```terraform
```hcl
resource "proxmox_virtual_environment_file" "cloud_config" {
content_type = "snippets"
datastore_id = "local"
@ -84,7 +84,7 @@ EOF
-> Consider using `proxmox_virtual_environment_download_file` resource instead. Using this resource for container images is less efficient (requires to transfer uploaded image to node) though still supported.
```terraform
```hcl
resource "proxmox_virtual_environment_file" "ubuntu_container_template" {
content_type = "vztmpl"
datastore_id = "local"

View File

@ -13,7 +13,7 @@ created on the cluster level, on VM / Container level.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_firewall_alias" "local_network" {
depends_on = [proxmox_virtual_environment_vm.example]

View File

@ -12,7 +12,7 @@ created on the cluster level, on VM / Container level.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_firewall_ipset" "ipset" {
depends_on = [proxmox_virtual_environment_vm.example]

View File

@ -11,7 +11,7 @@ Manages firewall options on VM / Container level.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_firewall_options" "example" {
depends_on = [proxmox_virtual_environment_vm.example]

View File

@ -14,7 +14,7 @@ level, on VM / Container level.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_firewall_rules" "inbound" {
depends_on = [
proxmox_virtual_environment_vm.example,

View File

@ -11,7 +11,7 @@ Manages a user group.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_group" "operations_team" {
comment = "Managed by Terraform"
group_id = "operations-team"

View File

@ -11,7 +11,7 @@ Manages the host entries on a specific node.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_hosts" "first_node_host_entries" {
node_name = "first-node"

View File

@ -11,7 +11,7 @@ Manages a resource pool.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_pool" "operations_pool" {
comment = "Managed by Terraform"
pool_id = "operations-pool"

View File

@ -11,7 +11,7 @@ Manages a role.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_role" "operations_monitoring" {
role_id = "operations-monitoring"

View File

@ -11,7 +11,7 @@ Manages the time for a specific node.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_time" "first_node_time" {
node_name = "first-node"
time_zone = "UTC"

View File

@ -11,7 +11,7 @@ Manages a user.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_user" "operations_automation" {
acl {
path = "/vms/1234"

View File

@ -13,7 +13,7 @@ Manages a virtual machine.
## Example Usage
```terraform
```hcl
resource "proxmox_virtual_environment_vm" "ubuntu_vm" {
name = "terraform-provider-proxmox-ubuntu-vm"
description = "Managed by Terraform"
@ -634,7 +634,7 @@ attaching one disk to multiple VM will cause errors or even data corruption.
Do *not* move or resize `data_vm` disks.
(Resource `data_user_vm` should reject attempts to move or resize non-owned disks.)
```terraform
```hcl
resource "proxmox_virtual_environment_vm" "data_vm" {
node_name = "first-node"
started = false

View File

@ -12,11 +12,10 @@ description: |-
!> **DO NOT USE**
This is an experimental implementation of a Proxmox VM resource using Plugin Framework.<br><br>It is a Proof of Concept, highly experimental and **will** change in future. It does not support all features of the Proxmox API for VMs and **MUST NOT** be used in production.
-> Note: Many attributes are marked as **optional** _and_ **computed** in the schema,
-> Many attributes are marked as **optional** _and_ **computed** in the schema,
hence you may seem added to the plan with "(known after apply)" status, even if they are not set in the configuration.
This is done to support the `clone` operation, when a VM is created from an existing one,
and attributes of the original VM are copied to the new one.
and attributes of the original VM are copied to the new one.<br><br>
Computed attributes allow the provider to set those attributes without user input.
The attributes are marked as optional to allow the user to set (or overwrite) them if needed.
In order to remove the computed attribute from the plan, you can set it to an empty value (e.g. `""` for string, `[]` for collection).

View File

@ -190,14 +190,14 @@ func TestAccResourceVMInitialization(t *testing.T) {
datastore_id = "local"
node_name = "{{.NodeName}}"
source_raw {
data = <<EOF
#cloud-config
runcmd:
- apt update
- apt install -y qemu-guest-agent
- systemctl enable qemu-guest-agent
- systemctl start qemu-guest-agent
EOF
data = <<-EOF
#cloud-config
runcmd:
- apt update
- apt install -y qemu-guest-agent
- systemctl enable qemu-guest-agent
- systemctl start qemu-guest-agent
EOF
file_name = "cloud-config.yaml"
}
}
@ -260,23 +260,67 @@ EOF
}),
),
}}},
{"native cloud-init: do not upgrade packages", []resource.TestStep{
{
Config: te.renderConfig(`
resource "proxmox_virtual_environment_vm" "test_vm_cloudinit3" {
node_name = "{{.NodeName}}"
started = false
initialization {
upgrade = false
{"native cloud-init: do not upgrade packages", []resource.TestStep{{
Config: te.renderConfig(`
resource "proxmox_virtual_environment_vm" "test_vm_cloudinit3" {
node_name = "{{.NodeName}}"
started = false
initialization {
upgrade = false
}
}`),
Check: resource.ComposeTestCheckFunc(
testResourceAttributes("proxmox_virtual_environment_vm.test_vm_cloudinit3", map[string]string{
"initialization.0.upgrade": "false",
}),
),
}}},
{"cloud-init: clone", []resource.TestStep{{
Config: te.renderConfig(`
resource "proxmox_virtual_environment_vm" "test_vm_cloudinit_template" {
node_name = "{{.NodeName}}"
name = "test-vm-cloudinit-template"
started = false
template = "true"
initialization {
upgrade = false
}
}
}`),
Check: resource.ComposeTestCheckFunc(
testResourceAttributes("proxmox_virtual_environment_vm.test_vm_cloudinit3", map[string]string{
"initialization.0.upgrade": "false",
}),
),
},
}},
resource "proxmox_virtual_environment_file" "cloud_config" {
content_type = "snippets"
datastore_id = "local"
node_name = "{{.NodeName}}"
source_raw {
data = <<-EOF
#cloud-config
runcmd:
- apt update
- apt install -y qemu-guest-agent
- systemctl enable qemu-guest-agent
- systemctl start qemu-guest-agent
EOF
file_name = "cloud-config.yaml"
}
}
resource "proxmox_virtual_environment_vm" "test_vm_cloudinit" {
node_name = "{{.NodeName}}"
name = "test-vm-cloudinit"
started = false
description = "Example to cause ciupgrade issue"
clone {
vm_id = proxmox_virtual_environment_vm.test_vm_cloudinit_template.id
}
initialization {
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
}
}`),
Check: resource.ComposeTestCheckFunc(
testResourceAttributes("proxmox_virtual_environment_vm.test_vm_cloudinit", map[string]string{
"initialization.0.upgrade": "true",
}),
),
}}},
}
for _, tt := range tests {

View File

@ -12,11 +12,10 @@ description: |-
!> **DO NOT USE**
{{ .Description | trimspace }}
-> Note: Many attributes are marked as **optional** _and_ **computed** in the schema,
-> Many attributes are marked as **optional** _and_ **computed** in the schema,
hence you may seem added to the plan with "(known after apply)" status, even if they are not set in the configuration.
This is done to support the `clone` operation, when a VM is created from an existing one,
and attributes of the original VM are copied to the new one.
and attributes of the original VM are copied to the new one.<br><br>
Computed attributes allow the provider to set those attributes without user input.
The attributes are marked as optional to allow the user to set (or overwrite) them if needed.
In order to remove the computed attribute from the plan, you can set it to an empty value (e.g. `""` for string, `[]` for collection).