example | ||
proxmox | ||
proxmoxtf | ||
.gitignore | ||
.travis.yml | ||
CHANGELOG.md | ||
go.mod | ||
go.sum | ||
LICENSE | ||
main.go | ||
Makefile | ||
README.md |
Terraform Provider for Proxmox
A Terraform Provider which adds support for Proxmox solutions.
Requirements
Table of contents
Building the Provider
Clone repository to: $GOPATH/src/github.com/danitso/terraform-provider-proxmox
$ mkdir -p $GOPATH/src/github.com/danitso; cd $GOPATH/src/github.com/danitso
$ git clone git@github.com:danitso/terraform-provider-proxmox
Enter the provider directory, initialize and build the provider
$ cd $GOPATH/src/github.com/danitso/terraform-provider-proxmox
$ make init
$ make build
Using the Provider
If you're building the provider, follow the instructions to install it as a plugin. After placing it into your plugins directory, run terraform init
to initialize it.
Configuration
Arguments
virtual_environment
- (Optional) This is the configuration block for the Proxmox Virtual Environmentendpoint
- (Required) The endpoint for the Proxmox Virtual Environment APIinsecure
- (Optional) Whether to skip the TLS verification step (defaults tofalse
)password
- (Required) The password for the Proxmox Virtual Environment APIusername
- (Required) The username for the Proxmox Virtual Environment API
Environment variables
You can set up the provider by passing environment variables instead of specifying arguments.
PROXMOX_VE_ENDPOINT
orPM_VE_ENDPOINT
- The endpoint for the Proxmox Virtual Environment APIPROXMOX_VE_INSECURE
orPM_VE_INSECURE
- Whether to skip the TLS verification stepPROXMOX_VE_PASSWORD
orPM_VE_PASSWORD
- The password for the Proxmox Virtual Environment APIPROXMOX_VE_USERNAME
orPM_VE_USERNAME
- The username for the Proxmox Virtual Environment API
provider "proxmox" {
virtual_environment {}
}
Usage
$ export PROXMOX_VE_ENDPOINT="https://hostname:8006"
$ export PROXMOX_VE_INSECURE="true"
$ export PROXMOX_VE_PASSWORD="a-strong-password"
$ export PROXMOX_VE_USERNAME="username@realm"
$ terraform plan
You can omit PROXMOX_VE_INSECURE
, if the Proxmox Virtual Environment API is exposing a certificate trusted by your operating system.
Data Sources
Virtual Environment
Datastores (proxmox_virtual_environment_datastores)
Arguments
node_name
- (Required) A node name
Attributes
active
- Whether the datastore is activecontent_types
- The allowed content typesdatastore_ids
- The datastore idsenabled
- Whether the datastore is enabledshared
- Whether the datastore is sharedspace_available
- The available space in bytesspace_total
- The total space in bytesspace_used
- The used space in bytestypes
- The storage types
Group (proxmox_virtual_environment_group)
Arguments
group_id
- (Required) The group id
Attributes
acl
- The access control listpath
- The pathpropagate
- Whether to propagate to child pathsrole_id
- The role id
comment
- The group commentmembers
- The group members as a list withusername@realm
entries
Groups (proxmox_virtual_environment_groups)
Arguments
This data source doesn't accept arguments.
Attributes
comments
- The group commentsgroup_ids
- The group ids
Nodes (proxmox_virtual_environment_nodes)
Arguments
This data source doesn't accept arguments.
Attributes
cpu_count
- The CPU count for each nodecpu_utilization
- The CPU utilization on each nodememory_available
- The memory available on each nodememory_used
- The memory used on each nodenames
- The node namesonline
- Whether a node is onlinessl_fingerprints
- The SSL fingerprint for each nodesupport_levels
- The support level for each nodeuptime
- The uptime in seconds for each node
Pool (proxmox_virtual_environment_pool)
Arguments
pool_id
- (Required) The pool id
Attributes
comment
- The pool commentmembers
- The pool membersdatastore_id
- The datastore idid
- The member idnode_name
- The node nametype
- The member typevm_id
- The virtual machine id
Pools (proxmox_virtual_environment_pools)
Arguments
This data source doesn't accept arguments.
Attributes
pool_ids
- The pool ids
Role (proxmox_virtual_environment_role)
Arguments
role_id
- (Required) The role id
Attributes
privileges
- The role privileges
Roles (proxmox_virtual_environment_roles)
Arguments
This data source doesn't accept arguments.
Attributes
privileges
- The role privilegesrole_ids
- The role idsspecial
- Whether the role is special (built-in)
User (proxmox_virtual_environment_user)
Arguments
user_id
- (Required) The user id.
Attributes
acl
- The access control listpath
- The pathpropagate
- Whether to propagate to child pathsrole_id
- The role id
comment
- The user commentemail
- The user's email addressenabled
- Whether the user account is enabledexpiration_date
- The user account's expiration date (RFC 3339)first_name
- The user's first namegroups
- The user's groupskeys
- The user's keyslast_name
- The user's last name
Users (proxmox_virtual_environment_users)
Arguments
This data source doesn't accept arguments.
Attributes
comments
- The user commentsemails
- The users' email addressesenabled
- Whether a user account is enabledexpiration_dates
- The user accounts' expiration dates (RFC 3339)first_names
- The users' first namesgroups
- The users' groupskeys
- The users' keyslast_names
- The users' last namesuser_ids
- The user ids
Version (proxmox_virtual_environment_version)
Arguments
This data source doesn't accept arguments.
Attributes
keyboard_layout
- The keyboard layoutrelease
- The release numberrepository_id
- The repository idversion
- The version string
Resources
Virtual Environment
File (proxmox_virtual_environment_file)
Arguments
content_type
- (Optional) The content type (backup
,images
,iso
orvztmpl
)datastore_id
- (Required) The datastore idnode_name
- (Required) The node nameoverride_file_name
- (Optional) The file name to use instead of the source file namesource
- (Required) A path to a local file or a URLsource_checksum
- (Optional) The SHA256 checksum of the source filesource_insecure
- (Optional) Whether to skip the TLS verification step for HTTPS sources (defaults tofalse
)
Attributes
file_modification_date
- The file modification date (RFC 3339)file_name
- The file namefile_size
- The file size in bytesfile_tag
- The file tag
Group (proxmox_virtual_environment_group)
Arguments
acl
- (Optional) The access control list (multiple blocks supported)path
- The pathpropagate
- Whether to propagate to child pathsrole_id
- The role id
comment
- (Optional) The group commentgroup_id
- (Required) The group id
Attributes
members
- The group members as a list withusername@realm
entries
Pool (proxmox_virtual_environment_pool)
Arguments
comment
- (Optional) The pool commentpool_id
- (Required) The pool id
Attributes
members
- The pool membersdatastore_id
- The datastore idid
- The member idnode_name
- The node nametype
- The member typevm_id
- The virtual machine id
Role (proxmox_virtual_environment_role)
Arguments
privileges
- (Required) The role privilegesrole_id
- (Required) The role id
Attributes
This resource doesn't expose any additional attributes.
User (proxmox_virtual_environment_user)
Arguments
acl
- (Optional) The access control list (multiple blocks supported)path
- The pathpropagate
- Whether to propagate to child pathsrole_id
- The role id
comment
- (Optional) The user commentemail
- (Optional) The user's email addressenabled
- (Optional) Whether the user account is enabledexpiration_date
- (Optional) The user account's expiration date (RFC 3339)first_name
- (Optional) The user's first namegroups
- (Optional) The user's groupskeys
- (Optional) The user's keyslast_name
- (Optional) The user's last namepassword
- (Required) The user's passworduser_id
- (Required) The user id
Attributes
This resource doesn't expose any additional attributes.
VM (proxmox_virtual_environment_vm)
Arguments
agent
- (Optional) The QEMU agent configurationenabled
- (Optional) Whether to enable the QEMU agent (defaults tofalse
)trim
- (Optional) Whether to enable the FSTRIM feature in the QEMU agent (defaults tofalse
)type
- (Optional) The QEMU agent interface type (defaults tovirtio
)
cdrom
- (Optional) The CDROM configurationenabled
- (Optional) Whether to enable the CDROM drive (defaults tofalse
)file_id
- (Optional) A file ID for an ISO file (defaults tocdrom
as in the physical drive)
cloud_init
- (Optional) The cloud-init configuration (conflicts withcdrom
)dns
- (Optional) The DNS configurationdomain
- (Optional) The DNS search domainserver
- (Optional) The DNS server
ip_config
- (Optional) The IP configuration (one block per network device)ipv4
- (Optional) The IPv4 configurationaddress
- (Optional) The IPv4 address (usedhcp
for autodiscovery)gateway
- (Optional) The IPv4 gateway (must be omitted whendhcp
is used as the address)
ipv6
- (Optional) The IPv4 configurationaddress
- (Optional) The IPv6 address (usedhcp
for autodiscovery)gateway
- (Optional) The IPv6 gateway (must be omitted whendhcp
is used as the address)
user_account
- (Required) The user account configurationkeys
- (Required) The SSH keysusername
- (Required) The SSH username
cpu
- (Optional) The CPU configurationcores
- (Optional) The number of CPU cores (defaults to1
)hotplugged
- (Optional) The number of hotplugged vCPUs (defaults to0
)sockets
- (Optional) The number of CPU sockets (defaults to1
)
description
- (Optional) The descriptiondisk
- (Optional) The disk configuration (multiple blocks supported)datastore_id
- (Optional) The ID of the datastore to create the disk in (defaults tolocal-lvm
)enabled
- (Optional) Whether to enable the disk (defaults totrue
)file_format
- (Optional) The file format (defaults toqcow2
)file_id
- (Optional) The file ID for a disk imagesize
- (Optional) The disk size in gigabytes (defaults to8
)
keyboard_layout
- (Optional) The keyboard layout (defaults toen-us
)memory
- (Optional) The memory configurationdedicated
- (Optional) The dedicated memory in megabytes (defaults to512
)floating
- (Optional) The floating memory in megabytes (defaults to0
)shared
- (Optional) The shared memory in megabytes (defaults to0
)
name
- (Optional) The namenetwork_device
- (Optional) The network device configuration (multiple blocks supported)bridge
- (Optional) The name of the network bridge (defaults tovmbr0
)enabled
- (Optional) Whether to enable the network device (defaults totrue
)mac_address
- (Optional) The MAC addressmodel
- (Optional) The network device model (defaults tovirtio
)vlan_id
- (Optional) The VLAN identifier
node_name
- (Required) The name of the node to assign the virtual machine toos_type
- (Optional) The OS type (defaults toother
)pool_id
- (Optional) The ID of a pool to assign the virtual machine tovm_id
- (Optional) The ID
Attributes
This resource doesn't expose any additional attributes.
Developing the Provider
If you wish to work on the provider, you'll first need Go installed on your machine (version 1.13+ is required). You'll also need to correctly setup a GOPATH, as well as adding $GOPATH/bin
to your $PATH
.
To compile the provider, run make build
. This will build the provider and put the provider binary in the $GOPATH/bin
directory.
$ make build
...
$ $GOPATH/bin/terraform-provider-proxmox
...
If you wish to contribute to the provider, the following requirements must be met,
- All tests must pass using
make test
- The Go code must be formatted using Gofmt
- Dependencies are installed by
make init
Testing the Provider
In order to test the provider, you can simply run make test
.
$ make test
Tests are limited to regression tests, ensuring backwards compability.