Ansible - A Beginner's Tutorial, Part 1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi I'm Ben and this is ansible a beginner's tutorial part 1 during this series I'm going to explain how to use amble to set up a small web platform in the video description you'll find links to the other path as well as a clickable table of content as that let me explain what am google actually don't worry it won't take long aníbal is a configuration management system that means it can be used to set up and configure computer system its main purpose is in server configuration but it can be used for desktop configuration also aníbal itself is maintained by redhead that means commercial support is available if needed however the most important parts are free and open source to let answer will do its magic you have to install it on a control machine that can be your desktop system or a dedicated server on the target server however no configuration is needed you just need to be able to access them by adverse H having said that let's have a look at the environment I'm going to use throughout this area the platform we are going to setup in this tutorial consists of three machines plus the additional control machine that will host the ansible tools and configuration on the right you see the three servers of the platform the web server will be used as reverse proxy forwarding the users request to the app server the app server will host a small Python application that will connect to the database server which in turn will be running a MySQL instance in a real world platform the app and database service wouldn't be directly reachable firewalls here and here would prevent that but those additional components would make the platform more complicated without adding anything in terms of understanding and irvil so I decided to leave them out let's get started as ansible uses ssh s connection method the first thing to make sure is that you can actually log into the servers via SSH to make this more convenient I'm creating an SSH key so I don't have to type password every time I use the command SSH copy ID to copy the key to the server you now I check if I can login to the web server the observer and the DB server using the new key as the login is working fine I can move on to the installation of ansible most modern Linux distributions already provide packages for Angela's Ubuntu 1604 which is what runs on my control machine is no exception so I could just type up get install ansible and be done with it but I do want to install the latest version so a little bit more work needs to be done essentially I have to add a repository to the system and install Anza bill from that repository that I type up at repository PPA and zero and zero I then update the repository cache of the system and I'm finally able to install Angelo you finally I can test if animal has been installed correctly now that Angela's running I can create the basic configuration and folder structure that ansible requires the ansible package that installs such a basic configuration as etc' ansible and you could work directly in that directory but if you want to manage multiple platforms from one control machine it's better to create a copy of that directory and work on the copy instead so I just copy et Cie and go to a local directory named my platform you there are two files in the directory and double-dot CFG contains options for ansible and we need to modify one of them the path to the inventory file instead of an absolute path we specify that the host size next to the end will the CFG file should be used now I have to modify the whole time the default version only includes comments which I will remove because I still have them at the original location instead I write down the names of the servers of my platform and I can reach them using only the short names I'm using those at the platform where he used fkd names or IP addresses I would write those into the file instead now I can run a quick test to see if ansible can reach the machines the command I have just used to let a double check the connection is called an ad-hoc command and health commands aren't the usual way to interact with your servers and that will demonstrate the normal style of working in part two of the series but the ad-hoc commands do come in handy for small tasks and changes to the platform like temporarily adding a user or querying information from the servers let me demonstrate this imagine you want to check the hostname values of every server normally you would have to log in to every machine and run the command hostname by yourself and double has a module called shell that lets you execute any command all you have to type is ansible - m to specify the module - a to pass the command and all to identify on which servers you want to run the module on and the bull will then return a status line for each server along with the output of the command let's do another example this time I want to know the available disk space on the server I'm using the same ansible module but this time I run DF - H when I tell ansible to run the Who am I command you can see that ansible is using my user to execute everything you'll have to keep this in mind when you want to do something on the servers that require through privileges in that case the answer tell ads about to switch to the root user you do this by adding - B to the command and someone will then use sudo to become route by default it will just assume that your user is allowed to run sudo without specifying any password this doesn't work on my platform as my user is required to enter his credentials when using sudo to have and will ask for the sudo password I have to add the - case which for example if I want to add a user to the servers I type and level - D - k then I specify to use the user module and I pass the required parameter the user name as you can see ansible asked me to enter my pseudo password before it connects to the server now let's check if the user has been added to the servers I therefore login to the web server and query the user looks good but hey I know a better way to do this why not use ansible to check for the user you okay the user exists on all three servers this is the end of part 1 of the series let me give you some informations while I have ansible remove the test user from the servers again in part 2 we will create the first ansible role and I will explain the concept of playbooks you will find a link to part 2 in the video description if you like this video please subscribe or give it a thumbs up thanks for watching you
Info
Channel: Ben's IT Lessons
Views: 404,496
Rating: 4.9502773 out of 5
Keywords: ansible, tutorial, configuration management, ssh, server configuration, server
Id: icR-df2Olm8
Channel Id: undefined
Length: 9min 33sec (573 seconds)
Published: Sun Jan 22 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.