SS17838 Ansible Overview
SS17838 Ansible Overview
SS17838 Ansible Overview
Configuration Management
Specifically about :
Existence
Primary Group that he belongs to
His Home Directory
Ansible Way
Supports Red Hat, CentOS, Ubuntu, MAC, Solaris …Support for Windows is
limited
Ansible Inc. that commercially supported Ansible was acquired by Red Hat
Ansible is scalable and can easily handle few to 100’s of nodes from a single
system over SSH connection
Managed Node
Network Devices (and/or servers) managed by Ansible
Controller/master configures these agents/nodes
Sometimes referred to as “hosts”
Ansible is not installed on managed nodes
Modules
Units of code that ansible executes
Each Module has a particular use
There are almost 450 Ansible provided modules that can automate nearly every
part of the environment
Standard Structure
Module : directive1=value directive2=value
For e.g.
Administers specific type of database
Manage VLAN interface on specific device
14 Copyright © 2013 Tech Mahindra. All rights reserved.
Ansible Terminologies
Tasks
You can execute a single task once with an ad-hoc command
Simple small tasks that can be executed without logging in to client
for e.g.: GetAlive status of server
Playbooks
Ordered list of tasks for repeated execution
Can include variables as well as tasks
Written in YAML
Variables
Allow you to alter how commands, etc. run
Can be used in many different ways
• Playbooks
• Files
• Inventories (group_vars, host_vars)
• Command Line
• Discovered Variables (facts)
• Ansible Tower
15 Copyright © 2013 Tech Mahindra. All rights reserved.
Ansible Architecture
The Ansible Automation
engine consists of:
1. Inventories
2. API’s
3. Modules
4. Plugin
[webservers]
www1.example.com
www2.example.com
[dbservers]
Db0.example.ccom
Db1.example.com
After hosts are listed, variables can be assigned to them in simple text
files (in sub directory called group_vars or host_vars
- hosts: content_servers
roles:
- common
- content
• It communicates over
SSH channels to retrieve
information from remote machines,
issue commands, and copy files etc
Ansible’s Playbook syntax allows to define secure any part of our system,
Like
• setting firewall rules,
• locking down users and groups,
• applying custom security policies
Installation
Managed Nodes
Python 2.6 or above or Python 3.5 or above needs to be installed
Communication using ssh
On RHEL or CentOS
$ sudo yum install ansible
Network Automation
Network Devices cannot work with python while Ansible is designed using
python
In case of persistent connection, host and credentials are defined only once
Ansible provides support for privilege escalation for network devices that
support it
Refer to http://docs.ansible.com/ansible/playbooks_special_topics.html
Ansible Playbooks
---
## PLAYBOOK TO INSTALL AND CONFIGURE APACHE HTTP ON
CENTOS
- host: all
tasks:
- name: Install Apache httpd
yum: pkg=httpd state=installed
Ansible Documentation
http://docs.ansible.com/