SlideShare a Scribd company logo
Writing your First Ansible Playbook
By Sana Khan
About me
➔ Infrastructure Engineer/ SysAdmin
➔ Former Software Developer
➔ GNOME Outreach Intern (2016) - OpenStack
➔ RGSoC Intern (2014)
Agenda
➔ Challenges in managing server configurations before Configuration Management
tools.
➔ Benefits of Configuration Management tool.
➔ Where does Ansible fit in the suite of IaaC tools?
➔ What are the features of IaaC tools?
➔ Why learn Ansible?
➔ Understanding an Ansible Setup.
➔ Basics concepts of Ansible.
➔ Writing your own Playbook.
➔ Security Best Practices.
Before Configuration Management Tools
Setup a Webserver (nginx) & an application stack (php)
➔ Step-1: Login to the server
➔ Step-2: Install the nginx package
➔ Step-3: Configure nginx configuration
➔ Step-4: Ensure required users, groups are present
➔ Step-5: Ensure correct permissions, user roles are assigned to conf files.
➔ Step-6: Install php packages
➔ Step-7: Configure the application
➔ Step-8: Configure web server to redirect to application
Before Configuration Management Tools -2
➔ Doable
➔ Couple of servers
➔ The only form of automation
available: Bash Scripts
➔ Inconsistent environments
Problem: Large groups of servers that need to be managed in a flexible way.
Configuration Management Tools - Today
Goal: Install, manage software and configuration at scale with ease.
➔ Helps automate Infrastructure
➔ Centralized management
➔ Helps manage Infrastructure at large scale
➔ Consistent environments
Where does Ansible fit in suite of IaaC Tools?
What are the features of IaaC Tools?
➔ Declarative Syntax
(describes the state of the infrastructure)
➔ Code form
(revision control)
➔ Idempotence
( current state == desired state )? -> take actions accordingly.
Why Ansible?
➔ Learning curve is less, easy to pick it up.
➔ Agentless, only requires Python to be installed on the managed
servers.
➔ Modules are written in Python, easily accessible.
➔ Modules that integrate with Cloud Providers like AWS, OpenStack.
➔ Modules for Docker, Ovirt, etc.
➔ Modules for network devices, windows, etc.
Ansible Setup
Prerequisites:
➔ Python needs to
be installed
➔ Sudo user
➔ SSH access
Ansible Concepts
➔ Inventory file
➔ Syntax of a YAML file
➔ Tasks
➔ Modules
➔ Ad-Hoc Commands
➔ Playbooks
➔ Roles (Ready to use playbooks - Ansible Galaxy)
YAML Basics
➔ All YAML files begin with ---
➔ At basic level YAML file consists of lists and dictionaries.
➔ YAML file starts with a list.
YAML Basics -- contd
Source: YAML Syntax
Demo
➔ Ansible | jonatanblue
➔ https://github.com/sanakhanlibre/Ansible101
Security Best Practices
➔ Control Node needs to be secure/hardened.
➔ Don’t use passwords, use Key based Authentication.
➔ Use Ansible Vault for secrets.
➔ Don’t expose sensitive data in Ansible Output.
➔ Verify before using Roles from Ansible Galaxy.
Thank You.

More Related Content

PDF
Ansible Introduction
PDF
Spinnaker - Bay Area AWS Meetup - 20160726
PPTX
Introduction to Ansible - Jan 28 - Austin MeetUp
PPTX
Owin and Katana
PPTX
AWS CodeDeploy - basic intro
PDF
Continuous delivery in AWS
PPTX
Ansible day 1.ppt
PDF
03 ansible towerbestpractices-nicholas
Ansible Introduction
Spinnaker - Bay Area AWS Meetup - 20160726
Introduction to Ansible - Jan 28 - Austin MeetUp
Owin and Katana
AWS CodeDeploy - basic intro
Continuous delivery in AWS
Ansible day 1.ppt
03 ansible towerbestpractices-nicholas

What's hot (18)

PPTX
Extending ansible
PPTX
Infrastructure as Code
PDF
Using hapi plugins to version your API (hapiDays 2014)
PPTX
End to End Testing with nightwatchjs
PDF
High Available Drupal
PPTX
Why I am hooked on the future of React
PPTX
An Introduction to hapi.js
PPTX
Cypress Automation
PPTX
How to Hack (And Secure) Serverless Apps on Azure
PPTX
SQL Start! 2019 - Ancona - Distribuisci ed amministra le tue istanze SQL Serv...
PDF
PDF
Women Who Code Connect 2018 Conference
PDF
Protecting your site by detection
PPTX
Building an API in Node with HapiJS
PPTX
ASP.NET Core
PDF
Serverless architecture: introduction & first steps
PDF
Ansible @ Red Hat | December 2015 Ansible Meetup in Melbourne
PPTX
“ASP.NET Core. Features and architecture”
Extending ansible
Infrastructure as Code
Using hapi plugins to version your API (hapiDays 2014)
End to End Testing with nightwatchjs
High Available Drupal
Why I am hooked on the future of React
An Introduction to hapi.js
Cypress Automation
How to Hack (And Secure) Serverless Apps on Azure
SQL Start! 2019 - Ancona - Distribuisci ed amministra le tue istanze SQL Serv...
Women Who Code Connect 2018 Conference
Protecting your site by detection
Building an API in Node with HapiJS
ASP.NET Core
Serverless architecture: introduction & first steps
Ansible @ Red Hat | December 2015 Ansible Meetup in Melbourne
“ASP.NET Core. Features and architecture”
Ad

Similar to Writing your First Ansible Playbook (20)

PDF
Ansible - Hands on Training
PDF
Ansible Tutorial.pdf
PPTX
Introduction to ansible
PPTX
MongoDB Ops Manager and Kubernetes - James Broadhead
PDF
Velocity NYC 2016 - Containers @ Netflix
PDF
Infrastructure as Code
PDF
Ransack, an Application Built on Ansible's API for Rackspace -- AnsibleFest N...
PDF
Devops with Python by Yaniv Cohen DevopShift
PDF
Creating pools of Virtual Machines - ApacheCon NA 2013
PDF
Deployment automation
PDF
ansible_rhel.pdf
PDF
Apache Provisionr (incubating) - Bucharest JUG 10
PDF
Backroll: Production Grade KVM Backup Solution Integrated in CloudStack
PPTX
Ranger admin dev overview
PDF
Extending Build to the Client: A Maven User's Guide to Grunt.js
PDF
Omaha (Google Update) server
PDF
apidays LIVE Paris 2021 - Edge Side APIs by Kevin Dunglas, Les Tilleuls
PDF
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
PDF
La sécurité avec Kubernetes et les conteneurs Docker (June 19th, 2019)
PDF
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible - Hands on Training
Ansible Tutorial.pdf
Introduction to ansible
MongoDB Ops Manager and Kubernetes - James Broadhead
Velocity NYC 2016 - Containers @ Netflix
Infrastructure as Code
Ransack, an Application Built on Ansible's API for Rackspace -- AnsibleFest N...
Devops with Python by Yaniv Cohen DevopShift
Creating pools of Virtual Machines - ApacheCon NA 2013
Deployment automation
ansible_rhel.pdf
Apache Provisionr (incubating) - Bucharest JUG 10
Backroll: Production Grade KVM Backup Solution Integrated in CloudStack
Ranger admin dev overview
Extending Build to the Client: A Maven User's Guide to Grunt.js
Omaha (Google Update) server
apidays LIVE Paris 2021 - Edge Side APIs by Kevin Dunglas, Les Tilleuls
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
La sécurité avec Kubernetes et les conteneurs Docker (June 19th, 2019)
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ad

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Encapsulation theory and applications.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Cloud computing and distributed systems.
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
cuic standard and advanced reporting.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
The AUB Centre for AI in Media Proposal.docx
Encapsulation theory and applications.pdf
Empathic Computing: Creating Shared Understanding
Chapter 3 Spatial Domain Image Processing.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
MIND Revenue Release Quarter 2 2025 Press Release
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Cloud computing and distributed systems.
sap open course for s4hana steps from ECC to s4
Spectral efficient network and resource selection model in 5G networks
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
cuic standard and advanced reporting.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Understanding_Digital_Forensics_Presentation.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?

Writing your First Ansible Playbook

  • 1. Writing your First Ansible Playbook By Sana Khan
  • 2. About me ➔ Infrastructure Engineer/ SysAdmin ➔ Former Software Developer ➔ GNOME Outreach Intern (2016) - OpenStack ➔ RGSoC Intern (2014)
  • 3. Agenda ➔ Challenges in managing server configurations before Configuration Management tools. ➔ Benefits of Configuration Management tool. ➔ Where does Ansible fit in the suite of IaaC tools? ➔ What are the features of IaaC tools? ➔ Why learn Ansible? ➔ Understanding an Ansible Setup. ➔ Basics concepts of Ansible. ➔ Writing your own Playbook. ➔ Security Best Practices.
  • 4. Before Configuration Management Tools Setup a Webserver (nginx) & an application stack (php) ➔ Step-1: Login to the server ➔ Step-2: Install the nginx package ➔ Step-3: Configure nginx configuration ➔ Step-4: Ensure required users, groups are present ➔ Step-5: Ensure correct permissions, user roles are assigned to conf files. ➔ Step-6: Install php packages ➔ Step-7: Configure the application ➔ Step-8: Configure web server to redirect to application
  • 5. Before Configuration Management Tools -2 ➔ Doable ➔ Couple of servers ➔ The only form of automation available: Bash Scripts ➔ Inconsistent environments Problem: Large groups of servers that need to be managed in a flexible way.
  • 6. Configuration Management Tools - Today Goal: Install, manage software and configuration at scale with ease. ➔ Helps automate Infrastructure ➔ Centralized management ➔ Helps manage Infrastructure at large scale ➔ Consistent environments
  • 7. Where does Ansible fit in suite of IaaC Tools?
  • 8. What are the features of IaaC Tools? ➔ Declarative Syntax (describes the state of the infrastructure) ➔ Code form (revision control) ➔ Idempotence ( current state == desired state )? -> take actions accordingly.
  • 9. Why Ansible? ➔ Learning curve is less, easy to pick it up. ➔ Agentless, only requires Python to be installed on the managed servers. ➔ Modules are written in Python, easily accessible. ➔ Modules that integrate with Cloud Providers like AWS, OpenStack. ➔ Modules for Docker, Ovirt, etc. ➔ Modules for network devices, windows, etc.
  • 10. Ansible Setup Prerequisites: ➔ Python needs to be installed ➔ Sudo user ➔ SSH access
  • 11. Ansible Concepts ➔ Inventory file ➔ Syntax of a YAML file ➔ Tasks ➔ Modules ➔ Ad-Hoc Commands ➔ Playbooks ➔ Roles (Ready to use playbooks - Ansible Galaxy)
  • 12. YAML Basics ➔ All YAML files begin with --- ➔ At basic level YAML file consists of lists and dictionaries. ➔ YAML file starts with a list.
  • 13. YAML Basics -- contd Source: YAML Syntax
  • 14. Demo ➔ Ansible | jonatanblue ➔ https://github.com/sanakhanlibre/Ansible101
  • 15. Security Best Practices ➔ Control Node needs to be secure/hardened. ➔ Don’t use passwords, use Key based Authentication. ➔ Use Ansible Vault for secrets. ➔ Don’t expose sensitive data in Ansible Output. ➔ Verify before using Roles from Ansible Galaxy.