Introduction to Ansible

TetraNoodle Team
A free video tutorial from TetraNoodle Team
REAL KNOWLEDGE. REAL EXPERIENCE. REAL VALUE.
4.1 instructor rating • 72 courses • 156,080 students

Learn more from the full course

DevOps: Automate your infrastructure using Ansible and IaC

Use Ansible tasks, modules and playbooks. Deploy, configure and manage your infrastructure w/ Infrastructure as code IaC

05:15:48 of on-demand video • Updated February 2019

  • You will get introduced to Infrastructure-As-Code (IaC) and learn what it is all about.
  • Learn why automating your infrastructure is important (especially in fast paced agile environment)
  • You will learn how to deploy and configure your infrastructure automatically with Ansible and its various modules
  • You will get familiar with Ansible playbooks and its various sections
  • You will learn how to author, use and distribute new Ansible roles
  • You will learn how to automate the deployment and management of your AWS cloud resources
English [Auto] These all the takeaways you can expect from this module develop an understanding about ansible understand. Watson ansible playbook is discuss what a YAML file is and what's Python less dictionaries and other complex data structures are within YAML which is used by ansible. You will also learn how to validate YAML learn how to install and configure uncivil and understand what ansible inventively is. It is exciting to get introduced to ansible. So let's get started. So let's begin our discussion by understanding what ansible is and Sipple is an I.T. automation configuration management and provisioning too which can be used to deploy applications manage systems and write infrastructures code infrastructure his code is the term used to describe managing infrastructure using code base and is one search tool by which we can manage the infrastructure through code which can be versions and re-used ansible is similar to puppets Sheth and various other configuration management tools. But the main difference is ansible is agent this as compared to puppets Sheth. So we don't need any kind of ansible agent running on the target node. We can just prepare the master node and can use ansible to make the configuration changes or to install our software. We can also use it for provisioning our infrastructure and Sipple uses playbooks which consist of tasks unrolls tasks are just a series of steps which we can write to define what needs to happen in the system unrolls are more of a generic entity we can create roles. It is a Magdi latest version of what the task is. Once we have written a role we can apply it to as many systems as we want. The role will get applied to that particular system as per our requirement. The example for rolls or apache server or my Escudo DBI server. So once we have written a roll we can apply that role to the server and the respective roles will get installed and Seppala is mainly written in Python. Most of its modules are also written in Python. And if we want to write our own modules then the preferred language is also Python ansible as agent class. So we don't need to have any kind of service running on the agent node to receive an ansible command and provision it. Now to understand what an ansible playbook is. Let's take a look. It's an example. So what this particular ansible playbook does is it installs WordPress with Majeski well and Gen-X and Ph. P PM Let's review this playbook. Line by line here. The first line defines the name of the playbook and the second line defines the targeted host. In this case we want to install WordPress on the host server called WordPress server while the third line states the remote user who should be logged in to the remote service the remote user is just the name of the user accounts. And then we have roles. It is a list of all the roles which we want to apply to our WordPress server. And if we look at the playbook carefully the first three lines denote that it is a list and inside each list we have individual components. So this particular playbook is one individual component. If we once we can add another playbook here ansible playbooks are generally written in a mockup format called Jamo. It stands for yet another markup language and it is similar to Jason. The file starts with triple hyphens. This is a requirement for YAML to interpret the file as a proper document. YAML allows multiple documents to exist in one file each separated by triple hyphens. But ansible only wants one document per file. So this should only be present at the top of the file. YAML is very sensitive to whitespace and uses that to group different pieces of information together. You should use only spaces or not tabs and you misuse consistent spacing for your files to be read correctly. Items at the same level of indentation are considered sibling elements items that begin with a dash or considered list items items that have the format of key value operators hashes or dictionaries. That's pretty much all there is to basic YAML YAML documents basically define a hierarchical tree structure with the containing elements further to the left. So when we work with ansible playbooks we are going to work a lot with the list. This is the Jamo format. This is basically the data structure and how it is represented in YAML when we write a line with a hyphen as a prefix dash. It means that it has a list and when we write a link with a colon in the key equals value formats then it represents a YAML dictionary when ansible we will be using the list of the list list of dictionary dictionary of the list. And all these kinds of data structures. So what is a list the list is nothing but a series of values stored in the variable and a dictionary is similar to the list but except that it has a key and a value. For example here the key is the remote user and the value is route. Another example is the key is host and the value is WordPress server. So it is very important to understand the list and dictionaries as the core data structures in the YAML files as this is the YAML file. Yet another markup language we need to understand is to write ansible playbooks. If you are familiar with Jason then there is an option to write these playbooks and Jason as well. Also there are a lot of tools which can convert from Jason to YAML and vice versa but YAML is more efficient and is favored by ansible engineers.