Ansible Overview

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14
At a glance
Powered by AI
Ansible is an open source configuration management, deployment, and orchestration tool based on Python.

Ansible is an open source configuration management, deployment, and orchestration tool, based on Python. It’s a simple automation language that can perfectly describe an IT application infrastructure in Ansible Playbooks.

The core components of Ansible are inventories, modules, variables, facts, playbooks and configuration files.

RED HAT ANSIBLE

Agenda

• Red Hat Ansible Overview


WHAT IS ANSIBLE?

INFRASTRUCTURE AS A CODE...
Ansible is an open source configuration management, deployment, and orchestration tool,
based on Python.
It’s a simple automation language that can perfectly describe an IT application
infrastructure in Ansible Playbooks.

It's also an automation engine that runs the Ansible Playbooks.


Designed to be minimal in nature, consistent, secure, and highly reliable, with an
extremely low learning curve for administrators, developers, and IT managers.

 
SIMPLE POWERFUL AGENTLESS

Human readable automation App deployment Agentless architecture


No special coding skills needed Configuration management Uses OpenSSH and WinRM
Tasks executed in order Workflow orchestration No exploits or updates
     
Get productive quickly Orchestrate the App lifecycle More efficient and more secure
CORE COMPONENTS

• Inventories
• Modules
• Variables
• Facts
• Playbooks
• Configuration Files
INVENTORIES
DEFINES WHICH HOSTS ANSIBLE MANAGES

• Static - Defined in simple text files, a host can be member of more than one
group, which is useful to identify the hosts' role in the datacenter.
• Dynamic - Generated for outside providers, some examples include
pulling* inventory from a cloud provider (OpenStack, AWS, etc.), LDAP, Cobbler,
or a piece of expensive enterprise CMDB software.
MODULES
SMALL PROGRAMS THAT COMES (BUILT-IN) WITH ANSIBLE

“Ansible Modules” are written to be resource models of the desired state of the system.
Ansible then executes these modules (over SSH by default), and removes them when
finished. 

The preinstalled library has 500+ modules available that allows us to manage from basic
systems resources to sophisticated ones. For example, to manage users, packages,
network*, files, services, as well provision cloud instances, create databases, and many
more.

Core, extra and custom modules


• Core modules - Written and maintained by Ansible development team, they are the
most important modules and are used for common administration tasks. 
• Extra modules - Generally not maintained by Ansible team but by the community,
typically implementing features for managing newer technologies.
• Custom modules - Developed by end users and not shipped by Ansible.
 
Idempotence - Is an important characteristic of a module, allows executing the same
task multiple times without resulting in the error state.
COMMAND MODULES
RUNNING CUSTOM COMMANDS AND SCRIPTS

Ansible has four modules in to this category and provide us the options to choose from
while running system commands or scripts:
• Raw - Do not require Python on target/managed host
• Command - Most recommended module for executing commands on target nodes
• Shell - Runs the command through the '/ bin/sh ' shell on the target host. It is less
secure than a command module
• Script - copy and execute a script in one step on remote host
VARIABLES
A CONVENIENT WAY TO MANAGE DYNAMIC VALUES FOR A GIVEN ENVIRONMENT

Ansible supports variables that can be used to store values that can be reused
throughout files in an entire Ansible project.
Variables must start with a letter and can only contain letters, numbers, and underscores.
• Global scope: Variables set from the command line or Ansible configuration
• Play scope: Variables set in the play and related structures
• Host scope: Variables set on host groups and individual hosts by the inventory, fact
gathering, or registered tasks

Note: Must start with a letter and can only contain letters, numbers, and underscores.

Example: Defining variables in playbooks


FACTS
KNOW THE FACTS ABOUT YOUR HOSTS

Ansible facts are variables that are automatically discovered by Ansible from a managed
host.

Facts are pulled by the setup module and contain useful information stored into
variables that administrators can reuse.

Fact variables can be used as part of playbooks, in conditionals, loops, or any other
dynamic statement that depends on a value for a managed host.

Display facts from all hosts and store them indexed by I(hostname) at C(/tmp/facts):

ansible all -m setup --tree /tmp/facts


YAML
THE PLAYBOOK LANGUAGE

YAML format - a simple, human-readable, and familiar way to blueprint the infrastructure
Users of this tool need not learn any special programming language to get started with,
Ansible code is self-explanatory and self-documenting in nature.

Playbooks are expressed in YAML format and have a minimum of syntax, which


intentionally tries to not be a programming language or script, but rather a model of a
configuration or a process.
PLAYBOOKS
A SIMPLE+POWERFUL AUTOMATION LANGUAGE

A playbook consists of one or more plays, which map groups of hosts to well-defined


tasks.

Plays also define the order in which tasks are configured. This allows us to orchestrate
multitier deployments.

By composing a playbook of multiple ‘plays’, it is possible to orchestrate multi-


machine deployments, running certain steps on all machines in the webservers group,
then certain steps on the database server group, then more commands back on the
webservers group, etc.

As an orchestrate example, it is possible to create a playbook  to configure the load


balancers only after starting the web servers, or perform two-phase deployment where
the first phase only adds this configurations and the second phase starts the services in
the desired order.

Roles - While it is possible to write a playbook in one very large file (and you might start
out learning playbooks this way), eventually you’ll want to reuse files and start to
organize things.
the apache config file template:   src: /srv/httpd.j2   dest: /etc/httpd.conf notify: - restart apache - name: ensure apache is runni

PLAYBOOKS
ANSIBLE VAULT
PROTECTING SENSITIVE DATA IN YOUR PLAYBOOKS

Sensible data like passwords and API keys can be encrypted and decrypted using Ansible
Vault.

To create a new encrypted data file, run the following command:

$ ansible-vault create foo.yml


similarly we can use edit, encrypt, decrypt, view and other options to work with vault
files, see more on:
$ man ansible-vault

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy