so there's the concept of in infrastructure is code which of course is codifying your infrastructure so that you can potentially um redeploy it or um basically reproduce that um that infrastructure now that concept infrastructure is code can be broadly split into two sections you've got infrastructure provisioning which is sort of like your Hardware if it's virtual so those could be spinning up virtual machines creating virtual networks um deploying uh deploying firewalls app gateways that sort of thing um and then there's configuration management which is actually configuring that infrastructure so that could be creating firewall rules it could be deploying software um anything like that
anible runs on a Linux host which is why we need to have a little bit of Linux in our back pocket cuz um we are going to be touching that um and to achieve that uh requirement you could use Windows subsystem for Linux on a Windows box or run a full VM or run be metal Linux um I personally go for a full uh Linux VM um but that's just because I use VMware Workstation and turning on the WSL stuff kills some of the things I need out of Works VMware so um I sort of don't have a choice um
now there's multiple ways to install ansible you can install it from your systems um via your systems package manager like python there except um it's generally going to be an older version um so regardless of the distribution for Linux I I prefer installing it via um the python package manager pip um that ensures I always get the latest version um
um the first thing I need is a user so let's go ahead and create a new local user no there um I'm calling this user anible um you can name it literally anything at um I'm just calling it anible cuz I'm not feeling very creative at the moment with my naming and you'll see that when you see the name of this Windows box as well
so created a folder for my demos um ignore playbooks there as I said I'm was up against time so I've pre-populated that instead of making you watch me type for a couple of minutes um cuz stuff like that happens um so I've created a folder called inventory and in there uh that's just a convention the folder could be named anything um and I'm going to make a host file in there now this um this inventory can take the form of an any or config file um or a yo file
be a member of two groups the uh automatically assigned to a group called all so that's literally just how you can um address all of the um all of the machines in your estate or at least the ones in your inventory and then they're also a member of either the groups you've defined or if you've listed them in here without assigning them to a group they go into an ungrouped group
um so my first group um just because I want to list everything that's in my lab here I'm going to call Linux servers and that has two hosts uh there is anible and there is Nexus um Nexus is just a box that I've got here um basically shielding me from any Wi-Fi issues
now you notice this is taking a while to come back what it's doing is it's trying to connect via SSH to that box and it should come back in a moment saying no I can't get an SSH connection up so same thing we need to tell it no actually this is a Windows box we want you to connect with winrm
so so far we've been running Ed hoc commands on the command line just calling anible saying run this module against This Server all right now we wanton want um to go into the playbooks that I said to ignore for now um so A playbook is basically like think of it like a script file in poell
then what we're going to do is we're going to use the one copy command to copy a file into that directory and by not specifying a file name on the destination we're saying keep the original file name uh now that file is I've just uh pointed to it relative to where this uh demo file sits
as good as all those commands are that are available eventually you're going to find a hole that is not an anable module to do the thing you want to do and luckily there is a um po shell module available which just allows you to run Parell at that point you can do whatever you want
the main thing I want to encourage is just have a go um don't let the fact that you need to um use Linux um don't let that be a barrier to um having a go with anible
get yourself a indent highlighter in vs code and um it will help um I've also been using ansible as an excuse to learn Linux more and I've been really enjoying that
so I did um include that at the end of the next talk but um where to from when you actually start to um use this in an organization you'd be looking at tools like awx
you can pull into that your inventory you can pull into that your playbooks and then you can schedule and run them from there and then you've got a central view of what things are running what things are failing
so the question was does that power shell have to be in line so it doesn't but I've always done it in line and that's just cuz my my how I've worked with it so far is if my power shell has gotten too long