Linux/Proxmox: Difference between revisions
< Linux
(Die Seite wurde neu angelegt: „== Install Ubuntu to be used for cloning with cloud-init == <pre> apt update apt install -y cloud-init cloud-initramfs-growroot qemu-guest-agent </pre> …“) |
|||
(40 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== | == Download Ubuntu Cloud Image == | ||
* https://cloud-images.ubuntu.com/releases/ | |||
** e.g.: ubuntu-22.04-server-cloudimg-amd64.img | |||
* upload cloud-init image from proxmox | |||
** gui -> local storage -> iso images | |||
== Create VM from Cloud Image to be used as template == | |||
<pre> | |||
iso folder: /var/lib/vz/template/iso/ | |||
qm create 9001 --memory 2048 --net0 virtio,bridge=vmbr0 --cpu cputype=host | |||
qm importdisk 9001 /var/lib/vz/template/iso/ubuntu-22.04-server-cloudimg-amd64.img local-lvm | |||
qm set 9001 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9001-disk-0 | |||
local:9001/vm-9001-disk-0.raw | |||
qm set 9001 --boot c --bootdisk scsi0 | |||
qm set 9001 --serial0 socket --vga std # --vga serial0 | |||
qm set 9001 --name "ubuntu-22.04-cloudimg" | |||
qm set 9001 --agent 1 | |||
# set cloud-init definitions | |||
qm set 9001 --ide0 local-lvm:cloudinit | |||
local:cloudinit | |||
qm set 9001 --ciuser "username" | |||
qm set 9001 --cipassword "password" | |||
qm set 9001 --ipconfig0 "ip=dhcp" | |||
</pre> | |||
* manual rework | |||
<pre> | |||
echo 'Acquire::http::Proxy "http://192.168.111.11:3142";' > /etc/apt/apt.conf.d/00aptproxy | |||
apt install qemu-guest-agent | |||
sudo dpkg-reconfigure keyboard-configuration | |||
apt clean | |||
</pre> | |||
== Clone template to new VM == | |||
<pre> | |||
qm clone 9001 123 --name docker1 | |||
qm resize 123 scsi0 20G | |||
</pre> | |||
== Terraform + Proxmox == | |||
* main.tf | |||
<pre> | |||
terraform { | |||
required_providers { | |||
proxmox = { | |||
source = "telmate/proxmox" | |||
version = "2.9.3" | |||
} | |||
} | |||
} | |||
provider "proxmox" { | |||
pm_api_url = "https://vm-host:8006/api2/json" | |||
pm_password = "password" | |||
pm_user = "root@pam" | |||
pm_tls_insecure = "true" | |||
} | |||
resource "proxmox_vm_qemu" "proxmox_vm" { | |||
name = "vm-01" | |||
desc = "Terraform VM" | |||
target_node = "vm-host" | |||
clone = "ubuntu-20.04-cloudinit" | |||
os_type = "cloud-init" | |||
agent = 1 | |||
cores = 1 | |||
sockets = 1 | |||
cpu = "host" | |||
memory = 2048 | |||
scsihw = "virtio-scsi-pci" | |||
boot = "c" | |||
bootdisk = "scsi0" | |||
disk { | |||
type = "scsi" | |||
storage = "local-lvm" | |||
size = "20G" | |||
} | |||
network { | |||
bridge = "vmbr0" | |||
firewall = false | |||
model = "virtio" | |||
} | |||
lifecycle { | |||
ignore_changes = [ | |||
network | |||
] | |||
} | |||
} | |||
</pre> | |||
== Proxmox + Ansible == | |||
* on proxmox host: | |||
<pre> | <pre> | ||
apt | apt install sudo | ||
apt install - | |||
adduser username | |||
usermod -aG sudo username | |||
sudo visudo | |||
> username ALL = (ALL) NOPASSWD: ALL | |||
apt install python3-proxmoxer | |||
</pre> | </pre> | ||
== Links == | |||
* https://yetiops.net/posts/proxmox-terraform-cloudinit-saltstack-prometheus/ | |||
[[Category:Linux/Virtualization]] | [[Category:Linux/Virtualization]] | ||
[[Category:Linux]] | [[Category:Linux]] |
Latest revision as of 21:53, 3 December 2023
Download Ubuntu Cloud Image
- https://cloud-images.ubuntu.com/releases/
- e.g.: ubuntu-22.04-server-cloudimg-amd64.img
- upload cloud-init image from proxmox
- gui -> local storage -> iso images
Create VM from Cloud Image to be used as template
iso folder: /var/lib/vz/template/iso/ qm create 9001 --memory 2048 --net0 virtio,bridge=vmbr0 --cpu cputype=host qm importdisk 9001 /var/lib/vz/template/iso/ubuntu-22.04-server-cloudimg-amd64.img local-lvm qm set 9001 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9001-disk-0 local:9001/vm-9001-disk-0.raw qm set 9001 --boot c --bootdisk scsi0 qm set 9001 --serial0 socket --vga std # --vga serial0 qm set 9001 --name "ubuntu-22.04-cloudimg" qm set 9001 --agent 1 # set cloud-init definitions qm set 9001 --ide0 local-lvm:cloudinit local:cloudinit qm set 9001 --ciuser "username" qm set 9001 --cipassword "password" qm set 9001 --ipconfig0 "ip=dhcp"
- manual rework
echo 'Acquire::http::Proxy "http://192.168.111.11:3142";' > /etc/apt/apt.conf.d/00aptproxy apt install qemu-guest-agent sudo dpkg-reconfigure keyboard-configuration apt clean
Clone template to new VM
qm clone 9001 123 --name docker1 qm resize 123 scsi0 20G
Terraform + Proxmox
- main.tf
terraform { required_providers { proxmox = { source = "telmate/proxmox" version = "2.9.3" } } } provider "proxmox" { pm_api_url = "https://vm-host:8006/api2/json" pm_password = "password" pm_user = "root@pam" pm_tls_insecure = "true" } resource "proxmox_vm_qemu" "proxmox_vm" { name = "vm-01" desc = "Terraform VM" target_node = "vm-host" clone = "ubuntu-20.04-cloudinit" os_type = "cloud-init" agent = 1 cores = 1 sockets = 1 cpu = "host" memory = 2048 scsihw = "virtio-scsi-pci" boot = "c" bootdisk = "scsi0" disk { type = "scsi" storage = "local-lvm" size = "20G" } network { bridge = "vmbr0" firewall = false model = "virtio" } lifecycle { ignore_changes = [ network ] } }
Proxmox + Ansible
- on proxmox host:
apt install sudo adduser username usermod -aG sudo username sudo visudo > username ALL = (ALL) NOPASSWD: ALL apt install python3-proxmoxer