Introduction to Ansible
Krishantha Dinesh Msc, MIEEE, MBCS
Software Architect
www.krishantha.com
www.youtube.com/krish
@krishantha
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Configuration management
• Manage software on top of hardware
• Maintain consistency based on functionality and design
• It is systems engineering process for establishing and maintaining consistency of a product's performance
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Why Configuration Management
• Make consistency
• Maintain integrity
• No need separate log in / execution on each server
• Centralize control / management
• Scaling made easy
• No time to deploy or configure after successful build
• Rolling back is easy
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
What is ansible
• Ansible is an open-source software provisioning, configuration management, and application-deployment tool.
• It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows.
• Its pushed based configuration management tool
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Why ansible
• Free. Ansible is an open-source tool.
• Very simple to set up and use. No special coding skills are necessary to use Ansible’s playbooks
• Powerful. Ansible lets you model even highly complex IT workflows.
• Flexible. You can orchestrate the entire application environment no matter where it’s deployed. You can also customize
it based on your needs.
• Agentless. You don’t need to install any other software or firewall ports on the client systems you want to automate.
You also don’t have to set up a separate management structure.
• Efficient. Because you don’t need to install any extra software, there’s more room for application resources on your
server.
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Ansible Architecture
• Modules
• Modules are like small programs that Ansible pushes out from a control machine to all the nodes / remote hosts.
• The modules are executed using playbooks.
• They control things such as services, packages and files. Ansible executes all the modules for installing updates or
whatever the required task is, and then removes them when finished.
• Ansible provides 400+ modules for common tasks
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
• Plugins
• As many other tools and platforms, plugins are extra pieces of code that augment functionality.
• Ansible comes with a number of its own plugins.
• we can write your own as well.
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
• Inventory
• All the machines you’re using with Ansible (the control machine plus nodes) are listed in a single simple file, with
their IP addresses, names etc.
• Once you list the inventory, you can assign variables to any of the hosts using a simple text file.
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
• Playbook
• Ansible playbooks are like instruction manuals for tasks.
• They are simple files written in YAML. (human-readable data serialization language).
• Playbooks are really at the heart of what makes Ansible so popular because they describe the tasks to be done
easily and without the need for the user to know or remember any special syntax. Not only can they declare
configurations, but they can orchestrate the steps of any manually ordered task, and can execute tasks at the
same time or at different times.
• Each playbook is composed of one or multiple plays, and the goal of a play is to map a group of hosts to well-
defined roles, represented by tasks.
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Ansible Tower
• Ansible Tower is Red Hat’s commercial web-based solution for managing Ansible.
• Its best-known feature is an easy-to-use UI for managing configurations and deployments,
• Ansible Tower contains the most important features of Ansible, especially those that are easier to see in a graphical
format rather than a text-based format.
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Practical example
Ansible
installed
EC2
Manager
EC2 node1
10.0.81.10
EC2 node2
10.0.81.11
EC2 node1
10.0.81.12
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Generate ssh key at Manager EC2
ssh-keygen
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Copy public key to remote (to node 1-2-3)
• cat ~/.ssh/id_rsa.pub |ssh -i kkey.pem ec2-user@10.0.81.10 "cat - >>
~/.ssh/authorized_keys”
• Repeat above step to all 3 nodes
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Install ansible on Manager
OR
OR in ubuntu
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Every steps here onward to be execute on Manager (ansible installed instance)
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Basic config
• Ansible by default install basic configs at /etc/ansible
• Good practice is copy that and work on copy
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Configure hostfile
• Since we have taken a copy we need to configure which host file to be used
• Update ansible.cfg as follows
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Update hosts
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Verify [ad-hoc command]
• Now we can verify that ansible can use all hosts or not
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Some more ad-hoc command
• Add-hoc commands are the command can use directly on terminal without configure
• -m à shell module
• -a à argument
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Failed – need sudo access
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
-b sudo access –K ask sudu password
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Verify user
With ansible
Without ansible
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Roles
• Ansible will execute roles on target machines
• Palybook can determine which role to which target machine
• Role is directory under roles and need other directory call task and inside main.yml
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Install a package
• nmap is not installed
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Create main.yml
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Create playbook
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
EXECUTE
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
verify
nmap installed
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Configure additional packages
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Additional packages
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Variable substitution
• Ansible can replace values with variable.
• Lets see how we can use one install option and provide packages
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Copy files
• Create sample file at /home/ec2-user/data.txt
vim roles/setup/tasks/main.yml
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
Execute and verify

More Related Content

PPTX
Introduction to apache maven
PPTX
Java Fundamentals to Advance
PDF
Introduction to jenkins
PDF
Introduction to docker
PPTX
Introduction to-ict
PDF
Professional WordPress Development with Vagrant - Andrea Cardinali - WordCam...
PDF
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
PPTX
Anthony Somerset - Site Speed = Success!
Introduction to apache maven
Java Fundamentals to Advance
Introduction to jenkins
Introduction to docker
Introduction to-ict
Professional WordPress Development with Vagrant - Andrea Cardinali - WordCam...
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Anthony Somerset - Site Speed = Success!

What's hot (20)

PPTX
Varying wordpressdevelopmentenvironment wp-campus2016
PDF
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
PPTX
Short-Training asp.net vNext
PDF
Mini-Training: Redis
PDF
Automated Infrastructure and Application Management
PPTX
Varying WordPress Development Environment WordCamp Columbus 2016
PDF
Introducing WordPress Multitenancy (Wordcamp Vegas/Orlando 2015/WPCampus)
PDF
ColdFusion builder plugins
PDF
Ako na vlastne WP temy
PPTX
Untangling fall2017 week1
PPTX
Varying WordPress Development Environment WordCamp Cincinnati 2016
PDF
Instant ColdFusion with Vagrant
PPTX
Docker With Asp.net Core
PDF
Lean Drupal Repositories with Composer and Drush
PDF
Building a community of Open Source intranet users
PPTX
PHP Indonesia - Nodejs Web Development
PDF
Afrimadoni the power of docker
PDF
How to make your Webpack builds 10x faster
PDF
Dev objective2015 lets git together
PDF
Instant ColdFusion with Vagrant
Varying wordpressdevelopmentenvironment wp-campus2016
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
Short-Training asp.net vNext
Mini-Training: Redis
Automated Infrastructure and Application Management
Varying WordPress Development Environment WordCamp Columbus 2016
Introducing WordPress Multitenancy (Wordcamp Vegas/Orlando 2015/WPCampus)
ColdFusion builder plugins
Ako na vlastne WP temy
Untangling fall2017 week1
Varying WordPress Development Environment WordCamp Cincinnati 2016
Instant ColdFusion with Vagrant
Docker With Asp.net Core
Lean Drupal Repositories with Composer and Drush
Building a community of Open Source intranet users
PHP Indonesia - Nodejs Web Development
Afrimadoni the power of docker
How to make your Webpack builds 10x faster
Dev objective2015 lets git together
Instant ColdFusion with Vagrant
Ad

Similar to Introduction to ansible (20)

PDF
Ansible automation sa technical deck q2 fy19
PPTX
Ansible as configuration management tool for devops
PPTX
Intro to-ansible-sep7-meetup
PDF
ansible_rhel.pdf
PDF
Automation Integration Ansible
ODP
Introduction to Ansible
PDF
Introduction to Ansible in RHEL- RHCE.pdf
PPTX
SESSION Ansible how to deploy and push resources
PPTX
Ansible: Automation Tool
PPTX
Hands on ansible
PPTX
Ansible: What, Why & How
PDF
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
PPTX
Introduction to Ansible
PPTX
Ansible
PPTX
Ansible_Presentation.pptx in devops 6th sem lab
PDF
Ansible Automation to Rule Them All
PDF
ansible_rhel_90.pdf
PDF
Ansible.pdf
PDF
El Paso Tech Day Sept 19 2018 - Net Automation with Ansible
PPTX
Automating with Ansible
Ansible automation sa technical deck q2 fy19
Ansible as configuration management tool for devops
Intro to-ansible-sep7-meetup
ansible_rhel.pdf
Automation Integration Ansible
Introduction to Ansible
Introduction to Ansible in RHEL- RHCE.pdf
SESSION Ansible how to deploy and push resources
Ansible: Automation Tool
Hands on ansible
Ansible: What, Why & How
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Introduction to Ansible
Ansible
Ansible_Presentation.pptx in devops 6th sem lab
Ansible Automation to Rule Them All
ansible_rhel_90.pdf
Ansible.pdf
El Paso Tech Day Sept 19 2018 - Net Automation with Ansible
Automating with Ansible
Ad

Recently uploaded (20)

PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PPTX
Tech Workshop Escape Room Tech Workshop
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
Microsoft Office 365 Crack Download Free
PDF
AI Guide for Business Growth - Arna Softech
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PPTX
Trending Python Topics for Data Visualization in 2025
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
"Secure File Sharing Solutions on AWS".pptx
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
iTop VPN Crack Latest Version Full Key 2025
PPTX
CNN LeNet5 Architecture: Neural Networks
PDF
Cost to Outsource Software Development in 2025
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
Tech Workshop Escape Room Tech Workshop
Monitoring Stack: Grafana, Loki & Promtail
Patient Appointment Booking in Odoo with online payment
Microsoft Office 365 Crack Download Free
AI Guide for Business Growth - Arna Softech
Oracle Fusion HCM Cloud Demo for Beginners
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
Trending Python Topics for Data Visualization in 2025
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
Why Generative AI is the Future of Content, Code & Creativity?
"Secure File Sharing Solutions on AWS".pptx
Designing Intelligence for the Shop Floor.pdf
Computer Software and OS of computer science of grade 11.pptx
iTop VPN Crack Latest Version Full Key 2025
CNN LeNet5 Architecture: Neural Networks
Cost to Outsource Software Development in 2025

Introduction to ansible

  • 1. Introduction to Ansible Krishantha Dinesh Msc, MIEEE, MBCS Software Architect www.krishantha.com www.youtube.com/krish @krishantha
  • 2. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Configuration management • Manage software on top of hardware • Maintain consistency based on functionality and design • It is systems engineering process for establishing and maintaining consistency of a product's performance
  • 3. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Why Configuration Management • Make consistency • Maintain integrity • No need separate log in / execution on each server • Centralize control / management • Scaling made easy • No time to deploy or configure after successful build • Rolling back is easy
  • 4. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ What is ansible • Ansible is an open-source software provisioning, configuration management, and application-deployment tool. • It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows. • Its pushed based configuration management tool
  • 5. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Why ansible • Free. Ansible is an open-source tool. • Very simple to set up and use. No special coding skills are necessary to use Ansible’s playbooks • Powerful. Ansible lets you model even highly complex IT workflows. • Flexible. You can orchestrate the entire application environment no matter where it’s deployed. You can also customize it based on your needs. • Agentless. You don’t need to install any other software or firewall ports on the client systems you want to automate. You also don’t have to set up a separate management structure. • Efficient. Because you don’t need to install any extra software, there’s more room for application resources on your server.
  • 6. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Ansible Architecture • Modules • Modules are like small programs that Ansible pushes out from a control machine to all the nodes / remote hosts. • The modules are executed using playbooks. • They control things such as services, packages and files. Ansible executes all the modules for installing updates or whatever the required task is, and then removes them when finished. • Ansible provides 400+ modules for common tasks
  • 7. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ • Plugins • As many other tools and platforms, plugins are extra pieces of code that augment functionality. • Ansible comes with a number of its own plugins. • we can write your own as well.
  • 8. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ • Inventory • All the machines you’re using with Ansible (the control machine plus nodes) are listed in a single simple file, with their IP addresses, names etc. • Once you list the inventory, you can assign variables to any of the hosts using a simple text file.
  • 9. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ • Playbook • Ansible playbooks are like instruction manuals for tasks. • They are simple files written in YAML. (human-readable data serialization language). • Playbooks are really at the heart of what makes Ansible so popular because they describe the tasks to be done easily and without the need for the user to know or remember any special syntax. Not only can they declare configurations, but they can orchestrate the steps of any manually ordered task, and can execute tasks at the same time or at different times. • Each playbook is composed of one or multiple plays, and the goal of a play is to map a group of hosts to well- defined roles, represented by tasks.
  • 10. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Ansible Tower • Ansible Tower is Red Hat’s commercial web-based solution for managing Ansible. • Its best-known feature is an easy-to-use UI for managing configurations and deployments, • Ansible Tower contains the most important features of Ansible, especially those that are easier to see in a graphical format rather than a text-based format.
  • 11. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Practical example Ansible installed EC2 Manager EC2 node1 10.0.81.10 EC2 node2 10.0.81.11 EC2 node1 10.0.81.12
  • 12. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Generate ssh key at Manager EC2 ssh-keygen
  • 13. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Copy public key to remote (to node 1-2-3) • cat ~/.ssh/id_rsa.pub |ssh -i kkey.pem ec2-user@10.0.81.10 "cat - >> ~/.ssh/authorized_keys” • Repeat above step to all 3 nodes
  • 14. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Install ansible on Manager OR OR in ubuntu
  • 15. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Every steps here onward to be execute on Manager (ansible installed instance)
  • 16. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Basic config • Ansible by default install basic configs at /etc/ansible • Good practice is copy that and work on copy
  • 17. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Configure hostfile • Since we have taken a copy we need to configure which host file to be used • Update ansible.cfg as follows
  • 18. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Update hosts
  • 19. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Verify [ad-hoc command] • Now we can verify that ansible can use all hosts or not
  • 20. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Some more ad-hoc command • Add-hoc commands are the command can use directly on terminal without configure • -m à shell module • -a à argument
  • 21. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
  • 22. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Failed – need sudo access
  • 23. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ -b sudo access –K ask sudu password
  • 24. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Verify user With ansible Without ansible
  • 25. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Roles • Ansible will execute roles on target machines • Palybook can determine which role to which target machine • Role is directory under roles and need other directory call task and inside main.yml
  • 26. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Install a package • nmap is not installed
  • 27. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Create main.yml
  • 28. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Create playbook
  • 29. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ EXECUTE
  • 30. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ verify nmap installed
  • 31. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Configure additional packages
  • 32. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Additional packages
  • 33. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Variable substitution • Ansible can replace values with variable. • Lets see how we can use one install option and provide packages
  • 34. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/
  • 35. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Copy files • Create sample file at /home/ec2-user/data.txt vim roles/setup/tasks/main.yml
  • 36. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Execute and verify