This web UI for Ansible is so damn useful!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I recently found this incredible web UI for ansible it's super simple very lightweight and of course free and open source this is perfect for everyone who likes to automate stuff in ansible no matter if you want to update all your servers at night build and deploy applications or run scheduled cleanup tasks everything that you can do in ansible playbooks can be so easily managed with ansible zema 4. so let's check it out I quickly want to show you how to install it and go through some of the stuff you can do with it and by the way if you are entirely new to ansible and you're wondering what the hell is this guy talking about you should go and check out some of my older videos about ansible this will give you all the foundational knowledge that you need but let me stop talking and let's start automating your home lab with ansible xenophore this video is supported by teleport a free and open source access proxy that helps you to securely authenticate to all your it infrastructure like Linux servers databases kubernetes clusters web applications or remote desktop you can easily protect your accounts with modern security features such as two-factor authentication or a password that's logged in and access your services through the browser or the seal eye tool with audit logging and session recording and the best it's completely free in the community version so you can just download and run it in your entire home lab or if you would like to use it in your company teleport offers many professional features like auditing single sign-on and more it's a great tool so just check it out you will find a link to their website in the description of this video if you want to find out more about this project you can take a look at the official homepage ansible.com this will give you a good starting point because the documentation is really good it's very detailed and there you will find all the instructions for installing configuring and much more for example you can just run a simple snap command to install it on a Linux machine or you could use the provided Linux packages the dot Deb ones are for Debian based Linux distros like Ubuntu and the dot RPM packages for Red Hat based distorts like Centos Rocky Linux and so on there's also an example Docker compost file you can find if you want to install it in a container and guess what I've been using to install it if you're watching my channel for a longer time you probably know I like to deploy everything in a container because it's just the easiest way for me but of course it's completely up to you how you want to do that in your home lab I've also created a simplified version of this Docker compose file that we can use as a template you will find just like all others of my resources on my personal GitHub Link in the description navigate to the boilerplates repo go into the darker section and then you will find a darker compose file for ansible xenophore in the corresponding tutorial folder for this video I am connected to one of my demo servers and have prepared a new project directory where we can start a new instance of ansible semaphore by using our Docker compose template I just needed to change a couple of things in this compose file like for example changing the database password or add a strong admin password and I also needed to generate a new access key encryption this is needed because ansible xamar4 stores sensitive information such as your SSH keys or passwords in the database and of course we don't want this information to be stored in clear text so we need to use a secret access key to encrypt it you can simply generate this with a single command you can find in the documentation of ansible xmr4 or in the write-up for this tutorial on git just add your secret key to this Docker compose file and once you have prepared all of this stuff you can start up the docker stack with a Docker compose up command in your terminal as you can see on my server this is currently generating the database config and starting up all the services for the web server and when everything was successful you should be able to connect to the ansible xamar4 web UI in your browser now you just need to log in with your configured admin username and password to create a new project and here we are just a quick side note I know I kind of rushed through this installation process of course this should not be used as a production setup because answers with zema 4 like most web applications doesn't have its own TLS certificate in part you should definitely look at protecting this with a reverse proxy like traffic or nginx and you should probably also not store Secrets like the passwords or the encryption key as clear text in your compose file that's not a good practice however I've already covered these Topics in others of my videos so I'm not going to cover it here again because I need the time to show you some much more important stuff for example I quickly want to show you some playbooks and templates that I'm running with ansible zema for in my home lab as you can see I've grouped all the playbooks in different categories like update maintenance installation configuration and deployment for instance these two playbooks here update all the Linux packages on my servers every weekend as you might I'm mostly running Ubuntu Linux machines in my home Labs so this Playbook will do an apt upgrade command on all my production servers and the other one will do the same on my demo servers and both will notify me whenever one of my servers needs a restart after that I also created one Playbook that will check the disk space on all of the servers every day and notifies me about any server that is eating up more than 80 of the disk space because I already had so many problems with my kubernetes clusters getting damaged when the virtual machines were running out of disk space yeah the usual funny things that always happen on the weekend and this Playbook really helps me to get notified even before it becomes a problem I also use other playbooks here to provision new virtual or physical machines just to make sure every server has the correct packages installed extremely useful ensure I could do all of this stuff with ansible CLI as well but it is kind of neat to have answers with xenophore in place for scheduling these automatic update tasks or to manage the different environments like production demo and evaluation I also have a complete history and user management for all of these tasks that is really nice to keep track of all the things you are automating in your home lab with possible by the way if you're wondering what exactly these playbooks do when the jobs are running here is the actual repository where I'm storing all of them this for example is one of the update playbooks on my Ubuntu servers and it also checks whenever one of these servers need to be restarted and then it sends me a Discord message using this webhook here I'm really proud of that and it also makes the most sense for me because upgrading all of the packages automatically on the server is one thing restarting the servers is a different thing so that's why I've split it into multiple tasks and only updated the update not the restart the checking disk space Playbook is also pretty straightforward this is just using the same method using a Discord web hook to send another message once one of the servers is running out of disk space and this is the installation Playbook that just makes sure all of my servers have the qmo guest agent running the NFS client unzip and basically anything else that I want these servers to be deployed with if you want to use some of these playbooks as examples or templates to build your own stuff with it you can find them in my boilerplates repository on GitHub just go to the folder ansible and here I'll update them from time to time if you like you can also share your own playbooks with our community just raise a new pull request or issue to GitHub I usually take care of all of this stuff and include it from time to time into the main branch so yeah any help extending this repo is highly appreciated but these are just a few examples that I wanted to show you of course you could do anything in these playbooks to automate all sorts of processes in your home lab and let us quickly go through some of this stuff here step by step first otherwise I'll forget it always enable dark mode in ansible zema 4. this is really important because real ID guys should never work without dark mode okay so as you should know from my other ansible tutorials you need to set up three main things to work with ansible you need an inventory which is basically just a set of IP addresses or DNS names from which ansible knows where and how to connect to your machines second you need a secure authentication to your machines like setting up a user at SSH Keys maybe also Define a pseudo password and third you need to create the actual playbooks in ansible xenophore the playbooks always need to be stored in a git repository so you would either need a get top or gitlab account or maybe some experts in here might have their own self-hosted kit running as well who knows because whenever ansible xemophore wants to start a new task it always puts down the latest version of the playbooks using git which is great for consistency and integrity of your jobs there's also one other thing that we need which is an ansible semaphore kind of special thing which is called environments but we will set this up later let's first start with a secure authentication to add a new SSH key in ansible xenophore I'm going to add a new key to the key store select the type SSH and then I'm just pasting my private SSH key in here that I'm using to authenticate to all of my servers and I'm also defining the user that this key should be used with which is also the same on all servers note if you have different users on different servers don't worry the username here is optional so you can still use the same private SSH key to authenticate different users or upload multiple keys that you can all specify later in the inventory if you want to add a pseudo password for example if some of your playbooks need that to become the root user you can also create a new key for storing these credentials as well just switch the type to login with password and then add your sudo passwords into this field and you might also want to add a new key with the type none which can be used as a placeholder for public repositories more about that in a minute next we can create our inventory so here we can select three different types of inventories a static inventory file that is managed and stored in ansible xamar for itself the same with a yaml formatting or you can link any inventory file that exists in the file system for this short demonstration I'll just add a new simple static inventory file which I'm calling home lab and I'm also adding the private SSH key we've just created as a preferred user credentials and the sudo password as sudo credentials once we have done that we can start ending our machines to this static inventory I'm just adding a couple of different demo machines in here that we can use for short test these are all DNS names that point to the IP addresses of my actual demo servers but of course you could also enter just the IP addresses or group these machines I've explained the ansible inventory file and grouping stuff in a bit more detail in my other ansible video so I'm sure you're all very familiar with how it works okay awesome so now that we have this we can add a new repository where we want to store our playbooks in I'm going to use my videos repository that I'm already maintaining on GitHub this is where you can find all the write-ups and commands for all my video tutorials like this year now in the branch setting you can Define which git Branch this repository should pull the playbooks from typically you would use the main branch of this repository but because I'm always using a separate Branch for every new video project that is work in progress I'm just setting the branch here to ansible xemma for tutorial this is where I'm currently working in and where I can upload the testing Playbook file later if you have a private git repository or you want to use the SSH method you would also need to add a valid SSH key in here for authentication but because this is just a public git repository it's easier for me so we don't need to do any authentication and just can select the access key none that we have created as a placeholder just a side note you can add as many repositories or branches as you want it answerable xamar4 I'm for instance organizing all of my stuff in one single git repository that I'm calling ansible and then I'm maintaining a few different branches for testing development or evaluation playboots in ansible xenophore I can later then add new repository entries for all these different branches and use it in different templates and jobs by the way I'm just realizing that someday I probably need to make a comprehensive video about git because I sometimes forget this might be the bread and butter of a software developer but homeless people sis admins or network guys might not be so familiar with all the different processes and things you can do and get it's really an amazing tool and very powerful but I need to admit that it's not always intuitive so what the hell is a branch when do you create a new branch and what is the pull request and so on so please do me a favor if you would like to see these kind of videos from me in the future where I'm explaining those Concepts please leave a like And subscribe this always helps to push out the video on YouTube and it gives me a good indication of which topics you're really interested in and yes I know I know you want to finally see me setting up an answer Playbook here but there's one last thing that we need to set up first which I already mentioned before we need to add an environment and this is extremely useful to pass different environment variables or arguments to your ansible jobs but it's not all always required you just need to add at least one environment in ansible demo for but a way I can just add an all environment and fill it with two empty curly brackets that is totally fine no because we have done all the necessary setup we can start defining templates for running the actual playbooks and this can be done in three different ways and ansible them before by setting them up as normal tasks build tasks or deploy tasks honestly this was first a bit weird to me because I didn't know what is the difference between a built Playbook and a tasked Playbook technically there isn't really it's just a different way of how ansible xamar for treats and tracks at this tasks template but as far as I have understood it if you want to use ansible to build software so for example if you're compiling a program or training a Docker image from source code you would use a build task so that will add version tracking to this in ansible demo 4 and when you then like to deploy this software you would in the Second Step Define a deploy task where you can select your build template and ship your application to your target machines if you want to find find out more about these different task types you can read the official documentation but if you don't do any of these things in ansible you just want to keep it simple then always use the type task that is what I'm doing all the time and I guess that's totally fine for running any playbooks that do installing packages update packages or configuring applications I never really needed a build or deploy task in my home Lab at least for now heads for this demonstration I'd just like to run a simple apt update Playbook so I'm going to name this update apt packages and then we will need to fill in all the options and settings that we've defined earlier of course we haven't created A playbook in the git repository yet so that's why we will come back to this later and first switch to vs code here I'm just doing a very simple example creating a new folder in the ansible xemophore tutorial directory and call it playbooks and here I've added a new ansible playbook which I've called update app packages.yaml just just like the task template this can run an apt update on all the hosts in my inventory so we'll start with defining the hosts and set it to all and because this is an administrative task we would need to switch from the regular user to the root user with a become true statement and then we can just Define our tasks I'm just adding one simple task to update all the APT packages on the machines again a very very simple example and to push this Playbook to the git repository just Commit This a change with any message and sync these changes to the branch that you have defined in ansible zema for I'm quickly going to check if our Playbook shows up in GitHub yes that's fine we can all go back to the ansible zema for UI and finish the configuration of our template now I've just put the correct file name for this playbook in the Playbook file name field and because I've stored this in subfolders I needed to add the full half of the playbook in here otherwise ansible xenophore didn't know where to find it and then selected the inventory home lab set the correct repository to videos of course and just added our environment all that should be everything that we need of course you can do all sorts of customizations to your templates like adding variables customizing arguments or if you want to schedule it like run it every week or every day you can add a cron expression in here so then answer with xmaphore automatically runs this Playbook whenever you want this is by the way the most important feature why I'm using this program in my homeland because then I can use ansible for doing automatic updates I'm happy with creating a simple task template that we need to run manually so let's finish and create this template and here we have it on our list we can now click on the actions run and because I want to do a quick test if everything is working but I don't want to execute any of these tasks from The Playbook to the machines I'm selecting the dry run options so that is useful if you want to do quick tests and when I run this it opens a new window where we can see what's currently happening on the server you can see there is a new process starting in ansible zema 4 it's cloning the repository videos then it executes all the stuff we have defined in the Playbook just like you would do it in ansible CLI and when the job is done you can see a full history of all the tasks that we have executed in the list whenever they are successful or if you got any errors that's really cool to keep track of all the actions that happen on your machines of course if you're working with multiple users on a single project you can also see who has executed which task template if you need to find out Whoever has destroyed your server and who needs to install a new one and because this was just a quick test with a dry run let's now re-run this task again but no without this dry run flag so now you can see when I'm executing this Playbook again this time it takes a bit longer because the servers are currently running the app updates as this was all successful you can see the ansible tasks has made changes on all three servers and if we now check one of them you can see all the app packages are up to date so everything worked as it should and yeah this is basically how you can use ansible zema 4 as a nice and clean web UI to manage all the ansible automation tasks in your home lab I think this adds some very interesting features to ansible like user management having all the playbooks in a centralized repository managing different environments like production testing and so on or you could even use it to build your own pipelines and build processes with it similar to what we've seen in GitHub actions and other CI CD tools but still it is simple enough that I think it's perfect for any Homeland user yeah even when you don't need all of these Advanced features and you just have a few tasks you want to schedule automatically and ansible this is where ansible xenophore absolutely shines as well but now you can tell me what do you think about this put it into the comments and as always thank everybody for watching I will catch you in the next video take care bye bye
Info
Channel: Christian Lempa
Views: 161,115
Rating: undefined out of 5
Keywords:
Id: NyOSoLn5T5U
Channel Id: undefined
Length: 20min 7sec (1207 seconds)
Published: Tue Jun 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.