Ansible 101 - Episode 14 - Ansible and Windows

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

This time, /u/nixfu, I shall not forget!

👍︎︎ 3 👤︎︎ u/geerlingguy 📅︎︎ Jun 17 2020 🗫︎ replies

hey /u/geerlinguy this was a pretty good episode, thanks for doing this!!

👍︎︎ 2 👤︎︎ u/Hollayo 📅︎︎ Jun 24 2020 🗫︎ replies
Captions
all right good morning my my preview just started playing an ad so it looked a little funny good morning everybody or a good evening wherever you are in the world as with all these streams if you would like to put where you are in the world it's always interesting to see where people are coming from I just realized my cameras pointed a little off so I'm gonna move over a little bit I've been working on some touring Pye video work lately and because of that I've had to move around all my cameras and things and I'm a little bit disjointed in here also because of because today's episode is going to talk about Windows I have set up my my Windows PC here I'm gonna be remoting into it through a remote desktop connection for some of the presentation and so I had to rearrange my desk which right now is a huge mess you can't see this area over here but it is a huge mess because I'm working on not only the Turnpike cluster but also a couple other interesting new projects that I hope to be sharing soon and one of them involving the high quality camera module using it for some Astro photography and also using it for some time lapse but photography I just got it in last week so playing around with that testing it so if you're interested in all that stuff please consider subscribing to the channel and and also if you're interested in me doing that kind of stuff on an ongoing basis please consider supporting me on github sponsors or on patreon the links are in the description below and and also I'd like to thank and especially the people who are supporting me as of this week in the past few days have started supporting me on github which is Neil Johnson Joss extra or hate extra Brandon Brandon Luna monolith projects Michael Moran ski and die dy which is I liked the the little logo its HP upside down and also Michael on patreon it helps a ton and there was just an interesting article on Hacker News yesterday about somebody who's who's able to do a lot of work and get enough sponsorship through patreon and github to be able to do that work full-time my end goal is to be able to do open source work and educational work like this full-time however I have a slight difference from the person who's making all that money I would like to do this and have everything that I do be open and free from the get-go instead of having something like I have this like if I did the streaming series only for sponsors and then later on if I reach a certain goal I would open it up I don't want to be like that I my whole life I've I've enjoyed sharing everything I knew free forever so anybody who supports me is is able to help support that mission anyways Aaron says thank fantastic for the 33,000 subscribers like I said earlier this year I had like 3,000 subscribers before I started the ansible 101 live streams and now I'm up to 33,000 my goal this year was to try to get to 5000 subscribers so I kind of blew that away and and that really made me think more about doing more of these series so I'm gonna have some more news about that towards the end of this episode but today's episode is talking about ansible on Windows and it's funny I so full disclosure I am NOT a Windows primarily developer I have used Windows my whole life my first if you notice the screen that the loading screen here that's not what I was talking about anyway the screen for that like the thumbnail for this video had the old Windows 3.1 logo the first machine that I ever used in computing was an old dos 6.0 running 386 and I upgraded the RAM I think I put a gig or eight gigs 8 megabytes of RAM over the years into that thing and I was able to run doom on it and I got Windows 3.1 and that was kind of my first computer that I I really used I put it together from parts my dad had brought home from from where he worked and kind of got it running and it was fun I also got my first electrical shock working inside of it it was only 12 volts so it isn't quite deadly or anything but I was touching the wrong part of the motherboard and realized don't touch that part of the motherboard anyways and I didn't have any SD wristband on at that time so anyways I've had a lot of history with Windows but I've never used it as my primary OS once I started doing work on computers full time I've used Linux here and there for short stints in the past but I've mostly been a Mac guy and that's because a lot of my background is more in design and web development things like that and I do a lot of media work but I haven't done as much until the past decade or so as much with sysadmin type work so anyway that's a lot of background just to say that I am NOT a primarily Windows developer some of the advice I give in this this particular episode might be might be good to look in live chat for people who might actually know more than me about Windows and using it with ansible but the first segment of this of this episode I wanted to get into was how to install ansible if you're running Windows specifically written at Windows 10 you can install the windows subsystem for Linux and that's the way that I do things I just find it easier because it's basically running Ubuntu or Debian or whatever your favorite distribution is it's basically running that inside of Windows fairly seamlessly not exactly seamlessly but it works well enough and for most ansible usage it works great I don't have any problems using SSH to connect to servers in that environment and with Windows subsystem for Linux to some of the little annoying bugs have been fixed but there's some other ones that I'll talk about later but one funny thing that happened was I pre-recorded this next segment just because it's it's one of those things where I don't want to try to do it on the live stream and spend 45 minutes on it because I forgot something because I don't do this every day and once you set it up you probably won't do it every day either but I ran into this fun situation because this Dell laptop I have I really use it for gaming and for mostly testing so when I want to test something that I do in ansible on Windows we're gonna want to test one of my Drupal projects on Windows I'll do it on this laptop and I voted it up I usually boot it up once a month or so and it had been like 60 days since the last boot up so of course while I was recording this thing two times two separate times that rebooted itself for Windows updates and that's always a fun thing that I don't enjoy on Windows anyway I'm going to show you this pre-recorded segment which will allow me to look at live chats so if you have anything fun to say in there I could actually respond to you for the next few we went at minutes but here is how I install danceable under windows subsystem for linux - using a bun - and the bash program that you get with that so there's a few different ways that you can run ansible on Windows and with Windows 10 if you're using the latest version and you can get windows subsystem for Linux - my favorite way is using WSL - and to install it you need to go to this guide page and copy these commands - to set it up so I'm gonna grab this command and it says open PowerShell as administrator there it is let me open it as administrator you can see also I have my my wonderful games that I normally play on this Windows laptop there but I'm gonna open up PowerShell and then paste this command right here and run it that's going to install the windows subsystem for Linux on to my computer and then I need to make sure that it's running WSL - so I need to make sure that the virtual machine platform component is enabled so I'm going to copy that and paste it here and for those not familiar with Windows you can right click to paste there's other ways as well anyways so let's say I also want to make sure it uses wsl - by default because there's some nice things in the bsl-2 that allow ansible to run a little better so I'm going to go ahead and do that and it's not working why is that hold on just a moment as I pause this and figure out what's going on I didn't read the rest of the instructions here I need to restart my machine so hold on for a moment as I reboot this computer and I can I can finish off the rest of this let's see restart alright so got rebooted and let me open up the guide that I was just working from again and I'm gonna open up PowerShell again his administrator and of course yes I want to allow that of course the chrome has lost the history where I was let's go back to there you can tell that I don't use Windows daily because I don't have all my preferences set up and all my browser and desktop and all that anyway so I rebooted the machine and now I want to set the default version hopefully this works this time I'm gonna copy that there we go all right let's see requires an update to its kernel component so I'll have to go to this URL I will have to install this extra thing here whoops I actually wanted to go to that but I'll go ahead and paste it in here so I'll need to download this right here and install it and I don't know why it hit itself okay next yes I do want to the Lao that oh this is killer performance driver sweet I'm not sure what that means but okay I don't really like the color performance driver sweet wherever that is sure I will undo those changes hopefully this PC does not have some malware all of a sudden I really don't use it for almost anything except for playing a couple games which are installed locally on the computer anyways it looks like it's finished all right now let's go back here and see if we can get this to run this time based okay that's good and then I need to install on Linux distributions so so I'm gonna go to the Microsoft Store which opens the separate app and make sure that I have a bunk to installed you can choose other Linux distributions and something like Debian would work pretty much the same as a bun too but I'm I usually run a bun too on Windows just because it seems like it has the most support and all right so it finally installed a bun - I was having some weird difficulty it seems like because I used to have it installed a while back under windows subsystem for the next one it had some trouble I had to reinstall it a couple of times I actually paused the video did that a few times and now it looks like it might actually be installed so I'm gonna go I could launch it from there but I'm gonna go into the Start menu and or whatever this is called nowadays the Windows menu and find where it is in here there it is it's installed just like a normal app but the first time that you run it I'm gonna go ahead and close Microsoft Store the first time you run it it sets things up it expands a disk image into the VM environment that it's running for a bun - and then it makes you create a user account so I'm going to do that and now I am running on a bunt to machine inside of WSL now there's some peculiarities with this and I'll talk about them in just a minute but the first thing I'm going to do is update the apt-get so sudo apt-get update and that's going to well let me type in my password that's going to make sure that all the installation packages have the latest metadata since we're going to use it to install pip we're going to install pip onto a bun - via apt so that we have Python 3 pip which will then use to install ansible so I'm going to say sudo apt-get install - why pip Python 3 pip and that is going to install pip and then I can use pip once its installed to install ansible now there's there's something that's a little odd about the environment here it in its bash profile setup the default setup that you have it actually loads the path that where pip installs ansible by default however it doesn't load it the first time you open up this a bun to app because it looks for a local dot local folder and a bin folder inside there the first time that you run it and it doesn't find that so it doesn't add that path to your system path in a bun - so after we install ansible I'm actually gonna have to quit a bun - and then start it again so I'll say pip 3 install ansible and pip is by default going to download and the latest version of ansible which for this particular video it's two point nine point ten it's probably gonna be a different version when you're seeing this unless you're seeing it on June 24th 2020 when this live stream episode is going out but it's gonna install that and it's going to put it into the path my home directory slash dot local slash bin and I'll show you slash that local slash bin and it installs all the different ansible binaries in there but if I try running ansible dash dash version it says it cannot be found and it's gonna suggest installing this app don't do that because you don't you know get the latest version of ansible that way unless you set up the ansible PPA which I'm not cover in this video because I like using pip to install it so the fix for that is to exit and then go back in and run a bun to again and that will reload the the bash profile setup and now if I say ansible - - version and we'll see it because if I say echo path the path that I have is updated to include that dot local directory somewhere in here I don't see there it is it adds this local directory in the path which is where ansible is located so now I have ansible installed and I can start using ansible - to do ad hoc tests to do whatever and the next things that I'll need to do is set up my SSH key if I if I have one so that I can work with a git repository and download things and synchronize things and so that I can log into other servers through this Linux environment another interesting thing is that you can actually call out to Windows binaries you might notice in this path that there's there's paths like /mnt /c if I look at all the disks I can see this path right here is a mount of my C Drive in Windows so if I say CD /mnt slash C and then look inside of here you can see all the windows file so you can access the windows files from a bun - or bash the XE and you can also access the bun - files from windows and it one one thing to keep in mind is when you do that the file system access is kind of through a virtualized boundary so you might have some performance issues if you have lots and lots of small files like if you're running applications through there however with ansible that's usually not much of a concern even if you have your files in the windows file system and your access them from a bun to bash like say for instance you're using the the get git bash environment in Windows to manage your git repositories and you want to access them through a bun - so anyway we have windows subsystem for linux - installed on windows 10 this is this is running the window 2004 not the year 2004 but the 2004 version of Windows 10 which allows you to run WSL 2 and then we install the bond 2 on it and now we have ansible ansible 22.9 point 10 running and now we can start doing automation inside of our Windows environment alright so that was getting getting ansible installed inside wsl 2 on Windows 10 and it works pretty much the same as if you have if you can't update yet - in Windows 2004 which is not Windows 2004 but Windows version 2004 the numbering scheme is really confusing me now because we're getting into like current events and I think what was 2004 was Windows 7 or Windows XP still I don't remember anyways the point of it is that you can install ansible either under WL 1 or 2 I just am using WS L 2 because it has a few other optimizations that make it run a little bit better in Windows 10 I want to get to actually using it now and I wanted to talk a little bit especially about using the ansible for DevOps examples so this repository on github has a bunch of the examples and I just realized that the new github is really throwing me off the new github design is is up and live and it's a lot different that's for sure but anyway there's a bunch of examples from the book in here and in the table of contents it has what chapter each example goes to and for example this node as example comes with a vagrant file and that allows you to use vagrant and if you're on a Mac or Linux computer you can just run vagrant up and everything is done and it works great on Windows the problem is that you can't run an ansible provisioner inside of power shell because ansible technically speaking it it could work and I have actually gotten ansible to run and do things but it doesn't really work that well and SSH is kind of a disaster inside of PowerShell right now that may change in the future but anyway the point of that is that it's it's impossible right now to get these vagrant configurations to run inside of PowerShell in Windows so a lot of people ask well can I just run it in WS l - well there's some complications there now you can see that I actually did get it running this is my abun to bash environment I actually got it running inside of this environment one one really funny thing that I noticed there's a bug with the font apparently the default font for a bun to bash is console us and if you use this font and I had it I had it set like this and if you say like vagrant status if you use that font and run any vagrant command vagrant actually outputs some character I don't remember what character it is it outputs some character that throws a bun to bash into this like raster or old school font mode and so the fix for that right now is to switch to lucida console because that font apparently has the right characters and console s does not or something like that anyways just a fun peculiarity that I found so I but I can get this working I have to tell you that it's not it's not just click a button and you're done there's a few different things you have to do to get this to work first of all you have to install virtualbox in Windows and VirtualBox does work now if you use VirtualBox 6.1 or later VirtualBox works in Windows with hyper-v enabled there's there can be some weird things that happen you might also need to edit your systems bios or its eee whatever the system is you might have to edit tweak it to turn on VTX virtualization support some laptops especially don't have that turned on by default so after you do all that VirtualBox should be able to run but you install that in Windows and then you install vagrant actually in a bun to bash and you can't just say sudo apt-get install vagrant because that's going to install a really old version of vagrant instead you have to install a version that you download from vagrant up comm whatever the latest version is I think it's two point two point nine right now you have to download that and put it into a pet as something that's in your system path I actually have some notes about that in in the repository I think it's under here if you if you want to get into all the nitty-gritty details downloading it and putting it into the right place then you have to also set this variable in the Ubuntu bash environment to make sure that vagrant knows that it's running under WSL and can run in Windows and and eventually you can run it but what I found is it doesn't actually control the networking correctly through a bun to bash NWSL - it might work in WS l1 but WSL one has its own peculiarities so what I found that I had to do to hit this all to work is I had to also install vagrant so I have it installed in a bun to the bash environment here and then I also had to install vagrant in the Windows environment and then I went into one of the examples so this is the node.js example and then I ran vagrant up from Windows and that creates the network connections correctly and then I went back over here because in Windows you can see here it says Windows is not officially supported for the ansible control machine because ansible doesn't run that well under PowerShell so I went back over here and I had to make a couple modifications because vagrant by default will connect over localhost and localhost is on a different network if you're in a bunt to versus the Windows environment and there may be ways to make that work a little better but I had to let's see I had to create an inventory file which is not necessary if you're on a Mac or Linux but I had to create an inventory file and that inventory file points to the the host IP address that is set up so that it doesn't try connecting over localhost and then it forces the user vagrant and then also I had to copy the private key file out of the Windows environment into the Linux file system because if you try doing this using the Windows copy of the key the in the windows file system everything is seen as 777 from Linux and so if you try using that key then SSH will be like you can't use that key that permissions our way to open so I had to copy the key into the Linux environment and then I changed its permissions to 600 so only my user can see the private key and then I can actually run vagrant provision and then I found another fun thing is that if you run vagrant provision 20 times maybe 12 or so times out of that 20 there will be some random weird error and I haven't tracked that down yet one time it said like the ansible module utils was gone and I'm like I don't know why that would happen it was always a random task that it would happen on other times it would say that git could not confirm sha hash other times when npm was installing it couldn't it couldn't confirm a file hash so I'm thinking that there's probably two layers of potential issues when you're doing things through WS l2 and also WS l want it sometimes I would have these kind of issues like here this one is saying you know randomly there's a structor integer out of range for l format code every time I do this I see some new weird problem and if I do it two times it won't show me the same problem so there's got to be some issue with networking or file system boundaries or something like that that's going on here because what we're doing and the reason why some of these things are complicated is we're running Windows so that this is not virtualized on my max this is actually this let me switch over here I'm already peeing into this laptop so it's actually running on a laptop it's not like four layers of virtualization but I'm running a VirtualBox VM that's managed using vagrant inside of Windows and I'm connecting to it through WS l2 so there's a lot of different virtualized networking layers going on and I think that's the problem so you can see this if we have another another error and this one is saying no module name the ansible module utils I don't know why exactly is this happening I've been debugging it you might notice in the next video and you'll just see in the next video what time it is anyways so so it's complicated I guess is what I'm saying you can get it to work and if you spend a little more time that you might be able to figure out some of the reasons like this time we got SFTP transfer mechanism failed didn't get that last time I don't know it's a little crazy there's every time that this stuff comes up on hacker news or on reddit or some things people like oh it's so great windows subsystem for Linux it's like you're running Linux on your Windows machine and it's like have you actually like tried it have you run applications in it I've never so far I've never had the experience that I have running on like a Windows machine or on my Mac where everything just works and you don't hit these random errors there are always random errors of software development don't get me wrong but windows subsystem for Linux is very far from perfect and seamless that's my experience now granted I do more complicated things and a lot of people who might just like install nodejs and run a node.js app but even that can have a lot of complications anyway so this time it actually all worked the playbook ran through completely and if I go to just like in the book example if I go to that URL in Chrome on the Windows machine and paste my fingers the the the keyboard memory hitting ctrl and set of command is always fun for the day when you're switching between Mac and Windows anyways it's working so so that's good that means that the deployment worked but like I said it gets a little bit complicated so would I recommend selling a Mac and going and buying in Windows PC to run examples that are in ansible for DevOps probably not if you're using Windows this is an option there's probably other ways to do this one thing that you can also do is get a vagrant file so in this vagrant file you could instead of using ant the ansible provision or you can use the ansible local provisioner which will copy the playbook into the VM and then you could actually run it from powershell doing it that way I actually do that with some of my other vagrant configurations I don't do that for the ansible for DevOps examples mostly because I try to make these examples work without vagrant entirely if you want to do it that way too or if you want to swap in any other kind of virtualization you can do that these examples are meant to be starting off points they're not meant to be like this is the only way you can do it so just keep that in mind Matt Matt is saying is this WSL too original and Mike mentioned yes it's WSL to each version has its own peculiarities that I found and wl2 improves on some things like theirs it's more consistent which is good but there's still some what I would consider weird bugs that I encounter in it and I try to document all those things so I've had all these issues and actually posted an issue upstream where is it I posted an issue in vagrants repository and I might or might not post an issue or two and wl2 about this mostly I like to do that because whenever I'm working on these issues and trying to figure out what's going on if I don't put my information like here's what I did out on the web then I'm not really advancing the state of our global knowledge about how this works so there might actually be a solution for this and somebody might know it and they could pop in here and post it and then when somebody Google's any of these terms that I have been talking about or any of them error messages that pop up then they'll get to this page and figure out that solution so that's one thing that I I like to do and in any of the development that I do and that's another reason why I love open source is because I have these problems with proprietary software and I have these problems with open source software with the proprietary software you usually end up in a black hole and there's no way you can see to fix it or you can't really converse with other people because the code is not open and the the repositories and the issue trackers and things are often not open so you end up having the same problems and you just you end up not being able to ever figure out how to fix them with open source software at least you can see that other people have the same problem even if you can never fix the process all right so we talked a bit about vagrant and running ansible playbooks under wsl - is is the same as running them under any Linux environment so now that I have ansible here I can run ansible and use SSH connections from this machine out to other machines just like I do on my Mac so I'm not going to get into deep hills and run a bunch of play books or anything like that but I can I can in this environment clone down--get repositories connect to servers connect to Bastian's connect to AWS do whatever I want because this is this is full Linux although with caveats like I said sometimes I ran into these weird networking and file system issues some of that's due to the fact that in this particular case I'm running on the C Drive this is as I mentioned in that video earlier this Drive is this is a mount of the C Drive that I'm running inside of and that's because vagrant requires that for some weird issue with the file system sharing or something like that you can also try running the stuff from within the the Linux file system and that may or may not help with some of the issues I'm having but that's just something to keep in mind where you're located on the file system can also dictate how things work anyways so that's wsl in in in Windows 10 and in the book I actually have a copy of the book with me in the book I have an appendix that's on Windows you have to note that I wrote this appendix I think in 2014 that was before WSL was even in existence so appendix it has a solution that can work you can set up a VirtualBox VM and do it in there this is basically doing the same thing but it's using the native WSL instead which makes a little faster a little easier and you don't even need to install VirtualBox if you don't want to use ansible and Windows so that is that sums up using ansible in Windows and I'm hoping to update that appendix to use this method and recommend this method since wsl 2 is now a fully supported feature of Windows for the past few months you'd had to be on the windows insider ring meaning you had to join the windows insider program and basically run beta software on your laptop to run this and I I would never recommend people do that it's if you're on the inside a ring you might know about things like the fact that your home director could have been deleted due to one of the updates and there's just a lot more buggy things that can happen it you shouldn't run beta software on your main machine almost ever I've done it once or twice when I really needed a feature really need to build for something but beta software's not all that fun to have to run just to just to use one feature like wsl to so the second part of this video and I'm kind of amazed that I hit the 10:30 mark or 11:30 or whatever 30 it is in your time zone or if you have a 15 minute or 30 minute increment it's not actually 30 minutes after the hour but the second part of this is talking about managing Windows machines using ansible and this is something you can do from linux from mac or from windows you can use any type of host assuming windows is using w cell 2 so you can run ansible in it you can manage windows machines for many of these servers so you can use a tower instance that's running in linux and manage windows machines with it because ansible uses different connection mechanisms for windows and there's actually a couple different ways you can do it and I guess I'll get into the next little pre-recorded video here and again I pre-recorded this because of the fact that since I don't do this setup everyday I know that I would screw something up and we'd spend 10 minutes just going around trying to copy a folder into the right path or something crazy like that so I recorded this and you'll see that the this was kind of under the wire last night so here is that segment there are a few different ways you can set up connections to windows from ansible and one of the traditional ways to do it is to use win RM but since i am a bit more familiar with SSH and since Windows 10 and the latest versions of Windows Server now support running OpenSSH although it's a new feature so it's it's probably not going to be available everywhere I'm going to use the windows ssh method for connecting to my my windows workstation and all you need to do basically is install this win32 OpenSSH project on your Windows machines and after you do that it's it's pretty much the same as connecting to any other SSH host with a couple small differences because it's windows and not Linux so there's an install guide on the win32 OpenSSH wiki and the install guide basically tells you to download the latest version and then run an installer so to get the link to the latest version I'm gonna go to this wiki page and copy out the installation setup for OpenSSH win 64 so I'm gonna copy that and open a PowerShell window and paste it in and then go ahead and grab this URL and downloads file it wants me to download the file and extract the contents into the folder program file / open SSH so I'm going to go ahead and download that file here open it up I'm gonna copy this folder out and go to the C colon slash Program Files and paste it into here and I'll go ahead and allow that to happen and then I'm going to rename this folder to just open SSH now I also need to relaunch PowerShell or open up PowerShell as administrator so that I have permissions to be able to install this thing so I'm going to go into C colon slash and I know that CD is not the proper technical way to do it on Windows but since partial alias is that Tudor I will hurt it into whatever the command is in Windows I can just do it here so I'm going to go to C colon slash let me go back to this page sequel and slash Program Files slash OpenSSH and then run this installation command right here and that's going to install it now that it's installed I also need to open the firewall port and since I'm running a client desktop machine Windows 10 I can run this command to open up my firewall on my machine so that it let's SSH activity go through and that just outputs okay so I guess that means it's okay then I need to start the service so I'll take that and run it and it looks like it started successfully and then I also want to make sure that it's running on boot-up so that I can always manage this machine even if I reboot it so I'm gonna do that now at this point ssh should be running so if I go over to my Mac and I try connecting ssh j Girling is my account name and let's get the IP address i think it's a if config if if if ap config there it is okay so the IP address for this workstation is 10.0 at 100 dot 112 and if I try connecting Jake yelling at 10.0 dot 100 that one too and put in my Windows user account password I am now logged in as as my user on this Windows laptop via SSH and that's pretty cool now one thing to keep in mind is the defaults will actually use the command cmd.exe for your shell so if you try doing those things that I was doing in PowerShell like saying LS for listing the directory it's going to say that that's not recognized because that's a PowerShell alias Tudor which won't work unless you're actually in PowerShell so that's something that you could set up I'm not going to cover that in this video but at this point we can connect via SSH and so if we can do that ansible should be able to control this computer by SSH so I have this project set up here and it has a typical ansible an inventory file that has one server which is this this PC that I have in my in my room here and there's two important things that you have to tell anta about one is the aunt wall connection which in this case is SSH that makes sure that even though it sees it as a Windows computer it's going to use SSH because that's the way that we're connecting to it and we want to make sure that ansible knows what kind of shell to try to use you could change this to PowerShell if you we're using that on the windows side and had that set up in the OpenSSH settings anyway so we have this host file and there's an ansible dot CFG file that basically tells ansible look for that host file so I can run ansible and then I'll say Windows to operate on all the servers in this windows group which is just one and then give it a module and for Linux OS we would use the ping module but if we do that on Windows this module won't actually work there's a lot of modules that are written more for like Linux and POSIX environments and they don't work with Windows because of the different protocols and ways that Windows works with files and file systems so instead of that I'm going to use the win ping module now one thing to keep in mind is that long term this might change actually and be something like ansible dot windows that ping but for now it's all these modules that are specific for Windows are like win ping and then I'm also going to say ask pass because I haven't set up an authorized Keys file on the Windows machine yet but you can do that just the same as SSH anywhere else you can use private keys and things like that but I'm going to have it ask for my password I'm gonna put my Windows user account password in and it looks like ansible can successfully connect to this server just like it can to any other server running SSH so that's that's the way that I like to connect to Windows but like I've said before I'm not I'm not like the windows expert and I don't manage fleets of Windows machines so your mileage may vary there and you might also not even be allowed to set up OpenSSH on your Windows servers and in that case you might want to use win RM or if there's any other ways to connect you could do that anyways back to me I guess because I'm doing this live stream and I just pre-recorded this video and I am now talking to myself by myself alright so that is how you can get OpenSSH running on Windows and as I mentioned in the video there's a lot of the modules pretty much all the modules that ansible originally came with were not written with Windows in mind and I think early on in the life cycle of adding Windows support to ansible the decision was made to not try to make all the modules like file and copy and all those things not make those modules be like split brain and have a ton of code for the POSIX and Linux environment and then also have a ton of code for the Windows environment so instead of doing that all these modules were created the Windows modules you see on this page and basically it's a lot of them are the same as they are for Mac or Linux but they're just prefixed with wind so there's a say there's a say module that can use text-to-speech on my Mac which I sometimes use to fun effect but there's for Windows it's win underscore se and there's wind underscore shell and there's win underscores that so a lot of the modules that we've used and all the other examples that we've done so far work work similarly if not identically on Windows it's just you're not gonna have the same kind of things like when you copy files to window hosts to Windows hosts now that's gonna be a word that I mess up it doesn't have some of the options like owner and group and things because file permissions work differently on Windows and they do on on Linux and and POSIX II types of file systems so somebody also earlier mentioned about managing managing Windows machines using Chaco or chocolaty and there are some modules for that already in ansible wind chocolaty and all these different all these different modules you might notice that the video that I played a few minutes ago was recorded at 11:30 or so last night I was planning on getting a little bit more stuff done and having a full kind of set up playbook kind of like I do for my Mac dev playbook which I'm active PlayBook that's the license file this Mac dev playbook is what I actually used to set up my Mac laptop it installs all the software it configures configurations for sublime text and them and all the dot files and things so I was planning on setting up at least a basic structure for that but I kind of run out of ran out of time because I was having so much trouble with getting vagrant to run and I you know I finally found that worker on that I have that gets it to work sometimes but I didn't get time to set up a full playbook that shows it but at a very basic level it's in the ansible playbook is an ansible playbook you you give it in one play you have posts and I have windows because that's the group that I have in the inventory file and then you use modules just like you would with any other ansible playbook and you can copy files apparently you can even defrag that was one of my my favorite pastimes back in the early Windows 95 days whenever he had a slow slow volume you know on your 80 megabyte hard drive ID or scuzzy or whatever you would run the defrag on it and watch this little those little squares move around until it was so nice and orderly people with my old borderline OCD which I probably have something like that we just would love that because you see all the disarray and then it kind of puts itself all together and then it's so much happier I believe you can still I guess you can still defrag I I haven't defrag this laptop ever I don't think it's as necessary anymore but I think you can still do that nowadays but anyway there's there's modules for all these things and I believe in civil windows collections I can look this up oh let's see here we go ansible collections so there's there's a new Windows collection here and I think that the collection is still using the prefix like it's so instead of if you're using this collection of Windows modules you would formerly use ansible let's see ansible windows - em wind ping ask and you might also hear some weird sounds coming from above me although it's not spatial so you wouldn't know that it's above or below or anything but my kids are playing with marbles they have marble works out upstairs and I just all day for the past couple days just all these marbles dropping my brain is about to explode anyway so in the in the past or in the present and if you're using ansible the the main community distribution it'll still work this way for at least some time in the future you can just call it like this if you're using this ansible windows collection if you have this installed separately you would call ansible dot windows that wind ping I think at some point I'll enter that again should really set up a key and I don't have that collection installed so obviously it's not going to find it at some point in the future I believe that the the the goal is to get these all aliased so that this would be like the old module name but the new one would just be ansible that windows dot ping and you would run it like that so it long-term it might be like that for now you can just use wind ping like this and it'll work or in your PlayBook use it like this and as I mentioned the collections episode I don't remember if that was last episode or whatever time has kind of run into itself as I is wearing what week 14 or 15 or something of this lockdown time and since I have a I'm on immunosuppressants I'm kind of locked down until until things are a lot more settled down so wear your masks anyway so in that in that episode I talked about collections you could also if if you wanted to use the collection module and he didn't want to type in ansible that windows that wind ping you could put in collections ansible that windows assuming that you have this collection installed then he could do that and it would use that that collection module to so anyways like I said I wanted to have a little bit more of an example of a full windows playbook that that does a lot of different settings but the main the main point of this is that with Windows a lot of the things that you do are the same as you do in in the Linux environment it's just most of the modules are prefixed with Wynn and almost I'd say that all the modules it's up for maybe two or three that I use work great in Windows that and just the same as they do on Linux it's just obviously you have to have a different mindset because the file system is different the way that that PowerShell works is different you can run PowerShell scripts a lot of people end up doing a lot of that for kind of glue work in the Windows environment and somebody also asked in the live stream earlier about joining like controlling through the domain and joining with LDAP and things like that those things are things that I will not be covering because like I said I am NOT a Windows expert at all I use it a good amount mostly to play Halo because I don't have any other device I sold my Xbox 360 like five or six no like eight or nine years ago so that is the literally the only way that I can play Halo anymore so it's kind of fun to play it there but I don't I don't manage a lot of Windows machines I that the last time I did that was a couple years ago I helped migrate some stuff off of I is into an Apache environment so I am definitely not the expert to talk to there are experts that you can talk to and if you if you have a Red Hat support contract I would I would definitely talk to Red Hat support and ask them about specific questions and problems you have and I believe that there's an instable Windows IRC instable Windows IRC I believe there's an IRC Channel yeah ansible windows so if you wanted to join that channel you can ask specific questions and there as well and there's there's more information than documentation this is actually an old one this is from ansible 2.4 so it's far out of date but there's there's other guides in here that teach you more about using ansible some of the things that you'll have to keep in mind and how to do a lot of different things with with managing Windows machines and running Hansol on Windows so I think that's all that I have for this particular episode but I did want to say a few things about the next episode so you might remember that I started this series I don't remember when it was it's been a long time we're on episode 14 today so it's been 14 weeks I guess that's an easy way to remember how long this how long I basically been holed up in my house the next episode will be the final episode of the ansible 101 series there's a couple things that are in this book ansible for devops that i have not covered particularly docker and kubernetes and some of the more advanced examples like the ELCA monitoring stack things like that and the reason I'm not covering those is because those are things that don't translate as easily into a one-hour episode of ansible 101 and I really don't want to I also need to take a break it's when I started this I was doing two live streams a week two one-hour long live streams a week and that was that was kind of killing me so this is still a little bit stressful and I want to finish off some other work that I'm doing for other YouTube videos so there there will be a follow-up this will not be ansible 101 what I'm thinking is I'm going to do something on kubernetes and if you have suggestions for things that you'd want to really see it would be starting more from like here's how to use docker and/or pod Man and here's how containers work and then getting into kubernetes and then getting into automating kubernetes with ansible that sort of thing kind of following the book that I do not have a physical copy of yet because it's not finished which is ansible for kubernetes there's a link to it I don't think there's a link to it in the description but there's a link to it anywhere just google ansible for kubernetes so I'm probably gonna be working on that sometime soon so if you want to see that if you want to see other things please hit subscribe below me it's right below my little video box here and also if you want to see more content please go over to github sponsors or patreon and sponsor me that's definitely the best way to make sure that I motivated because if I if I can't earn enough revenue to be able to do this stuff and and still support my family and things like that then I won't be able to do as much but for next week's episode it's gonna be the final episode I am going to do kind of a Q&A usually at the beginning of these episodes today I didn't do it just because I wanted to make sure I had time usually I cover some questions and answers from the previous livestream and next week I'm just going to cover some of the general questions I've heard and also any questions that you might have I have a Google Form set up here and it doesn't require an email address or anything you can optionally add your email address if you want to be added to the ansible for DevOps mailing list but you don't have to I don't really care about that I'd really just want to get some questions for the next episode and there will be one special surprise based on questions I'm not going to say exactly what my criteria is but somebody will be getting this copy of the book and maybe some other thing or two I don't know what else what else I can throw in the box definitely some open source stickers but obviously there's no purchase necessary just ask a question about the instable and and I think you can submit multiple questions I don't think I restricted it but this book is a collector's edition because it has all of my scribbles in it I guess so and and also I need to replace it with a newer copy this is version 1.2 0 I think and we're up to 1.2 3 now so I'll be on 1.2 for very soon because I'm working on the new chapter 7 that I talked about last week on collections I'm working on rewriting the tower chapter I'm working on rewriting the ansible windows guide in the appendix and the sad thing about this all is that on Amazon they don't allow me to update the published date for the the paperback book so it still says it was published in 2015 and and there's no indication that it's ever been updated so yeah the other annoying thing is the top review on Amazon is somebody who gave it like a one-star review saying it's terrible it doesn't cover anything and nothing works in it and then oh okay and I don't understand that but whatever whatever floats your boat or weird flex but okay I'm so cool because I know all those things anyways let me a glance really quick yeah Hans says he does yell K for a living that's a book on itself yeah it's funny the the section in the book on LK is a very small example of what you can do with it and I actually ran in production in a kubernetes cluster a pretty big beefy elasticsearch fluent D and Cabana so EF K set up inside of kubernetes and we ended up pouring tons of resources into it I think the persistent volumes for the cluster that we had were up to like three or four terabytes at some point and I don't know how that projects going anymore because I kind of we kind of moved it on to someone else and they it was working but it was it was getting hundreds of thousands of log messages streaming into it per minute and it was a lot of data and it was it was fun to manage so yes EF k and e lk which is elasticsearch log stash in Cabana or you might use something other than log stash to put logs into it it's it's a common way nowadays using open source tools to get logs streaming into a system and be able to visualize the logs and see see trends and things like that so it's extremely necessary if you have multiple servers and have a bunch of applications you could use like ar-ar-ar syslog or other solutions like that but f K gives you a full stack of storing and managing and visualizing log files anyways yeah that could be its own streaming series elasticsearch even just elasticsearch could be a few episodes so I definitely can't cover that in ansible 101 but anyway so please go in there's a link in the description below me to this same Google forum and ask any questions you have about ansible or the streaming series or anything like that even if you want to ask about how the series went or things like that for the next episode I'll also hopefully have a few stats that I chair about it that will be interesting and fun and I want to celebrate just a little bit I guess because not only that but also at least in some parts of the world life is getting closer to normal I there's some parts of the world that are being a little crazy and dare I say irresponsible with the way things are going with the current crisis but but anyway we can celebrate a little bit I guess one good thing is I got food from a restaurant that I had not gotten food from for three and a half months and so that was kind of cool that was for Father's Day I ain't got something so anyway fun times I will see you guys next week and thank you for subscribing thank you for supporting me on github or patreon and hopefully if you do use windows or if you're needing to support Windows you got something out of this but like I said go join the IRC channel ansible windows if you have specific questions and read the documentation because I am NOT the windows expert but I know enough to to be dangerous you
Info
Channel: Jeff Geerling
Views: 16,714
Rating: undefined out of 5
Keywords: ansible, ansible 101, devops, playbook, automation, collections, galaxy, plugins
Id: N7tgLVCXup4
Channel Id: undefined
Length: 57min 38sec (3458 seconds)
Published: Wed Jun 24 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.