Quantcast
Channel: Cloud Training Program
Viewing all articles
Browse latest Browse all 1902

Ansible Tutorial for Beginners Live Training

$
0
0

In this blog post, I am going to share Ansible Tutorial for Beginners Live Training and share some quick tips including Q/A and blog posts on the topics that we covered in a Live Training.

What You’ll Learn Today:

  • Ansible: What Problem It Solves
  • Ansible in DevOps world
  • Infrastructure as Code (IaC) Options
  • Ansible: What & Why?  
  • Where should you use Ansible?
  • Ansible Components: Playbook, Inventory, Modules
  • Ansible Deployment: Control & Managed Nodes
  • Demo: Deploy Web Server on Remote Linux Host
  • What’s Next: 4 Week Roadmap to Learn Ansible
  • Q/A & Quiz

Here you can see Timestamps for the Ansible Tutorial for Beginners Live Training Video:

12:35 – 13:06- Ansible: What & Why?
15:54 – 17:11- What does DevOps mean?
19:26 – 20:45- How is Ansible different from Terraform?
20:54 – 21:44- Do we need to learn any scripting language for Ansible?
34:53 – 36:08- Ansible Playbook, Inventory, and Modules
46:34 – 51:37- Demo
52:54 – 56:12- Learning Path for Ansible
1:04:02 – 1:05:30- Will Ansible cover all features provided by Terraform?

Here are some of the FAQ’s asked during the Ansible Tutorial for Beginners Live Training:

Why Ansible?

  • Ansible allows you to write scripts that describe the state of your system. That means once written these scripts are re-usable and reliable.
  • Ansible scripts are written in YAML. Ansible uses the same tools that are normally used for administration in Linux systems.
  • Ansible gives you the power to manage multi-tier deployments.
  • Ansible can be easily introduced to the existing environment.
  • Ansible is built for the cloud. Modules included in Ansible help manage deployments across AWS, Azure, and other cloud services.

Why Ansible

What Problem It Solves:

NASA needed to move roughly 65 applications from a traditional hardware-based data center to a cloud-based environment for better agility and cost savings. The rapid timeline resulted in many applications being migrated ‘as-is’ to a cloud environment. This created an environment spanning multiple virtual private clouds (VPCs) and AWS accounts that could not be easily managed. Even simple things, like ensuring every system administrator had access to every server, or simple patching, were extremely burdensome.

NASA used the Ansible Tower to manage and schedule the cloud environment. As a result of implementing the Ansible Tower, NASA is better equipped to manage its AWS environment. Tower allowed NASA to provide better operations and security to its clients. It has also increased efficiency as a team. If we see by the numbers:

  • Updating nasa.gov went from over 1 hour to under 5 minutes
  • Patching updates went from a multi-day process to 45 minutes
  • Achieving near real-time RAM and disk monitoring
  • Provisioning OS Accounts across an entire environment in under 10 minutes
  • Application stack set up from 1–2 hours to under 10 minutes.

What is Ansible in DevOps World?

Dev+Ops – Development + Operation

A DevOps is basically a combination of certain automation tools, which help you to speed up the process of delivering software to the client.

The following are the benefits of Ansible in DevOps:

  • The deployments are reliable
  • The IT infrastructure is coordinated
  • The deployments are faster
  • Need for automation
  • Version control and configuration management
  • Orchestration of the IT Infrastructure

DevOps: Software Life Cycle

DevOps_Cycle

DevOps Tools:

DevOps Tools

Infrastructure as Code (IaC)

Infrastructure as Code (IaC) means Idempotency. Meaning, operations called more than once with the same parameters have no additional effect. Some tools that are developed on the IAC approach include Ansible, Terraform, AWS Cloud Formation, ARM templates. Infrastructure as Code IaC can be approached in 2 ways:

  • Declarative
  • Imperative

Also Check: IaC

IaC

IaC Spectrum:

IaC Spectrum:

Q. How Ansible is different from Terraform?

Ans. Chek this: Terraform vs Ansible

Q. Chef vs Puppet vs Ansible vs Salt

Ans. Chef vs Puppet vs Ansible vs Salt

What is Ansible?

Ansible is an open-source IT Configuration Management, Deployment & Orchestration tool. It aims to provide large productivity gains to a wide variety of automation challenges. This tool is very simple to use yet powerful enough to automate complex multi-tier IT application environments.

Advantages of Ansible:

  • Free: Ansible is an open-source tool.
  • Simple: Ansible Playbooks provide human-readable automation. This means that playbooks are automation tools that are also easy for humans to read, comprehend, and change. No special coding skills are required to write to them.
  • Powerful: You can use Ansible to deploy applications, for configuration management, workflow automation, and network automation. Ansible can be used to orchestrate the entire application life cycle.
  • Agentless: Ansible is built around an agentless architecture. Ansible connects to the hosts it manages using OpenSSH or Windows Remote Management and runs tasks by pushing out small programs called Ansible modules to those hosts.

Ansible Features:

Human Readable: Ansible is using the popular YAML format for playbooks and no scripting knowledge is required.

Where should I use Ansible?

You can use Ansible to automate many tasks, these are Six very common tasks:

  • Provisioning: Provisioning is creating new infrastructure. Ansible allows for application management, deployment, orchestration, and configuration management.
  • Continuous Delivery: Ansible provides a simpler way to automatically deploy applications. All required services for a deployment can be configured from a single system. Continuous Integration (CI) tool can be used to run Ansible playbook, which can test and automatically deploy the application to production if tests are passed.
  • Application Deployment: Ansible provides a simpler way to deploy applications across the infrastructure. Deployment of multi-tier applications can be simplified and the infrastructure can be easily changed over time.
  • Configuration management: Centralizing configuration file management and deployment is a common use case for Ansible, and it’s how many power users are first introduced to the Ansible automation platform.
  • Security automation: When you define your security policy in Ansible, scanning, and remediation of site-wide security policy can be integrated into other automated processes and instead of being an afterthought, it’ll be integral in everything that is deployed.
  • Orchestration: Configurations alone don’t define your environment. You need to define how multiple configurations interact and ensure the disparate pieces can be managed as a whole. Out of complexity and chaos, Ansible brings order.

Ansible On Cloud:

Ansible_Cloud

Ansible Architecture an overview

The Ansible architecture is shown below in the diagram.

Architecture

As you can see, in the diagram above, the Ansible automation engine has a direct interaction with the users who write playbooks to execute the Ansible Automation engine. It also interacts with cloud services and Configuration Management Database (CMDB).

  • Modules: Ansible works by connecting to your nodes and pushing out scripts called “Ansible Modules” to them. Most modules accept parameters that describe the desired state of the system. Ansible then executes these modules (over SSH by default) and removes them when finished.
  • Plugins: Plugins augment Ansible’s core functionality. While modules execute on the target system in separate processes, plugins execute on the control node within the /usr/bin/ansible process. Plugins offer options and extensions for the core features of Ansible.
  • Inventory: An inventory file contains a list of the hosts you’ll manage using Ansible. Although Ansible typically creates a default inventory file when installed, you can use per-project inventories to better separate your infrastructure.
  • Playbook: A playbook contains an ordered list of tasks, and a few other directives to indicate which hosts are the target of that automation, Ansible executes tasks sequentially, and a full playbook execution is called a play. Playbooks are written in YAML format.
  • APIs: APIs in Ansible are used as transport for Cloud services, public or private.

Ansible Playbook

  • A collection of tasks (or plays) written in a file
  • YAML format
  • Standard YAML syntax
  • Multiple plays can be included
  • Task-> Plays-> Playbook

Your First Playbook

---
- name: Enable Intranet Services
  hosts: node1.k21academy.com
  become: yes

  tasks:
   - name: Install httpd and firewall
     yum:
      name: |
       - https
       - firewall
      state: latest

Inventory

The Ansible inventory file defines the hosts and groups of hosts upon which commands, modules, and tasks in a playbook operate. The file can be in one of many formats depending on your Ansible environment and plugins. Common formats include INI and YAML. The default location for the inventory file is /etc/ansible/hosts.

Static and Dynamic Host Inventories-

  • Inventories are simply the manage nodes or target devices Ansible needs to manage.
  • Store inventory as static fields or dynamic inventory scripts.
  • The default location can be configured in ansible. cfg or pass while executing the automation playbook.
[myself]
localhost

[webservers]
servera
serverb
serverc

[database]
db1
db2
db3

[servers:children]
database
webservers

[somanyservers]
db[a:f].example.com

[manyips]
192.168.0.[10:20]

Ansible Modules

  • reusable, a standalone script that Ansible runs on your behalf, either locally or remotely.
  • Interact with your local machine, an API, or a remote system to perform specific tasks

Wide Support

Wide Support

Ansible Deployment

  • Control Node: A control node is a system where Ansible is installed and set up to connect to your server. You can have multiple control nodes.
  • Managed Node: The systems you control using Ansible are called managed nodes. Ansible requires that managed nodes are reachable via SSH and have Python 2 (version 2.6 or higher) or Python 3 (version 3.5 or higher) installed.

Ansible Deployment

Ansible Demo

  • Learn Ansible by deploying a simple website using NGINX on Linux.

Check out Deploying a static website with Ansible

There are 7 modules covering 30+ lessons & 9 extensive step-by-step Hands-on labs which are vital to becoming an Automation with Ansible certified.

  • Module 1Introduction to Ansible
  • Module 2: Ansible Inventory & Ad hoc commands
  • Module 3Ansible Playbook, Modules & Privilege Escalation
  • Module 4Ansible Variables
  • Module 5: Conditional Execution & Loops
  • Module 6: Managing files & roles
  • Module 7Advanced Topics & Ansible Tower

Quiz Time!

Check out one of the questions and see if you can crack this…

Ques.1 Which Of the following is not a component of Ansible?

A. Playbook

B. Inventory

C. Cloud

D. Module

Comment your answer in the comment box.

Ques.2 You can manage both Unix & Windows hosts using Ansible.

A. TRUE

B. FALSE

Comment your answer in the comment box.

Related/References

Next Task For You

If you are considering in-depth learning about Ansible in the coming days, then do join our WAITLIST and don’t miss an opportunity to attend a free class and gain a plethora of insights on the Ansible for Beginners Live Training.ansible

The post Ansible Tutorial for Beginners Live Training appeared first on Cloud Training Program.


Viewing all articles
Browse latest Browse all 1902

Trending Articles