first commit
This commit is contained in:
commit
e5473e8df1
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
env.sh
|
||||
*.log
|
||||
*.backup
|
43
.terraform.lock.hcl
Normal file
43
.terraform.lock.hcl
Normal file
@ -0,0 +1,43 @@
|
||||
# This file is maintained automatically by "terraform init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.terraform.io/hashicorp/external" {
|
||||
version = "2.3.1"
|
||||
hashes = [
|
||||
"h1:bROCw6g5D/3fFnWeJ01L4IrdnJl1ILU8DGDgXCtYzaY=",
|
||||
"zh:001e2886dc81fc98cf17cf34c0d53cb2dae1e869464792576e11b0f34ee92f54",
|
||||
"zh:2eeac58dd75b1abdf91945ac4284c9ccb2bfb17fa9bdb5f5d408148ff553b3ee",
|
||||
"zh:2fc39079ba61411a737df2908942e6970cb67ed2f4fb19090cd44ce2082903dd",
|
||||
"zh:472a71c624952cff7aa98a7b967f6c7bb53153dbd2b8f356ceb286e6743bb4e2",
|
||||
"zh:4cff06d31272aac8bc35e9b7faec42cf4554cbcbae1092eaab6ab7f643c215d9",
|
||||
"zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
|
||||
"zh:7ed16ccd2049fa089616b98c0bd57219f407958f318f3c697843e2397ddf70df",
|
||||
"zh:842696362c92bf2645eb85c739410fd51376be6c488733efae44f4ce688da50e",
|
||||
"zh:8985129f2eccfd7f1841ce06f3bf2bbede6352ec9e9f926fbaa6b1a05313b326",
|
||||
"zh:a5f0602d8ec991a5411ef42f872aa90f6347e93886ce67905c53cfea37278e05",
|
||||
"zh:bf4ab82cbe5256dcef16949973bf6aa1a98c2c73a98d6a44ee7bc40809d002b8",
|
||||
"zh:e70770be62aa70198fa899526d671643ff99eecf265bf1a50e798fc3480bd417",
|
||||
]
|
||||
}
|
||||
|
||||
provider "registry.terraform.io/telmate/proxmox" {
|
||||
version = "2.9.14"
|
||||
constraints = "2.9.14"
|
||||
hashes = [
|
||||
"h1:H/f+LbVyPOLslHLAYnGuMMRqWFZ65K6E3V+MCYgfAyk=",
|
||||
"zh:0d049d33f705e5b814d30028770c084151218439424e99684ce31d7e26a720b5",
|
||||
"zh:20b1c64ed56d81de95f3f37b82b45b4654c0de26670c0e87a474c5cce13cd015",
|
||||
"zh:2946058abd1d8e50e475b9ec39781eb02576b40dbd80f4653fade4493a4514c6",
|
||||
"zh:29e50a25c456f040ce072f23ac57b5b82ebd3b916ca5ae6688332b5ec62adc4a",
|
||||
"zh:3612932306ce5f08db94868f526cbb8c56d0d3c6ebe1c11a83f92bbf94354296",
|
||||
"zh:42d1699b0abebaac82ea5a19f4393541d8bb2741bde204a8ac1028cdc29d1b14",
|
||||
"zh:5ffd5dc567262eb8aafdf2f6eac63f7f21361da9c5d75a3c36b479638a0001b0",
|
||||
"zh:6692ef323e3b89de99934ad731f6a1850525bf8142916ae28ea4e4048d73a787",
|
||||
"zh:a5afc98e9a4038516bb58e788cb77dea67a60dce780dfcd206d7373c5a56b776",
|
||||
"zh:bf902cded709d84fa27fbf91b589c241f2238a6c4924e4e479eebd74320b93a5",
|
||||
"zh:cab0e1e72c9cebcf669fc6f35ec28cb8ab2dffb0237afc8860aa40d23bf8a49f",
|
||||
"zh:e523b99a48beec83d9bc04b2d336266044f9f53514cefb652fe6768611847196",
|
||||
"zh:f593915e8a24829d322d2eaeedcb153328cf9042f0d84f66040dde1be70ede04",
|
||||
"zh:fba1aff541133e2129dfda0160369635ab48503d5c44b8407ce5922ecc15d0bd",
|
||||
]
|
||||
}
|
Binary file not shown.
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 <copyright holders>
|
||||
|
||||
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.
|
@ -0,0 +1,53 @@
|
||||
[![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.
|
||||
* `proxmox_vm_qemu` does not (yet) validate vm names, be sure to only use alphanumeric and dashes otherwise you may get
|
||||
an opaque 400 Parameter Verification failed (indicating a bad value was sent to proxmox).
|
||||
* 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)
|
Binary file not shown.
13
env.sh.example
Normal file
13
env.sh.example
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# env.sh
|
||||
|
||||
# Change the contents of this output to get the environment variables
|
||||
# of interest. The output must be valid JSON, with strings for both
|
||||
# keys and values.
|
||||
cat <<EOF
|
||||
{
|
||||
"PM_API_TOKEN_ID": "tf@pve!terraform",
|
||||
"PM_API_TOKEN_SECRET": "foo-bar-1234"
|
||||
}
|
||||
EOF
|
83
main.tf
Normal file
83
main.tf
Normal file
@ -0,0 +1,83 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "telmate/proxmox"
|
||||
version = "2.9.14"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "external" "env" {
|
||||
program = ["${path.module}/env.sh"]
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
pm_api_url = "https://localhost:8006/api2/json"
|
||||
pm_api_token_id = data.external.env.result["PM_API_TOKEN_ID"]
|
||||
pm_api_token_secret = data.external.env.result["PM_API_TOKEN_SECRET"]
|
||||
pm_log_enable = true
|
||||
pm_log_file = "terraform-plugin-proxmox.log"
|
||||
pm_debug = true
|
||||
pm_log_levels = {
|
||||
_default = "debug"
|
||||
_capturelog = ""
|
||||
}
|
||||
# leave tls_insecure set to true unless you have your proxmox SSL certificate situation fully sorted out (if you do, you will know)
|
||||
pm_tls_insecure = true
|
||||
}
|
||||
|
||||
# resource é o que queremos
|
||||
# unha entidade co nome "hashi" de tipo "proxmox_vm_qemu"
|
||||
resource "proxmox_vm_qemu" "hashi_server" {
|
||||
count = 1 # cantidade de instancias, 0 para destruir todas
|
||||
name = "hashi-${count.index + 1}" # autonumera
|
||||
target_node = var.proxmox_host # definese no vars.tf
|
||||
clone = var.template_name #definese no vars.tf
|
||||
full_clone = true
|
||||
|
||||
# basic VM settings here. agent refers to guest agent
|
||||
agent = 0
|
||||
os_type = "cloud-init"
|
||||
cores = 2
|
||||
sockets = 1
|
||||
cpu = "host"
|
||||
memory = 2048
|
||||
scsihw = "virtio-scsi-pci"
|
||||
bootdisk = "scsi0"
|
||||
|
||||
disk {
|
||||
slot = 0
|
||||
# set disk size here. leave it small for testing because expanding the disk takes time.
|
||||
size = "10G"
|
||||
type = "scsi"
|
||||
storage = "local-lvm"
|
||||
}
|
||||
|
||||
# if you want two NICs, just copy this whole network section and duplicate it
|
||||
network {
|
||||
model = "virtio"
|
||||
bridge = "vmbr0"
|
||||
}
|
||||
|
||||
# not sure exactly what this is for. presumably something about MAC addresses and ignore network changes during the life of the VM
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
network,
|
||||
]
|
||||
}
|
||||
|
||||
# the ${count.index + 1} thing appends text to the end of the ip address
|
||||
# in this case, since we are only adding a single VM, the IP will
|
||||
# be 192.168.1.71 since count.index starts at 0. this is how you can create
|
||||
# multiple VMs and have an IP assigned to each (.71, .72, .73, etc.)
|
||||
ipconfig0 = "ip=192.168.1.7${count.index + 1}/24,gw=192.168.1.1"
|
||||
|
||||
# username by cloud-init
|
||||
ciuser = "alpine"
|
||||
ssh_user = "alpine"
|
||||
|
||||
# sshkeys set using variables. the variable contains the text of the key.
|
||||
sshkeys = <<EOF
|
||||
${var.ssh_key}
|
||||
EOF
|
||||
}
|
188
terraform.tfstate
Normal file
188
terraform.tfstate
Normal file
@ -0,0 +1,188 @@
|
||||
{
|
||||
"version": 4,
|
||||
"terraform_version": "1.5.6",
|
||||
"serial": 26,
|
||||
"lineage": "9d9b0d60-7a22-799c-7440-c01afa77a9fb",
|
||||
"outputs": {},
|
||||
"resources": [
|
||||
{
|
||||
"mode": "data",
|
||||
"type": "external",
|
||||
"name": "env",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/external\"]",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"id": "-",
|
||||
"program": [
|
||||
"./env.sh"
|
||||
],
|
||||
"query": null,
|
||||
"result": {
|
||||
"PM_API_TOKEN_ID": "tf@pve!terraform",
|
||||
"PM_API_TOKEN_SECRET": "ad479bed-0769-4716-bf7b-55ad80a3ca8c"
|
||||
},
|
||||
"working_dir": null
|
||||
},
|
||||
"sensitive_attributes": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "proxmox_vm_qemu",
|
||||
"name": "hashi_server",
|
||||
"provider": "provider[\"registry.terraform.io/telmate/proxmox\"]",
|
||||
"instances": [
|
||||
{
|
||||
"index_key": 0,
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"additional_wait": 5,
|
||||
"agent": 0,
|
||||
"args": "",
|
||||
"automatic_reboot": true,
|
||||
"balloon": 0,
|
||||
"bios": "seabios",
|
||||
"boot": "c",
|
||||
"bootdisk": "scsi0",
|
||||
"bridge": null,
|
||||
"ci_wait": null,
|
||||
"cicustom": "",
|
||||
"cipassword": "",
|
||||
"ciuser": "alpine",
|
||||
"clone": "alpine-gold",
|
||||
"clone_wait": 10,
|
||||
"cloudinit_cdrom_storage": null,
|
||||
"cores": 2,
|
||||
"cpu": "host",
|
||||
"default_ipv4_address": null,
|
||||
"define_connection_info": true,
|
||||
"desc": "",
|
||||
"disk": [
|
||||
{
|
||||
"aio": "",
|
||||
"backup": true,
|
||||
"cache": "none",
|
||||
"discard": "",
|
||||
"file": "vm-104-disk-0",
|
||||
"format": "raw",
|
||||
"iops": 0,
|
||||
"iops_max": 0,
|
||||
"iops_max_length": 0,
|
||||
"iops_rd": 0,
|
||||
"iops_rd_max": 0,
|
||||
"iops_rd_max_length": 0,
|
||||
"iops_wr": 0,
|
||||
"iops_wr_max": 0,
|
||||
"iops_wr_max_length": 0,
|
||||
"iothread": 0,
|
||||
"mbps": 0,
|
||||
"mbps_rd": 0,
|
||||
"mbps_rd_max": 0,
|
||||
"mbps_wr": 0,
|
||||
"mbps_wr_max": 0,
|
||||
"media": "",
|
||||
"replicate": 0,
|
||||
"size": "10G",
|
||||
"slot": 0,
|
||||
"ssd": 0,
|
||||
"storage": "local-lvm",
|
||||
"storage_type": "lvmthin",
|
||||
"type": "scsi",
|
||||
"volume": "local-lvm:vm-104-disk-0"
|
||||
}
|
||||
],
|
||||
"disk_gb": null,
|
||||
"force_create": false,
|
||||
"force_recreate_on_change_of": null,
|
||||
"full_clone": true,
|
||||
"guest_agent_ready_timeout": 100,
|
||||
"hagroup": "",
|
||||
"hastate": "",
|
||||
"hostpci": [],
|
||||
"hotplug": "network,disk,usb",
|
||||
"id": "pve/qemu/104",
|
||||
"ipconfig0": "ip=192.168.1.71/24,gw=192.168.1.1",
|
||||
"ipconfig1": "",
|
||||
"ipconfig10": "",
|
||||
"ipconfig11": "",
|
||||
"ipconfig12": "",
|
||||
"ipconfig13": "",
|
||||
"ipconfig14": "",
|
||||
"ipconfig15": "",
|
||||
"ipconfig2": "",
|
||||
"ipconfig3": "",
|
||||
"ipconfig4": "",
|
||||
"ipconfig5": "",
|
||||
"ipconfig6": "",
|
||||
"ipconfig7": "",
|
||||
"ipconfig8": "",
|
||||
"ipconfig9": "",
|
||||
"iso": null,
|
||||
"kvm": true,
|
||||
"mac": null,
|
||||
"machine": "",
|
||||
"memory": 2048,
|
||||
"name": "hashi-1",
|
||||
"nameserver": "",
|
||||
"network": [
|
||||
{
|
||||
"bridge": "vmbr0",
|
||||
"firewall": false,
|
||||
"link_down": false,
|
||||
"macaddr": "A6:34:10:6D:83:97",
|
||||
"model": "virtio",
|
||||
"mtu": 0,
|
||||
"queues": 0,
|
||||
"rate": 0,
|
||||
"tag": -1
|
||||
}
|
||||
],
|
||||
"nic": null,
|
||||
"numa": false,
|
||||
"onboot": false,
|
||||
"oncreate": true,
|
||||
"os_network_config": null,
|
||||
"os_type": "cloud-init",
|
||||
"pool": "",
|
||||
"preprovision": true,
|
||||
"pxe": null,
|
||||
"qemu_os": "l26",
|
||||
"reboot_required": false,
|
||||
"scsihw": "virtio-scsi-pci",
|
||||
"searchdomain": "",
|
||||
"serial": [],
|
||||
"sockets": 1,
|
||||
"ssh_forward_ip": null,
|
||||
"ssh_host": null,
|
||||
"ssh_port": null,
|
||||
"ssh_private_key": null,
|
||||
"ssh_user": "alpine",
|
||||
"sshkeys": " ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPiMj6yG62yNiju2H3FQicX76AsBRZfxpMMfVeCEXEsF sergio@nas\n\n",
|
||||
"startup": "",
|
||||
"storage": null,
|
||||
"storage_type": null,
|
||||
"tablet": true,
|
||||
"tags": "",
|
||||
"target_node": "pve",
|
||||
"timeouts": null,
|
||||
"unused_disk": [],
|
||||
"usb": [],
|
||||
"vcpus": 0,
|
||||
"vga": [],
|
||||
"vlan": -1,
|
||||
"vmid": null
|
||||
},
|
||||
"sensitive_attributes": [],
|
||||
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWZhdWx0IjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDAsInJlYWQiOjEyMDAwMDAwMDAwMDAsInVwZGF0ZSI6MTIwMDAwMDAwMDAwMH19",
|
||||
"dependencies": [
|
||||
"data.external.env"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"check_results": null
|
||||
}
|
Loading…
Reference in New Issue
Block a user