proxmox, cloud-init, terraform, ansible, semaphore demo

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to my next tutorial today I'm going to be talking a bunch about uh different development operation tools uh specifically proxmux terraform and ansible are going to be the focus of this video and basically gluing all these tools together so the goals of this video is take terraform to control a proxmox server to launch a new Ubuntu uh cloud and knit server and I'll kind of go into some of those details what that means in a minute then once the virtual machine's running ansible will take over after that the next goal is to be able to to destroy and create the virtual machine in a loop and then have that entire process continue to work and be able to test on this setup so I've actually a little bit background of this is I have this home lab I have two Intel Nooks that are pretty old running proximux 8.0.3 you certainly don't need two of them for this demo you just need one so here in the background is my cluster and you can see CPU memory storage blah blah blah and I'll kind of go into these setups here in a minute Okay so the next thing I do is I immediately create a new virtual machine with a bunch of development operations tools on it ansible terraform and semaphore which is basically just the uh some before is a ansible front end website front end for controlling playbooks so it's just like an extra tool for ansible the next thing we need to do is set up a virtual machine to clone from terraform so if you come to this website here it talks about how to set this up and this got to be such a tedious process I actually wrote a script to do this because there's actually a lot of other steps that are needed for this Cloud init to work so if you come to this TF examples uh repository you want to look at this Crete VM 9000. and basically this is going to create this virtual machine for you by running this on your primary proxmox server so I'm actually going to get that started right now so we're going to come here this bottom server is my primary proxmox server I'm going to do crate vm9000. and it's going to do a bunch of stuff here and I can kind of walk through what this is going to do if you put this file on the file system it's smart enough not to re-download it so that's kind of a feature I added to this script here otherwise it'll get it from the website and takes a little bit longer to run basically we're injecting a this agent is important to be running we also set a default username a password it's up to you if you want to inject your public key from any of your devices into this image personally I don't have to do this stuff because terraform will do it on the next step um so I just leave those in the script in case you need it in fact I had some logic here if you put this here uh it'll inject your uh key here so if you need that you can use it if not just leave it commented out otherwise let this run uh basically enables uh what type of hard drive it says it's a cloud init server this is so the console Works in proxmox if you come here and look at the console you want to set that um I haven't had to mess with this one but I set this to try to tell it has an agent on here and when you use this I don't know how to pronounce this q-e-m-u guest agent I usually set this and then this turns it into a template so that's uh all done running now so if you come over here to nodo one you'll have VM 9000 here and this is all set up now for terraform to take over so I have this terraform script called reset VM and basically what it's going to do is just destroy the old one and then create the new one in place and I can actually demo that happening here uh it's going to be called testing O2 you can see it's already been launched there so I want to be able to GF reset and VM so now this will disappear and then it sleeps a little bit and then it recreates that and it'll be copying or cloning It Off this vm9 9000 . okay you can see it already came back so I I actually let this uh run for about another 60 seconds even after this create VM command finishes just to let Cloud init finish because there is quite a bit of startup stuff that runs on the on these VMS so okay so some other things that you're going to need to set up before calling this script is if you come in this TF examples you need to come into these credentials auto tfvars.sample file and remove this dot sample and put in your info here so this points at your primary proxmox server this points uh at the username and then you need a proxmox API token so make sure you update this file the other thing you need to do is come into this full clone and this is what controls most of what is going on with the terraform apply command but down at the bottom here you want to put your public key SSH key for your ansible server down here so in my example when I called that reset VM script this is all set up on my side the other thing you want to look at is probably this entry here this tells it what IP you want and what Gateway it's going to use for now I have that commented out because I don't really know which uh Network you have so it's up to you how you want to control that so those those are two other entries you want to make sure you change the rest of these you can change too but just be careful it might uh break something if you don't have certain air like this is expecting this VM to clone off of so you may get error messages if you don't use this correctly uh this is the name of the device it's going to create and I just kind of copied this down these VM IDs also have to be unique if you don't I actually put in here if you reuse IDs you will get errors and that's kind of how terraform launches a proximox device so if we come back to the terminal okay this reset VM completed so I can come back here and just make sure it's running okay yeah the screen arrow means it's running and over here you have options options to shut down and not start so you know this is running okay so the first thing I do now that the device is up is I make sure uh my ansible playbooks actually work from the terminal do ping here and this should be able to Ping out the dot 7 device and you can see that worked fine so if you come to this other git uh Hub uh repo this is all my ansible examples so if you come in here to play books you'll see ping and this is the one we just ran so I have a bunch of other playbooks in here that I can actually demo uh now that I know this is running I usually switch over to the semaphore dashboard uh basically this is a tool to see ha basically have uh templates that will match your playbooks see every time I have a new playbook that I want to run I do new template here and put in all the information so you can see basically these are one for one inside this playbooks uh yaml files okay so I always do these base packages as well and this does basically I can show you what that does in the git repo so if you come here base packages I just install a bunch of these tools that I always expect to see on my servers I also make sure this Banner goes away it's what it's easier to SSH into these devices without that okay some other playbooks that I've been testing is this install patchy and this install Samba both seem to work pretty well but that's kind of how I use terraform and proxmux and ansible to control all these devices some other things that you run into when you're um destroying and creating virtual machines a lot you'll run into where it gives you the the fingerprint problem and in order to fix that if you come into ansible examples and go to this ansible but dot CFG you'll see I add the a couple entries here to try to bypass these uh fingerprint check settings and all this stuff in fact I bet you here I can show you what happens like I'm sure if you've foreign so if I do Ubuntu at one this is going to be a bad fingerprint and this is what you usually get and this would be bad if this was not a device that was just recreated so usually you have to do key gen and then yes and then you can go right back into this device so that's kind of these keys that these commands help suppress These Warnings about these Keys the other thing you can do is of course put entries in your host file to ignore some of this stuff too but it is also a security check so you want to make sure you know what you're doing and why you're using these commands okay um I can demo one more Playbook I will just show you like the Apache 2 here so if I come here and just run this and you can see what this Playbook does going to ansible examples playbooks install Apache 2. and this kind of does [Music] um some advanced stuff it actually enables the SSL stuff I um it's nice having this set up here I'm going to keep working on this and probably keep changing this more and more okay so that's done and now this should work so if I go see that one done seven so this works here and also on http so that's how easy it is to install Apache on devices with all these tools the last thing I just want to show you in proxmox here is if you have any problems adding SMB storage here so if you come here to storage and you go add SMB sometimes you'll get an error message that says like the server is offline error 500 all you have to do is uncheck this checkbox click add then the entry will work here in the dashboard and then just double click these and click this on and it'll work the other thing to note too is you can see all these different storage devices here and it these icons actually represent how much storage is left on the device you can see this one I have here is pretty much full this was an old Samba share I've had for a long time if you see icons over here with like question marks or errors or problems here chances are it cannot write to the folder that it's trying to access so make sure you check permissions and and all that stuff if you're creating Samba shares or other shares these icons should look like this and actually Auto detect uh you can see these four drives basically have very little on them so far and I just created this uh setup yesterday so yeah that's uh just another quick tip on how to manage some samba SMB shares if you have any comments or questions please post them below and thanks for watching
Info
Channel: Dan Sheffner
Views: 2,422
Rating: undefined out of 5
Keywords:
Id: Kz7F_GrXM3E
Channel Id: undefined
Length: 14min 54sec (894 seconds)
Published: Wed Jul 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.