Create VMs on Proxmox in Seconds!
Vložit
- čas přidán 16. 05. 2024
- In this video I show you how to create VM Templates in Proxmox. We will use Packer from Hashicorp, which is a free and open-source image automation tool. This can create custom machine images for Proxmox with provisioning shell scripts and inject configuration settings via Cloud-Init. #Proxmox #Packer #Cloudinit
My Packer Templates: github.com/christianlempa/boi...
Teleport Tutorial: • How I secure my Server...
Teleport-*: goteleport.com/thedigitallife
Follow me:
TWITTER: / christianlempa
INSTAGRAM: / christianlempa
DISCORD: / discord
GITHUB: github.com/christianlempa
PATREON: / christianlempa
MY EQUIPMENT: kit.co/christianlempa
Timestamps:
00:00 - Introduction
01:20 - What is Packer?
03:07 - How to use Packer in Proxmox
04:45 - Integrating Cloud-Init
07:27 - Advertisement-*
08:03 - Preparing the Project
10:09 - Packer Template for Ubuntu
16:56 - Provisioning the Ubuntu Server
18:48 - Build the Template with Packer
20:24 - Deploy a new VM from the Template
21:43 - Troubleshooting and Issues
24:01 - The next steps
________________
All links with "*" are affiliate links.
I discovered you recently. In general, you are explaining such nice tricks to a person who does not know the subject :) Congratulations, I wish you continued success . Bravo
Thank you so much! :) Makes me so happy to read this
Man, you helped me a lot with some use cases for a task that I have. Thank you so much and keeping do it. Great video and very good explanation!!
Great video.
Very pleasing to follow.
Very clear:
You ve put a framework by putting the most important principles first,
Then putting details with why, what, steps and tools on those principles, and by linking logicaly the principles.
Few have your redactional qualities.
One way or another, you have to teach.
Thanks!
Thanks! Use Proxmos around 10 years. Packer thats I need many years ago!!!
Looking forward to a Packer + Terraform video. I'd also be interested to see how Packer (and Terraform) could work with LXD too. Proxmox is great but, as everyone knows, it requires a Debian base, whereas the snap version of LXD will run on just about any arch or distro and also provides both VM and CT instances with clustering features. It's just missing a standard web GUI like Proxmox.
SO COOL! interested in how this would interact with Terraform. Thank you for the video!
Hey, first of all, great video. You have packed up lots of info in this video. As a new packer user I had to deal with the plugin installation which was not a part of the video but I can understand that we cannot go over everything and we need to make hard choices in order to simplify the content. For those who had error messages about unknown source, you need to define the plugin to be used and then initialize packer in order to install that plugin :)
what is the needed plugin to install?
@@insanity.k As mentioned, you can either use the proxmox-iso option to create an image from iso, or maybe the better option, create an image from virtual machine you already have using the proxmox-clone
@@TheJoBlackos Kinda new to Packer - I want to use the proxmox-iso plugin. But how do I use that? Where do I define using the proxmox-iso plugin and how to initialize packer in order to install the plugin? Thanks in advance!
Fantastic! Excellent addition to youtube 👌⭐️
Thank you so much!
Very good video! Easy to follow and important details.
This is really great content!! I am just getting started with Proxmox and this is very helpful
Glad it was helpful!
Great tutorial. Very clear and easy to follow.
Glad it was helpful!
Thank you for the video, it is very educational!
Thanks for the demo and info, have a great day
Thanks, you too!
You sir, are a goldmine of information!!!
Thank you so much 😊
Precisely what i was looking for.
Glad you liked it :)
Thanks you 4 helpful video and tutorial! Also you have a perfect pronunciation, that awesome 4 me as foreign listener! :)
Nice, very clear instructions!
Thank you! :)
This was a great video btw! Many thanks for the high level explanation
Glad it was helpful!
Christian. Excellet video again. Tomorrow, I will go and follow your next video in the series - Terraform with Proxmox VM creation (cloning). Thanks.
Cool, thanks :) GL
Amazing Video, as always 👏🏼
🙌 thanks!
Awesome, this worked for me!
Thanks for your video!
Does the SSH users need to exist in order to build the VM or will packer create that? I assume it needs to be created before had to use the private SSH key.
Also how would I enable cloud-init on proxmox?
I just watched @Techno Tim's video on this very topic. So cool to get 2 different perspectives on the same topic within literally days of each other. Thank you!! 😁
Oh yeah I watching his video as well and was so glad that I did it slightly different 😁
Another AWESOME video! I got my two templates up and running after a few tries. One thing on the docker one is that also added docker-compose as well. Now with the release of Ubuntu 22.04 LTS, I thought that I could just clone the scripts - change names, etc. and it would work. To my sad surprise, it would appear that boot commands between 20.04 and 22.04 are different. Will have to try and dig in and find out what they are.
Currently working on this, you should see an update on my GitHub Repo soon!
Hi@@christianlempa , facing similar issue. Autoinstall stuck on language selection with Ubuntu 22.04.4. Your boilerplate scripts refer to Ubuntu 22.04 which is can not be downloaded. Thanks!
Does this apply to LXC containers as well? I'm almost 100% lXC on Proxmox.
Yeah, awesome video, thanks for sharing ;)
Thank you so much for your help! 🥰
@@christianlempa You are most welcome, anytime.
Brilliant - again! 👍
Thanks :)
Can I use it in Virtual box or VMware the proxmox installation what u recommend and how to remove the pre-build tools in linux and making to install own tools
Hey TheDigitalLife! Your Videos are very thorough and to the point. I followerd your Traefik Video and it provided me very good concepts. Could you also make another Video on Ingress in k8s and how we could secure it both in ipv4 and ipv6 address?
Thanks! Glad that you enjoy the videos :) I currently have no plans to do this, but maybe we will discuss ipv6 in a future video
Thanks for the great video. Please i need some help on how i can passthrough my h710min hba pcie card to my truenas vm in proxmox. I have a dell r720xd server.
@23:40 is there a lint function for the .yaml file?
Hello, great video!! Any idea how to do IP Pools in Proxmox because it doesn't have this option!
spettacolare!!!
Thx :)
Mind sharing an example of the environ access file? Can only find for aws.
Hi Christian! Thank you so much. I learned so much from you and your videos look great.
I followed the tutorial and everything worked as expected, but if I try to make more than one VM they share the same IP. I tried everything I could think of including one last
provisioner "shell" {
inline = [
"sudo cloud-init clean",
"sudo rm -f /etc/machine-id",
"sudo rm -f /var/lib/dbus/machine-id"
]
}
But the IP keeps persisting. I've looked into other tutorials on cloudinit where this seems to be a consideration, but I don't know what to do in Packer
Did you have a qemu-agent install fail, qcow2 unsupported format, failed to connect system bus Error?
@@JustinWallis No errors unfortunately. That's why I'm having difficulty diagnosing the issue. Everything seems fine, but in the end I always get the same IP.
Really nice. :)
interesting, will it work with LXC or only for QEMU instance? also is Packer able to resize/change resource after instance created?
About LXC I'm not sure
Hey for me the boot gets stuck at cloud-init running init-local in the console and the script is waiting for ssh to be accessible....would you happen to know any fix ?
Ok, a bit late maybe, but check what is happening in the Proxmox console on the newly created VM. For me packer fails to unmount the ISO which means it will start the installer script again on reboot instead of booting the new server. This appears to be an unsolved bug.
I have the same problem, u remember how u resolve a issue?
Quick question: When I want to create a quick vm on my proxmox system right now, all I do is clone the existing vm and run a bash script that modifies the mac, ip and hostname. I reboot the vm, and it works like a charm and only takes a few minutes. Simple and easy. Is this a bad workflow?
Nice !
Thx ;)
Hey, I have the problem that the VM has no internet when it hangs in the boot CMD and therefore can't reach the webserver. the dhcp server works though.
Hello, I tried to build a template using your tutorial but i get an error: wasm connection closed by the server ( being proxmox ) I have latest version of Proxmox. Do you have an idea?
Thank you !
Regards
Is it also possible to automatically distribute VMs into pools?
Hello
ubuntu install in PROXMOX via packer stuck at welcome screen
how to bypass that ?
any help will be appreciated
thanks
My Packer build is stuck on the "Waiting for SSH to become available..." step, and I'm not able to log into vm. Did you solve the issue?
Hey! This was a great video, I ran the same install with your new 22.04 packer proxmox templates but the boot is hanging on "[ OK ] Finished Load AppArmor profiles managed internally by snapd", did you see anything like this?
One last thing I noticed, the 22.04 template doesn't work with ssh passwords even if the autoinstall user-data and packer hcl file have the exact same entries. It worked once I used ssh keys instead. The following was the error if you're interested:
Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
Did you encode your ssh password? It needs to be base64 if I'm right
@@christianlempa Ah thats probably it, it was in raw string format, do you know the reason for base64 requirement?
thanks for the video as it is very helpful...
one question that maybe someone can help with:
the packer automation fails when I try to use ssh password instead of public key authentication and I get the following error message:
Packer experienced an authentication error when trying to connect via SSH
I have googled on this issue but still unable to get past the ssh authentication. Any hint is greatly appreciated.
Hey, did you solve the issue?
But why I must create an install template which I use only one time and then the machine is there. then it's a template and I don't need to install it anymore
Are you using LVM? because I'm gettning this error " unsupported format 'qcow2' " apparently LVM doesn't support that if I set it to raw it does work but just wandering
using "raw" instead of qcow2 would get you through. had same issue. done it today successfully
Hey, I just followed your example and it works (with ssh keys) however if I switch to password it fails. Did you try using password for ssh credential?
FOUND IT! During the cloning of the image changing the user in "Cloud-Init" screen has some bug. When the user name is left empty (it will show 'Default'), cloud init will greater a new user 'ubuntu' in addition to the one specified by the packer template. The password which you change in Proxmox Cloud-Init will be assigned to .... wait for it ... to ubuntu account and not the one specified by the packer temple. This is VERY screwy indeed. I did not test if the packer defined user id in such situation will simply get no password. To late to test it tonight.
I have the same issue. How to fix that?
Can't you make a vm then make a template out of it?
Interesting
Thanks ;)
Can you do a video on OPN sense firewall. As well as PFsense.
Well, I probably won't because I'm not using it.
Christian Packer sounds great but it is important to know how to create vms containers & templates by hand to understand what is going on. Automation is good till it goes wrong .
Why don't use ubuntu cloud-image instead of ubuntu image?
I am thinking exactly the same thing. Ubuntu cloud image + cloud-init can be proxmox template in less than 10 lines of commands 😁
Please I need a hand! I 'm using your git script but it Freeze in the middle of Ubuntu Installation, at mirror package selection, What can be the reason? Great video! Thanks in advance
I've explained some of the problems in my troubleshooting section of the video, others I really don't know. You could share some logs and infos in our Discord, maybe somebody can help.
How do you have that proxmox skin?
Its the pve dark mode extension
what if I was trying to install an image of Ubuntu that includes the GUI such Gnome?
Would also work similar way, you can put anything in your templates
@@christianlempa wouldn't the Mac address and IP would replicate Every time or will it change automatically?
Interesting process, but, this smells like it's a 1:1 build? I know this is a year old video, but I kinda stopped taking notes as soon as I saw a lot of inputs that are pretty static when it comes to new machine builds. Like, defining IP addresses? Assigning the VM an ID to ProxMox? What if I wanted to spin up several VMs for different purposes based on this template, this seems pretty "stuck" to how the template file is configured, and you'd have to go edit/copy the config files every time you want something different for the next VM, like the ID or static IP address, or whatever the case may be. This process just doesn't seem like it's going to save time compared to just running a base template, and copy/pasting a set of commands out.
Am I missing something here?
After you create the template, you can use something like terraform to automate building x amount of machines with different id's.
I use terraform to provision VMs.
Oh yeah that's a great idea, maybe topic for a future video? 😀
ooohhhh.... that dark theme for proxmox! How? Is it PVEDiscordDark? TIA!
Yes! ;) Got it from GitHub
@@christianlempa Just a totally off topic question :) What mixer are you using? It looks nice.
Wait, wouldn't it be faster to just spend the time to make a VM manually, keep it as a VM iinstead of converting to template and just clone it when you need another instance? By keeping it as a VM to maintain the ability to do updates and other changes. Why do a whole installation every time, even if automated, when you can just clone a "template" VM in seconds? And why cloud-init when packer seemingly is able to do all the same stuff?
One example he provided was a vm with different user credentials
Honestly i prefer to use lxc with docker inside. They work better tham VMs in resource limited environments - no virtualisation overhead and much better flexibility in adjusting assigned resources. The only vm i have is pfsense. I cant afford for special virtualization licenses to vitualize other os like windows or macos. I know that some abuse trial licenses or even use keys from physical machines but their license dont allow that, so such actions are plain piracy.
Grüße! Gutes Video Wäre mal schön das auch in deutsch zu hören danke
Ich mache zwar nicht die gleichen, aber andere Videos auf meinem deutschen Kanal. Ist mehr in Vlog und Persönlicher Kanal, aber kannst ja mal reinschauen ;) Gibts auch Informatiker Content.
@@christianlempa ich finde 👍 👍 👍 gut wie du es machst weiter so
@@Rgb0braucht0keiner danke, mach ich 😀
Call me weird, but I run proxmox only with LXC's, waste of resources to use VM's unless there is a specific kernel/os/migration requirement.
Yeah why not? LXC seems like a great feature on Proxmox
11:16 are you using Linux?
No I'm using Windows on my PC
@@christianlempa cool, i did think it’s kde or gnome
this is overcomplicated alternative for using a cloud init image and provision it with cloud init too?🤕
Well, you can do this manually as well, but the point was to simply that process with packer
@@christianlempa he was referring to ready made official cloud-init images, just like Techno Tim did a few days ago... those steps can be automated using ansible (download image, create proxmox vm, attach disk, create template). To customize the images, one could use libvirt tools beforehand
Yes. If you are the only contributor to your infrastructure and it lives only on proxmox, and you rarely update or version your software.
No if you work on a team, use more than one environment, or need to manage patching in a highly regulated security environment
your config really does not work. I think the booting behaviour of Ubuntu has changed. I have been looking around and I cannot find a solution
I would simply use terraform
You can add terraform to this, but it's actually a good addition, not a replacement.
Use ansible
Please. NixOS
I'll take a look!
Guys! Don’t Google Packer 😂
Dude, it's called "Ubuntu", not "Oh-Bantu". So annoying.
I feel better now.
LIKE !!
But i need:
debian cloud-init lvm (with explain of partman ;) ) uefi boot
i found out, that you can separate your packer files for better structure as:
build.pkr.hcl (source and provisioners)
build-vars.pkr.hcl (default vars)
eg. PROXMOX.debian.pkr.hcl (build commands...)
and build-vars-debian.pkvars.hcl (overrride vars)
THANKS FOR INIT MY PACKER KNOWLEDGE ;)