Skip to content

Commit e9c916a

Browse files
author
Grant Gongaware
committed
reformat documentation to fit terraform registry
1 parent 1929fcd commit e9c916a

File tree

7 files changed

+113
-76
lines changed

7 files changed

+113
-76
lines changed

docs/cloud_init_guide.md renamed to docs/guides/cloud_init.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Sample file
44

55
main.tf:
6-
```tf
6+
```hcl
77
/* Uses cloud-init options from Proxmox 5.2 */
88
resource "proxmox_vm_qemu" "cloudinit-test" {
99
name = "tftest1.xyz.com"

docs/installation.md renamed to docs/guides/installation.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
1-
# How to get terraform to recognize third party provider
1+
2+
# Automatic Registry Installation
3+
4+
To install this provider, copy and paste this code into your Terraform configuration (include a version tag).
5+
```hcl
6+
terraform {
7+
required_providers {
8+
proxmox = {
9+
source = "Telmate/proxmox"
10+
version = "<version tag>"
11+
}
12+
}
13+
}
14+
15+
provider "proxmox" {
16+
# Configuration options
17+
}
18+
```
19+
20+
Then, run
21+
```shell
22+
terraform init
23+
```
24+
25+
26+
# Manual Build & Install
27+
28+
## How to get terraform to recognize third party provider
229

330
Third-party plugins (both providers and provisioners) can be manually installed into the user plugins directory,
431
located at `%APPDATA%\terraform.d\plugins` on Windows and `~/.terraform.d/plugins` on other systems. Plugins come
@@ -10,14 +37,14 @@ In order to build the required executables, [install Go](https://golang.org/doc/
1037
repository and run the following commands inside the cloned repository. Since this plugin is both a provider and
1138
provisioner in one, there are two install commands.
1239

13-
```
40+
```shell
1441
go install github.com/Telmate/terraform-provider-proxmox/cmd/terraform-provider-proxmox
1542
go install github.com/Telmate/terraform-provider-proxmox/cmd/terraform-provisioner-proxmox
1643
```
1744

1845
Then create the executables. They are placed in the `bin` folder inside the repository.
1946

20-
```
47+
```shell
2148
make
2249
```
2350

docs/index.md

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,51 @@
1-
# Documentation: Terraform provider plugin for Proxmox
1+
# Proxmox Provider
22

3-
## Table of contents
3+
A Terraform provider is responsible for understanding API interactions and exposing resources. The Proxmox provider
4+
uses the Proxmox API. This provider exposes two resources: [proxmox_vm_qemu](docs/resources/vm_qemu.md) and [proxmox_lxc](docs/resources/lxc.md).
45

5-
1. [Install Terraform plugin](installation.md)
6-
1. [Terraform Provider](provider.md)
7-
1. [Terraform VM Qemu Resource](resource_vm_qemu.md)
8-
1. [Terraform LXC Resource](resource_lxc.md)
9-
1. [Cloud Init Guide](cloud_init_guide.md)
6+
## Creating the connection
7+
8+
When connecting to the Proxmox API, the provider has to know at least three parameters: the URL, username and password.
9+
One can supply fields using the provider syntax in Terraform. It is recommended to pass secrets through environment
10+
variables.
11+
12+
```bash
13+
export PM_PASS=password
14+
```
15+
16+
```hcl
17+
provider "proxmox" {
18+
pm_api_url = "https://proxmox-server01.example.com:8006/api2/json"
19+
pm_user = "terraform-user@pve"
20+
}
21+
```
22+
23+
## Argument Reference
24+
25+
The following arguments are supported in the provider block:
26+
27+
* `pm_api_url` - (Required; or use environment variable `PM_API_URL`) This is the target Proxmox API endpoint.
28+
* `pm_user` - (Required; or use environment variable `PM_USER`) The user, maybe required to include @pam.
29+
* `pm_password` - (Required; sensitive; or use environment variable `PM_PASS`) The password.
30+
* `pm_otp` - (Optional; or use environment variable `PM_OTP`) The 2FA OTP code.
31+
* `pm_tls_insecure` - (Optional) Disable TLS verification while connecting.
32+
* `pm_parallel` - (Optional; defaults to 4) Allowed simultaneous Proxmox processes (e.g. creating resources).
33+
* `pm_log_enable` - (Optional; defaults to false) Enable debug logging, see the section below for logging details.
34+
* `pm_log_levels` - (Optional) A map of log sources and levels.
35+
* `pm_log_file` - (Optional; defaults to "terraform-plugin-proxmox.log") If logging is enabled, the log file the provider will write logs to.
36+
* `pm_timeout` - (Optional; defaults to 300) Timeout value (seconds) for proxmox API calls.
37+
38+
Additionally, one can set the `PM_OTP_PROMPT` environment variable to prompt for OTP 2FA code (if required).
39+
40+
## Logging
41+
42+
The provider is able to output detailed logs upon request. Note that this feature is intended for development purposes, but could also be used to help investigate bugs. For example: the following code when placed into the provider "proxmox" block will enable loging to the file "terraform-plugin-proxmox.log". All log sources will default to the "debug" level, and any stdout/stderr from sublibraries (proxmox-api-go) will be silenced (set to non-empty string to enable).
43+
44+
```hcl
45+
pm_log_enable = true
46+
pm_log_file = "terraform-plugin-proxmox.log"
47+
pm_log_levels = {
48+
_default = "debug"
49+
_capturelog = ""
50+
}
51+
```

docs/provider.md

Lines changed: 0 additions & 54 deletions
This file was deleted.

docs/resource_lxc.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/resources/lxc.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# LXC Resource
2+
3+
Resources are the most important element in the Terraform language. Each resource block describes one or more
4+
infrastructure objects, such as virtual networks, compute instances, or higher-level components such as DNS records.
5+
6+
This resource manages a Proxmox LXC container.
7+
8+
9+
```hcl
10+
resource "proxmox_lxc" "lxc-test" {
11+
features {
12+
nesting = true
13+
}
14+
hostname = "terraform-new-container"
15+
network {
16+
name = "eth0"
17+
bridge = "vmbr0"
18+
ip = "dhcp"
19+
ip6 = "dhcp"
20+
}
21+
ostemplate = "shared:vztmpl/centos-7-default_20171212_amd64.tar.xz"
22+
password = "rootroot"
23+
pool = "terraform"
24+
storage = "local-lvm"
25+
target_node = "node-01"
26+
unprivileged = true
27+
}
28+
```

docs/resource_vm_qemu.md renamed to docs/resources/vm_qemu.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Terraform VM Qemu Resource
1+
# VM Qemu Resource
22

33
Resources are the most important element in the Terraform language. Each resource block describes one or more
44
infrastructure objects, such as virtual networks, compute instances, or higher-level components such as DNS records.
@@ -13,7 +13,7 @@ base with an ISO, and make the rest of the VM resources depend on that base "tem
1313
When creating a VM Qemu resource, you create a `proxmox_vm_qemu` resource block. The name and target node of the VM are
1414
the only required parameters.
1515

16-
```tf
16+
```hcl
1717
resource "proxmox_vm_qemu" "resource-name" {
1818
name = "VM name"
1919
target_node = "Node to create the VM on"
@@ -25,7 +25,7 @@ resource "proxmox_vm_qemu" "resource-name" {
2525
With preprovision you can provision a VM directly from the resource block. This provisioning method is therefore ran
2626
**before** provision blocks. When using preprovision, there are three `os_type` options: `ubuntu`, `centos` or `cloud-init`.
2727

28-
```tf
28+
```hcl
2929
resource "proxmox_vm_qemu" "prepprovision-test" {
3030
...
3131
preprovision = true
@@ -39,7 +39,7 @@ There is a pre-provision phase which is used to set a hostname, intialize eth0,
3939
space. This is done over SSH with the `ssh_forward_ip`, `ssh_user` and `ssh_private_key`. Disk resize is done if the file
4040
[/etc/auto_resize_vda.sh](https://github.com/Telmate/terraform-ubuntu-proxmox-iso/blob/master/auto_resize_vda.sh) exists.
4141

42-
```tf
42+
```hcl
4343
resource "proxmox_vm_qemu" "prepprovision-test" {
4444
...
4545
preprovision = true
@@ -74,7 +74,7 @@ creating a resource that is using Cloud-Init, there are multi configurations pos
7474
parameter to create based on [a Cloud-init configuration file](https://cloudinit.readthedocs.io/en/latest/topics/examples.html)
7575
or use the Proxmox variable `ciuser`, `cipassword`, `ipconfig0`, `ipconfig1`, `searchdomain`, `nameserver` and `sshkeys`.
7676

77-
For more information, see the [Cloud-init guide](cloud_init_guide.md).
77+
For more information, see the [Cloud-init guide](docs/guides/cloud_init.md).
7878

7979
## Argument reference
8080

0 commit comments

Comments
 (0)