Proxmox: Difference between revisions
No edit summary |
No edit summary |
||
| Line 15: | Line 15: | ||
See also, the ansible role at https://github.com/FuzzyMistborn/ansible-role-proxmox-nag-removal/blob/master/tasks/remove-nag.yml | See also, the ansible role at https://github.com/FuzzyMistborn/ansible-role-proxmox-nag-removal/blob/master/tasks/remove-nag.yml | ||
===Deployment using | ===Deployment using Terraform=== | ||
You can use Hashicorp's Terraform deployment tool to automatically provision virtual machines on Proxmox. After installing Terraform, follow the following steps to get your deployments working. | You can use Hashicorp's Terraform deployment tool to automatically provision virtual machines on Proxmox. After installing Terraform, follow the following steps to get your deployments working. | ||
==== Setup | ====Setup Terraform==== | ||
Terraform controls the Proxmox server using the [https://github.com/Telmate/terraform-provider-proxmox Telmate Proxmox provider]. For more information on each of the provider's options, review the documentation at https://registry.terraform.io/providers/Telmate/proxmox/latest/docs/resources/vm_qemu. | |||
To quickly get started, we will: | |||
{{Highlight | # Install Terraform | ||
| code = # | # Setup an account with an API key on Proxmox. This account should have permissions to '/' as well as to any storage volumes it needs to create VMs on '/storage/data'. (TBD) | ||
# We will use the following <code>main.tf</code> file which will define the provider and provider configurations. The VM definitions are also included here. | |||
# Run <code>terraform init</code> to set up the provider | |||
# Run <code>terraform plan</code> to plan the tasks | |||
# Run <code>terraform apply</code> to create the VMs. | |||
main.tf:{{Highlight | |||
| code = # Use Telmate proxmox provider | |||
terraform { | terraform { | ||
required_providers { | required_providers { | ||
| Line 34: | Line 41: | ||
} | } | ||
# Configure the proxmox provider | |||
provider "proxmox" { | provider "proxmox" { | ||
pm_api_url = "https://proxox-server:8006/api2/json" | pm_api_url = "https://proxox-server:8006/api2/json" | ||
| Line 43: | Line 49: | ||
} | } | ||
# Define our first VM | |||
resource "proxmox_vm_qemu" "test-vm" { | resource "proxmox_vm_qemu" "test-vm" { | ||
count = 1 | count = 1 # 0 will destroy the VM | ||
name = "test-vm-${count.index + 1}" # count.index starts at 0. We want the VM to be named test-vm-1 | name = "test-vm-${count.index + 1}" # count.index starts at 0. We want the VM to be named test-vm-1 | ||
target_node = var.proxmox_host | target_node = var.proxmox_host # target proxmox host | ||
clone = var.template_name | clone = var.template_name # VM template to clone from | ||
os_type = "cloud-init" | |||
agent = 1 | agent = 1 | ||
cores = 2 | cores = 2 | ||
sockets = 1 | sockets = 1 | ||
| Line 57: | Line 63: | ||
memory = 2048 | memory = 2048 | ||
scsihw = "virtio-scsi-pci" | scsihw = "virtio-scsi-pci" | ||
bootdisk = " | bootdisk = "sata0" | ||
disk { | disk { | ||
slot = 0 | slot = 0 | ||
size = "10G" | size = "10G" | ||
type = " | type = "sata" | ||
storage = "data" | storage = "data" | ||
iothread = 1 | iothread = 1 | ||
| Line 85: | Line 91: | ||
EOF | EOF | ||
} | } | ||
| lang = text | |||
}}vars.tf: | |||
{{Highlight | |||
| code = variable "ssh_key" { | |||
variable "ssh_key" { | |||
default = "ssh-rsa ... " | default = "ssh-rsa ... " | ||
} | } | ||
# This should be the exact same name as your proxmox node name | |||
variable "proxmox_host" { | variable "proxmox_host" { | ||
default = "proxmox-server" | default = "proxmox-server" | ||
| Line 98: | Line 104: | ||
variable "template_name" { | variable "template_name" { | ||
default = " | default = "rocky85-template" | ||
} | } | ||
| lang = text | |||
}} | |||
==== Issues with the apply step ==== | |||
I kept on getting "<code>400 Parameter verification failed</code>": | |||
{{Highlight | |||
| code = ╷ | |||
│ Error: 400 Parameter verification failed. | |||
│ | |||
│ with proxmox_vm_qemu.test-vm[0], | |||
│ on main.tf line 20, in resource "proxmox_vm_qemu" "test-vm": | |||
│ 20: resource "proxmox_vm_qemu" "test-vm" { | |||
│ | |||
╵ | |||
| lang = text | |||
}} | |||
The issues I encountered which triggered this error was: | |||
* Incorrect host name for the Proxmox node | |||
* Invalid values for the disk type (I tried changing <code>type = "scsi"</code> to <code>type = "sata"</code>) while leaving <code>iothread = 1</code> defined. | |||
To help diagnose issues, review the provider's documentation and ensure the values you're using are appropriate. You may also want to enable additional logging by running with the <code>TF_LOG=TRACE</code> environment variable: | |||
{{Highlight | |||
| code = $ TF_LOG=TRACE terraform apply | |||
| lang = terminal | | lang = terminal | ||
}} | }} | ||
==Troubleshooting== | ==Troubleshooting== | ||
Revision as of 04:44, 28 December 2021
Proxmox Virtual Environment (VE) is an open source virtualization management software that allows deployment and management of KVM-based virtual machines and LXC containers. The platform itself run on a Debian based distribution and supports filesystems such as ZFS and Ceph.
In terms of functionality, Proxmox VE is similar to VMware ESXi with some overlap with vSphere. You can have a cluster of Proxmox servers controlled and managed through a singular web console, command line tools, or via the provided REST API.
Installation
Installation is as simple as installing any other Linux distribution. Download the Proxmox iso image from https://www.proxmox.com/en/downloads. After installation, you should be able to access the web console via HTTPS on port 8006.
Tasks
Remove the subscription nag
If your Proxmox server has no active subscription, you will be nagged every time you log in to the web interface. This can be disabled by running the following as root in the server's console:
sed -Ezi.bak "s/(Ext.Msg.show\(\{\s+title: gettext\('No valid sub)/void\(\{ \/\/\1/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
See also, the ansible role at https://github.com/FuzzyMistborn/ansible-role-proxmox-nag-removal/blob/master/tasks/remove-nag.yml
Deployment using Terraform
You can use Hashicorp's Terraform deployment tool to automatically provision virtual machines on Proxmox. After installing Terraform, follow the following steps to get your deployments working.
Setup Terraform
Terraform controls the Proxmox server using the Telmate Proxmox provider. For more information on each of the provider's options, review the documentation at https://registry.terraform.io/providers/Telmate/proxmox/latest/docs/resources/vm_qemu.
To quickly get started, we will:
- Install Terraform
- Setup an account with an API key on Proxmox. This account should have permissions to '/' as well as to any storage volumes it needs to create VMs on '/storage/data'. (TBD)
- We will use the following
main.tffile which will define the provider and provider configurations. The VM definitions are also included here. - Run
terraform initto set up the provider - Run
terraform planto plan the tasks - Run
terraform applyto create the VMs.
main.tf:
# Use Telmate proxmox provider
terraform {
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "2.7.4"
}
}
}
# Configure the proxmox provider
provider "proxmox" {
pm_api_url = "https://proxox-server:8006/api2/json"
pm_api_token_id = "terraform@pam!terraform_token_id"
pm_api_token_secret = "e458e7bc-d8e6-4028-885b-d0896f4becfa"
pm_tls_insecure = true
}
# Define our first VM
resource "proxmox_vm_qemu" "test-vm" {
count = 1 # 0 will destroy the VM
name = "test-vm-${count.index + 1}" # count.index starts at 0. We want the VM to be named test-vm-1
target_node = var.proxmox_host # target proxmox host
clone = var.template_name # VM template to clone from
os_type = "cloud-init"
agent = 1
cores = 2
sockets = 1
cpu = "host"
memory = 2048
scsihw = "virtio-scsi-pci"
bootdisk = "sata0"
disk {
slot = 0
size = "10G"
type = "sata"
storage = "data"
iothread = 1
}
network {
model = "virtio"
bridge = "vmbr0"
}
lifecycle {
ignore_changes = [
network,
]
}
ipconfig0 = "ip=10.1.1.10${count.index + 1}/22,gw=10.1.1.1"
# sshkeys set using variables. the variable contains the text of the key.
sshkeys = <<EOF
${var.ssh_key}
EOF
}
vars.tf:
variable "ssh_key" {
default = "ssh-rsa ... "
}
# This should be the exact same name as your proxmox node name
variable "proxmox_host" {
default = "proxmox-server"
}
variable "template_name" {
default = "rocky85-template"
}
Issues with the apply step
I kept on getting "400 Parameter verification failed":
╷
│ Error: 400 Parameter verification failed.
│
│ with proxmox_vm_qemu.test-vm[0],
│ on main.tf line 20, in resource "proxmox_vm_qemu" "test-vm":
│ 20: resource "proxmox_vm_qemu" "test-vm" {
│
╵
The issues I encountered which triggered this error was:
- Incorrect host name for the Proxmox node
- Invalid values for the disk type (I tried changing
type = "scsi"totype = "sata") while leavingiothread = 1defined.
To help diagnose issues, review the provider's documentation and ensure the values you're using are appropriate. You may also want to enable additional logging by running with the TF_LOG=TRACE environment variable:
$ TF_LOG=TRACE terraform apply
Troubleshooting
LXC containers does not start networking
I have a Fedora based LXC container which takes a long time to start up. After the tty does start, the only network adapter isn't up. systemd-networkd is also in a a failed state with a bad exit code and status 226/namespace.
This was resolved by enabling nesting on this container with the following commands:
# pct set $CTID -features nesting=1
# pct reboot $CTID