Alexa, build me a Virtual Machine

Video Notes:

Become an Ansible Master: Best of Fest: AnsibleFest Content hub:    

With one, simple request to Alexa, I can deploy lab machines to Proxmox, AWS, and Linode with Ansible!! I’ve automated my entire lab creation process!! In this video, I’m going to tell you an automation story, a tale of how I tried to automate everything and….went a little crazy in the process. But it was amazing and honestly…kind of addicting. I’ll also show you how you can automate your lab as well.

Automate Your STUFF


-All the code (Github):

-Linode documentation:

-AWS Documentation:

-Proxmox Documentation:

-Slack Documentation:

0:00   ⏩  Intro

0:59   ⏩  Level 1 Laziness unlocked

2:02   ⏩  I should’ve gone to Ansible Fest 

2:47   ⏩  Level 2 of Laziness, deploying proxmox

5:24   ⏩  Level 3 Laziness using slack
9:44   ⏩  Level 4 of Laziness using Alexa 

12:18 ⏩  See it in Action!!

Ah, I did it. I automated everything. 

I went a little crazy for this video. Let me tell you a story. The Red hat asked me to make a video about Ansible, my favorite IT automation tool. Of course I said, yes, duh. But you gotta be careful. IT automation is amazing and stupid fun, but it’s also addicting. This is your brain on IT automation. So that’s my disclaimer. If you keep watching, that’s on you. Okay? You took the red pill, you can’t spit it out. But seriously, by the end of this, I created a masterpiece, my IT automation, Sistine Chapel, my Mona Lisa. So get your stinking coffee ready and prepare to be inspired. Now like all great IT automation, conquest, my idea was born from laziness. I’m lazy and I think you are too. That’s what makes us great. Now, my initial idea was pretty awesome. You see one thing I do all the time, and it’s kind of annoying how long it takes is I deploy virtual machines to the cloud for my lap and for these videos. 

But I have to do it manually and that takes time. And also I’m lazy. Now, could Ansible do this for me? The answer is a big old heck yes. And actually it wasn’t that hard. Automating with Ansible is easy. I started with LE Node because it was really easy, almost too easy. With one Google search, I found one node module and this did all the heavy lifting. So I started writing an Ansible playbook. Here it is. And by the way, if you’re unfamiliar with Ansible, a playbook is basically what they call their magic. It spells or tasks like this guy right up here and it’s pure magic. And honestly, all I had to do was copy and paste and put in my API token and call. Today it’s done. And just like that, a fresh baked vm. And it was the same story with aws. 

I often deploy Windows machines to aws and it was super easy. They had a ton of documentation. See automation, it’s easy unless you go offroad a it. I went offroad before I show you the next three levels of laziness. Yes, there are three more. I told you it’s crazy. Let me tell you, this would’ve been so much easier if I had gone to Ansible Fest 2022. I tried to go, I asked my wife and she said no, but I told her I’d be able to learn about automation and I can bounce a bunch of ideas off people there, experts, She still said no. I said she could go and she could actually stop sucking at Lennox. She said yes. Just kidding. She said, No, slap me and made me do laundry. So no Ansible Fest has come and gone. I missed it and maybe you did too, but I got good news. 

The Ansible Fest content hub, it goes live today. Actually it came out Monday. So check it out. It’s almost like we didn’t miss. They have over 40 sessions available on demand. They have keynote sessions, virtual booths, which I don’t even know what that is, but it sounds cool actually. Can you go find out for me real quick? So if you wanna become an IT automation master, check the link below. Yes, you do wanna become addicted to IT. Automation, just don’t go as far as I did. Save yourself the trouble, check it out. Link below. Now, I don’t know if I mentioned this, but I’m lazy just like you. And with this automation stuff, honestly, I wanted to see how high I could fly. So I automated deploying to the cloud, which honestly is almost too easy. There’s too much documentation. So I thought, how could I be lazier? 

And then it hit me. I have a home lab, I have a prox mock server OnPrim that I deployed VMs onto and I don’t want to have to do that myself anymore. Come on, I’m lazy. Can Ansible deploy to Prox ox? Yes it can. But now we’re venturing into the land of little documentation. But actually it wasn’t too bad. We Googled found a great module created by someone in the Ansible community, which is one thing I wanna highlight about automation and Ansible specifically. It’s community. Community is key. And more often than not someone has walked the path you’re about to walk. So before you lose your mind research and reach out. Now like I said, this was easy except for one thing you see, to deploy a VM like this to prox mos, you need a VM template, which is not very straightforward. But thankfully I found a video by Jay LaCroix. 

Thanks Jay. See, I told you it’s all about community easy. When I say easy, um, I want you to show that you do best stuff easy. Yeah, that’s, that’s all I’m gonna do for it. <laugh>. This is probably very confusing. Deal with it Nick. Deal with it. Come at me. So with my template ready and this amazing module that again is doing all the heavy lifting, I barely did anything. I put my password in. That’s all I did. And this thing is ready to go. Let’s test it out. Bam. There it is. Another fresh baked vm. Except this time it’s on prem. That’s pretty cool. And I was almost done, but there’s one little problem I have. Did you notice it? If you didn’t, you need some more coffee. I need some more coffee. You see if I try to run that playbook again and try to create another lab machine, watch what happens. 

Nothing. Nothing has changed. No new VM here. It’s empty except for the guy we created. Now the reason it’s doing that is because Ansible is in in impotent, in ient impotent, I don’t know how to say it. Basically what it means is that when you run a playbook, whatever it magic spells you have in there, is it gonna make sure that’s the case? Like that’s what’s going on. That makes sense. So if I want a VM named Fresh Baked VM Ubuntu, it’s gonna make sure that guy exists when you run it. If it already exists, it’s not gonna do anything. It’s just making sure that state is present. But because they often deploy more than one lab machine, this can’t work. So I needed this to generate a random name for me and I’m embarrassed to tell you how long this took me to figure out. 

So here’s what I came up with. It uses the password function that generate some random characters, but it does the job. So now when we run it, it will actually change something and create a new fresh baked VM for me. Delicious. So I made that change to LE node and AWS and I’ve gotta be done now, right? I mean this is, this is pretty cool. We can call it a day, but you know it doesn’t end there. It told you IT automation, it’s addicting. It’s too amazing and it’s hard to stop. And also I’m lazy. Now I’m warning you. What you’re about to see is the genies thing I’ve ever done on this channel. Now deploying VMs v Ansible, it’s cool and pretty lazy. I love it. It’s 

The best. I 

Love it. But I have to sit there and wait for it to finish and then I have to find the IP address somehow that’s just too much. So I put some thought to it. How can I be even lazier with this slack? I want Ansible to send me a message via Slack. When my VM is done, I want to hand it to me on a silver platter IP address, everything, all the goodies. Now it turns out this was actually pretty easy. Slack has a module, it’s well documented and all I had to do was add a few more spells to my playbook and bam, within moments I was basking in my new level of laziness. Carls go, except for Smox, not this one. It almost killed me. And honestly, I’m a little embarrassed to show you what I did to make this work, but I’m still proud of it. 

So I’m gonna show you anyway. Now, here’s my problem. Notice how with Le Node, for example, it gave me my server name and the IP address, it’s beautiful Prox ox, it can’t do that. The cloud is easy. They assign the IP address, both prox ox. When I create a VM with it, it does nothing with the networking, it simply spits it out into my network here and says, You’re on your own kid. And then my home network will take it from there. My router will give it an IP address, but only my router knows about that. Not what you’re probably thinking. You’re like Chuck, you can use network automation with Ansible. If the router knows the ip, then just have Ansible ask the router that’s gonna work. Right? Wrong. You couldn’t be more wrong. <laugh>. Sorry, still a little sore on this. You see, I use ubiquity unifying in my, my network here, a dream machine pro. 

To be more exact, you cannot automate with the Dream machine pro. You just can’t do it. I tried. I tried for hours. There’s no module. You can’t use the role cli, You can’t do anything ubiquity. Why can’t you just automate? You would’ve saved me so much time. You’re the reason I went a little crazy ubiquity. You suck. Just kidding. I love you. So I could have given up there, but no, I’m a network guy. I can think you of this out. IP addresses are what I know. Well not yet, but I’ll find out what it is. So the current state of things, Prox Ox doesn’t know the IP address of the vm. It created Ansible doesn’t know the IP address of the VM that it helped create, but it does know the Mac address. If I can get the Mac address from Prox Ox, then I can use ARP to find the IP address. 

So let’s see if it works. So allow me to walk you through a bit of madness real quick. And this is, this is a kind of therapy for me. So thank you. So first I got the VM I d and I used that with Prox box to grab the Mac address <laugh>, which I had to use a shell command, which is actually really cool about Ansible is that there’s not like a module for the thing you’re trying to do. You can just use a shell command, good old cli. And that’s what I did here. I used Prox Moli to find the Mac address and I had to do some really crazy stuff to put it in a format that ARP would like. So that’s, that’s all that a stuff. It’s pretty awkward. <laugh>. And then I waited about not five minutes. I don’t know why I have that. 

I waited one minute and then I attempted to arp, did it work? Did it find the IP address? No it didn’t. There’s no IP anywhere. Where did I go wrong? Well, I forgot a simple fact about arp. So I’m running ARP for my prox mock server and all it’s doing is checking its own a cash to see what Mac addresses it knows about and what IP addresses they have. But that’s the key thing I missed. It knows about it doesn’t know about all the IP addresses on my network. No device does. It only knows about the devices. It has to talk to my prox mock server has not talked to all the addresses on its network. How can I populate my art cash with every IP address and MAC address mapping on my network hacking? Of course I will use Nmap, I’ll use Nmap and have pros mock scan the entire network and populate that ARP cash. Great idea, Chuck. This was so Jake. Yeah, I told you. So I do an INMAP scan for Michelle after I wait about a minute to let the Vem come up. And now 

Let’s see if that works. 

Please work. Please work. Please 

Work. Do you see that? I got it. There’s the IP address. 

So now if I slap in Slack, that was hard to say. And run it one more time. 

Fingers crossed. There it is. 

This simple message took me so long but it was so worth it. So now I’ve gotta be done right. Well Node AWS and pro Smox can all send me a message when my VM is done with an IP address and it’s beautiful and I love it. But no, you saw that guy. You saw the guy in the beginning of the video, he’s not done. He’s an automation addict and they’re never done. I’m talking in third person. I’m never done. This is where my laziness and um, my madness peak. I decided that I was even too lazy to simply run a playbook. I couldn’t bother to enter. Well enter on the command line. I wanted something to do it for me while I’m relaxing, playing ping pong, playing video games, whatever. Now what if all I had to do was just like say it like any good magic spell, including magic it spells. 

That’s all you have to do, right? When Guardian love Yoa Mia vm, okay, I, I know the actual spell is like a co vm. I I couldn’t let that sit. I’m too much of a Harry Potter nerd to let that rest. I know it just didn’t flow as well. Just relax. So that’s where comes in now Nick, can you change that to where it doesn’t set off everyone’s us. God look, thanks. I want her to do it all for me. That’s my new thing, my new dream. I could not rest until it was completed. So here’s the new blueprint, my new dream. I tell Alexa I want a new vm. Then she tells Ansible and Ansible will tell Prox ox le node and AWS to make it. And then Ansible tells Slack and Slack tells me a beautiful game of lazy telephone. My favorite now for the stream to happen, I needed Alexa to somehow be able to talk to Ansible, but I didn’t know how to do that cuz Ansible by default doesn’t have an api, doesn’t have web hooks, which is normally how Alexa would talk to things. 

So I was kind of stumped. So we had to Google around also we asked Red Hat, like Red Hat, what can we do? I mean they made the thing they should know and they did. And I found something that changed the game. It’s called the Red Hat Ansible Automation Platform. This thing, it’s Ansible but Ansible that’s gone crazy, crazy awesome. It’s got a beautiful gooey, it does so many things, but it has an API and that’s just what I needed. That’s all I needed it for. So even though this is way overkill for what I’m trying to do, cuz you can use Ansible automation platform like to do a lot of stuff. Like huge enterprises do this. But no, I just wanted the api. So I signed up for a 60 day free trial installed Red Hat and then the Ansible automation platform on top of that. 

Which by the way, you can do the same thing right now. You can do the trial or if you just wanna play around with it just to mess with it, they have a sandbox. Check out the link below. It actually was really easy to set up. And then I just plugged in my playbooks and off to the races. Man, it was actually pretty easy to set up. And yeah, I mean that was, that was pretty much it. So here’s the final diagram. Ansible is now the Ansible automation platform. I plug him in there. Now there is one more thing I had to do. I could have programmed at Alexa Skill to interact with the Ansible automation platform api, but I didn’t wanna do that. So I used Zapier instead. So Alexa will talk to Zavier. Zapier will run some Python code to interact with the Red Hat Ansible automation platform api, which will kick it off to the node AWS and Smox, then to Slack. And then to me, this, this is it. My Mona Lisa, my sustain chapel VMs delivered to my watch, to my pocket. And all I have to do is wish for it. You wanna see it in action? Here it is. Here it comes.

Check Out Network Chuck's Coffee and MERCH Shop