SlideShare a Scribd company logo
- 1 -
Infrastructure
as-a-Code
How can DevOps automation help you
boosting your startup
By : Ahmed Mekkawy
- 2 -
The presenter
● Ahmed Mekkawy AKA linuxawy.
● CEO | Founder of Spirula Systems.
● Co-founder of OpenEgypt.
● Free Software Foundation (FSF) member.
● Independent consultant at MCIT.
● Advisory board member at Mushtarak.
● One of the authors of the Egyptian government's FOSS 
adoption strategy.
Intro
BG
Ansible
Docker
- 3 -
Who is this for ?
● Entrepreneur with a technical background, to take wise 
decision.
● Developers, to get closer to operations and DevOps.
● SysAdmins/SysOps, to get closer to developers and 
DevOps.
● Entry level DevOps.
Intro
BG
Ansible
Docker
- 4 -
prerequisites
● A background of development or system administration.
● Linux systems awareness.
● Familiarity with Linux command line.
Intro
BG
Ansible
Docker
- 5 -
Infrastructure as a code
● Definition
● Unlocked potentials :
● Dynamic infrastructure
● Minimizing cycle
● Environment versioning – through source control
● Testing your code/environment
Intro
BG
Ansible
Docker
- 6 -
Devops ?
● DevOps (a clipped compound of "development" and 
"operations") is a culture, movement or practice that 
emphasizes the collaboration and communication of both 
software developers and other information-technology (IT) 
professionals while automating the process of software 
delivery and infrastructure changes. It aims at establishing 
a culture and environment where building, testing, and 
releasing software, can happen rapidly, frequently, and 
more reliably. - Wikipedia
Intro
BG
Ansible
Docker
- 7 -
DevOps Culture
● The opposite of DevOps is despair — Gene Kim
● Technology has became more reliable than our 
management and our process.
● People > Process > Tools.
● DevOps is not a job title, nor a product, but rather a culture 
and practices.
● It's an extension to « You operate what you build » to « 
everyone's involved ». Everyone includes more than devs 
and SysOps. Business guys are in, too.
● Everyone involved knows how the entire system works, and 
is clear about the underlying business value they bring to 
the table. Availability becomes the problem for the entire 
organization, not just for the SysOps.
Intro
BG
Ansible
Docker
- 8 -
DevOps Culture
● DevOps is not a technology problem. DevOps is a business 
problem.
● Waterfall 
● Complete isolation between Devs, SysOps, Business 
department.
● Each new release has destabilizing influence.
● DevOps
● Devs and Ops are a single team.
● « us » instead of « them ».
● Emphasizing people and process over tools.
● Allows tight alignment of operations with business needs 
and thus with customer needs.
Intro
BG
Ansible
Docker
- 9 -
DevOps Automation
● Why automation? 
● SysAdmin POV :
● Handle growing scale
● Counter increasing failures
● Ensuring servers consistency
● Stop repeating tasks
● Design for failure
● No more server documentation (yaaay!)
● Developers POV :
● Automation is fun
● Environment versioning
● You understand how production environment impact your 
code, hence you write more efficient code.
Intro
BG
Ansible
Docker
- 10 -
DevOps Automation
● Entrepreneur POV :
● Decrease operation overhead with scale
● Move among infrastructure providers
● Be agile on the infrastructure level
● Disaster Recovery
● Rapid Growth
● Slashdot Effect / Reddit Hug of Death
Intro
BG
Ansible
Docker
- 11 -
Intro
BG
Ansible
Docker
- 12 -
DevOps Automation
● Why not ?
● Oopses here are bad, really bad.
● It can be tempting to do risky things.
● Knowing how to automate doesn't mean that you know
what to automate.
● Knowing what to operate doesn't mean that you know
how to automate.
● With great power comes great responsibility.
Intro
BG
Ansible
Docker
- 13 -
I. backgroundIntro
BG
Ansible
Docker
- 14 -
Cloud
● On-demand computing: (I|P|S)aaS, the aaS part is what
matters.
● Why? Too late to ask that now.
● Its impact from the infrastructure POV: resulting IT systems
become more complex and scalable
Intro
BG
Ansible
Docker
- 15 -
Configuration management
● Concept
● Since when
● Push vs. Pull
Intro
BG
Ansible
Docker
- 16 -
conf. Management tools
● Ansible
● Chef
● Puppet
● Saltstack
● Fabric
● CFEngine
Intro
BG
Ansible
Docker
- 17 -
Containers
● OS level virtualization
● Containers vs. Virtualization
● Most known container engines:
● FreeBSD jails
● Solaris Zones
● Virtuozzo / OpenVZ
● LXC
● Docker
Intro
BG
Ansible
Docker
- 18 -
Microservices
● A software architecture style
● Application is broken down to lots of tiny services.
● The service does a single function.
● Each service is elastic, resilient, composable, minimal,
and complete.
● Services can be implemented using different
programming langages and environments.
● Services communicate using APIs
● Unix philosophy : Do one thing and do it well.
Intro
BG
Ansible
Docker
- 19 -
II. ansible
Intro
BG
Ansible
Docker
- 20 -
What is ansible ?
● named after the fictional
instantaneous hyperspace communication system
featured in Ender's Game.
● Feb 2012, Michael DeHaan – author of cobbler -
started Ansible project, after working in puppet labs.
● Design goals:
● Minimal
● Consistent
● Secure
● Highly reliable
● Low learning curve
● Commercially supported (Ansible Tower - GUI).
Intro
BG
Ansible
Docker
- 21 -
Why ansible ?
● Agentless : uses plain SSH.
● Idempotent : safe to re-run.
● Modular : large number of contributed modules.
● Simple
● Easy to use :
● YAML syntax
● JSON output
● It's python :)
● FOSS, naturally.
Intro
BG
Ansible
Docker
- 22 -
First look : ad-hoc command
● pip install ansible
● Echo “localhost” > hosts
● ansible all -i hosts -m ping
● ansible all -i hosts -m setup
Intro
BG
Ansible
Docker
- 23 -
Modules
● ansible all -i hosts -s -m shell -a 'apt-
get install nginx'
● ansible all -i hosts -s -m apt -a
'pkg=nginx state=installed
update_cache=true'
● Note : 'state' not 'change'
● You can write your own on any language, but please 
use python.
● https://docs.ansible.com/ansible/modules_by_category.html
Intro
BG
Ansible
Docker
- 24 -
task
● The basic unit of ansible code
● Playbook => roles => tasks
tasks:
- name: Install Nginx
apt: pkg=nginx state=installed
update_cache=true
Intro
BG
Ansible
Docker
- 25 -
Inventory file
● Usually named « hosts »
[loadbalancers]
lb1 server_role= « lb »
ansible_ssh_port=22
ansible_ssh_host=xx.xx.xx.xx
[app:children]
user_app
admin_app
[user_app]
app1 server_role « app »
ansible_ssh_port=22 ansible_ssh_host=xxxx
Intro
BG
Ansible
Docker
- 26 -
Dynamic InvEntory
● Getting the inventory file from another system :
● LDAP
● Cobbler
● OpenStack
● EC2
● … etc
● https://docs.ansible.com/ansible/intro_dynamic_inventory.html
Intro
BG
Ansible
Docker
- 27 -
roles
● Organized set of tasks with their needs
rolename
- defaults
- files
- handlers
- meta
- templates
- tasks
- vars
● Each of those directories include main.yml, except files 
and templates.
Intro
BG
Ansible
Docker
- 28 -
Files
● Files to be copied to the servers as is.
● No main.yml here.
● Example : startup scripts.
Intro
BG
Ansible
Docker
- 29 -
Templates
● Files to be copied to the server after substituting the 
variables, or doing some minor logic (i.e. loops)
● Python's Jinja2 template engine.
● No main.yml here too.
● Simple use :
echo {{ ip_forward }} >
/proc/sys/net/ipv4/ip_forward
Intro
BG
Ansible
Docker
- 30 -
Templates
● Adbanced use :
{% for service in outgoing %}
{{'##'|e }} {{ service.name }}
{{'##'|e }} {{'=' * service.name|length }}
iptables -A OUTPUT -p {{ service.protocol |
default('tcp') }} {{ '-d '+service.destination if
service.destination is defined else '' }} --dport
{{ service.port }} -j ACCEPT
iptables -A INPUT -p {{ service.protocol |
default('tcp') }} {{ '-s '+service.destination if
service.destination is defined else '' }} --sport
{{ service.port }} {{ '' if service.protocol is
defined and service.protocol == 'udp' else '! --syn
' }} -j ACCEPT
{% endfor %}
Intro
BG
Ansible
Docker
- 31 -
handler
● Just as a task, but triggered from within another task.
● Notifiers are only run if the Task is run. Think Event
tasks:
- name: Install Nginx
apt: pkg=nginx state=installed
update_cache=true
notify:
- Start Nginx
handlers:
- name: Start Nginx
service: name=nginx state=started
Intro
BG
Ansible
Docker
- 32 -
Meta
● Role meta data, including dependencies on other roles.
---
author: your name
description: what this role does
company: your_company
licence: GPLv2
min_ansible_version: 1.2
dependencies:
- { role: ssl }
Intro
BG
Ansible
Docker
- 33 -
playbook
● A complete project
playbook
- group_vars
- group1.yml
- all.yml
- hosts
- playbook.yml
- roles
- role1
- role2
Intro
BG
Ansible
Docker
- 34 -
variables
● declaration (in override order):
● command line
● playbook file
● group_vars
● role (vars)
● role (defaults)
● facts.
● https://docs.ansible.com/ansible/playbooks_variables.html
Intro
BG
Ansible
Docker
- 35 -
Spirula's practices
● Treat your CM code as code :
● Use version control.
● Comment on commits.
● Code reuse.
● Have a testing procedure.
● Keep your /etc/ansible/hosts empty, so you have to
define inventory file on each run.
● Keep your variable definition clean:
● Don't define vars in playbook file.
● Keep your project vars in playbook's group_vars, in
all.yml, or in the group if needed.
Intro
BG
Ansible
Docker
- 36 -
Ansible Galaxy
● Community hub for contributing, downloading, and reviewing
ansible roles.
ansible-galaxy install Spirula.common
● https://galaxy.ansible.com
Intro
BG
Ansible
Docker
- 37 -
III. dockerIntro
BG
Ansible
Docker
- 38 -
Docker Architecture
Intro
BG
Ansible
Docker
- 39 -
Containerization soln
Intro
BG
Ansible
Docker
- 40 -
Build Ship Run
● Build images using Dockerfiles.
● Ship images to different environments (testing, staging,
production).
● Run and scale your containers on different platform.
Intro
BG
Ansible
Docker
- 41 -
Docker 'Hello world'
● Install Docker engine on your Linux platform.
● Run :
$ docker run -it ubuntu:14.04 /bin/bash
● Docker will run a /bin/bash process inside a container and
give you control of this process.
Intro
BG
Ansible
Docker
- 42 -
Discussion
- 43 -
Resources
● Ansible:
● https://docs.ansible.com/ansible/
● https://serversforhackers.com/an-ansible-tutorial
● http://slash4.net/blog/deployment-automation/howto-use-ansible-to
● https://www.spirulasystems.com/blog/tech
● Book : Ansible for DevOps
● Book: The Practice of Cloud System Administration
● Docker
● https://the.binbashtheory.com/before-you-start-with-lxc-and-docke
● https://serversforhackers.com/getting-started-with-docker
- 44 -
Thank you
Ahmed Mekkawy
mekkawy@spiru.la
www.spirulasystems.com

More Related Content

PPTX
Edge and ai
PPTX
VOLODYMYR TSAP, BAQ, "CI/CD Infrastructure as a Code"
PDF
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
PDF
We Need to Talk: How Communication Helps Code
PDF
[DevConf.US 2019]Quarkus Brings Serverless to Java Developers
PDF
The Beam Vision for Portability: "Write once run anywhere"
PDF
Docker from a team perspective
PDF
Docker?!?! But I'm a SysAdmin
Edge and ai
VOLODYMYR TSAP, BAQ, "CI/CD Infrastructure as a Code"
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
We Need to Talk: How Communication Helps Code
[DevConf.US 2019]Quarkus Brings Serverless to Java Developers
The Beam Vision for Portability: "Write once run anywhere"
Docker from a team perspective
Docker?!?! But I'm a SysAdmin

What's hot (20)

PDF
Docker based-Pipelines with Codefresh
PPTX
Multi-cloud CI/CD with failover powered by K8s, Istio, Helm, and Codefresh
PDF
Okteto For Kubernetes Developer :- Container Camp 2020
PDF
Tales of Training: Scaling CodeLabs with Swarm Mode and Docker-Compose
PDF
Docker at MoneyBird
PDF
The Next Generation Cloud: Unleashing the Power of the Unikernal
PPTX
How to Achieve more through Collaboration
PDF
Knative makes Developers Incredible on Serverless
PDF
Node.js Rocks in Docker for Dev and Ops
PDF
Building Cloud Virtual Topologies with Ravello and Ansible
PDF
Securing the Software Supply Chain with TUF and Docker - Justin Cappos and Sa...
PDF
Docker
PDF
DCSF19 How To Build Your Containerization Strategy
PDF
Back to the Future: Containerize Legacy Applications
PDF
Terratest with Terraform
PPTX
Building CI/CD Pipelines with Jenkins and Kubernetes
PDF
Deploying containers on Heterogeneous IOT devices by Daniel Bruzual
PDF
Living with microservices at Pipedrive
PPTX
Instant developer onboarding with self contained repositories
PDF
Disruption from within
Docker based-Pipelines with Codefresh
Multi-cloud CI/CD with failover powered by K8s, Istio, Helm, and Codefresh
Okteto For Kubernetes Developer :- Container Camp 2020
Tales of Training: Scaling CodeLabs with Swarm Mode and Docker-Compose
Docker at MoneyBird
The Next Generation Cloud: Unleashing the Power of the Unikernal
How to Achieve more through Collaboration
Knative makes Developers Incredible on Serverless
Node.js Rocks in Docker for Dev and Ops
Building Cloud Virtual Topologies with Ravello and Ansible
Securing the Software Supply Chain with TUF and Docker - Justin Cappos and Sa...
Docker
DCSF19 How To Build Your Containerization Strategy
Back to the Future: Containerize Legacy Applications
Terratest with Terraform
Building CI/CD Pipelines with Jenkins and Kubernetes
Deploying containers on Heterogeneous IOT devices by Daniel Bruzual
Living with microservices at Pipedrive
Instant developer onboarding with self contained repositories
Disruption from within
Ad

Viewers also liked (16)

PDF
MoCDA Bylaws
PDF
Emily Huddleston Resume 1
PDF
Lewis Recommendation
PPTX
What is Sinusitis?
PDF
CertainTeed Proposal
DOCX
Preguntas de la prueba 2
PPTX
Brand journalism 1.0
PPTX
Geo.ii. imagenes. t.p. n °2
PPTX
KIM JUNSANG 取り組みと実績
ODT
autoevaluación
PPTX
Tarjeta de felicitación
PDF
Goal setting worksheet
PDF
"Πάμε θέατρο;", project Α' Λυκείου, εργασία
PPT
Internet marketing proposal from ETS
PDF
Dskp pendidikan muzik kssr tahun 5
PPTX
Abn 4 años1
MoCDA Bylaws
Emily Huddleston Resume 1
Lewis Recommendation
What is Sinusitis?
CertainTeed Proposal
Preguntas de la prueba 2
Brand journalism 1.0
Geo.ii. imagenes. t.p. n °2
KIM JUNSANG 取り組みと実績
autoevaluación
Tarjeta de felicitación
Goal setting worksheet
"Πάμε θέατρο;", project Α' Λυκείου, εργασία
Internet marketing proposal from ETS
Dskp pendidikan muzik kssr tahun 5
Abn 4 años1
Ad

Similar to Infrastructure as a Code (20)

PPTX
Ansible - Why and what
PDF
Automated Deployment and Configuration Engines. Ansible
PPTX
Go Faster with Ansible (AWS meetup)
PDF
Infrastructure = Code
PPTX
Ansible: What, Why & How
PPTX
Ansible Devops North East - slides
PDF
Devops with Python by Yaniv Cohen DevopShift
PDF
Managing Postgres with Ansible
PDF
Ansible at work
PDF
Getting Started with Ansible - Jake.pdf
PPTX
Intro to-ansible-sep7-meetup
PPTX
Automating with ansible (Part A)
PDF
Ansible Tutorial.pdf
PPTX
Go Faster with Ansible (PHP meetup)
PDF
Automating with ansible (part a)
PDF
Ansible - Hands on Training
PDF
Getting started with Ansible
PDF
Ansible & Salt - Vincent Boon
PPTX
Learn you some Ansible for great good!
PPTX
ansible-app-platforme-2024-presentation-
Ansible - Why and what
Automated Deployment and Configuration Engines. Ansible
Go Faster with Ansible (AWS meetup)
Infrastructure = Code
Ansible: What, Why & How
Ansible Devops North East - slides
Devops with Python by Yaniv Cohen DevopShift
Managing Postgres with Ansible
Ansible at work
Getting Started with Ansible - Jake.pdf
Intro to-ansible-sep7-meetup
Automating with ansible (Part A)
Ansible Tutorial.pdf
Go Faster with Ansible (PHP meetup)
Automating with ansible (part a)
Ansible - Hands on Training
Getting started with Ansible
Ansible & Salt - Vincent Boon
Learn you some Ansible for great good!
ansible-app-platforme-2024-presentation-

More from Ahmed Mekkawy (20)

PDF
Encrypted Traffic in Egypt - an attempt to understand
ODP
Securing Governmental Public Services with Free/Open Source Tools - Egyptian ...
PDF
OpenData for governments
PDF
شركة سبيرولا للأنظمة والجمعية المصرية للمصادر المفتوحة
PDF
Everything is a Game
ODP
Why Cloud Computing has to go the FOSS way
ODP
FOSS Enterpreneurship
ODP
Intro to FOSS & using it in development
PDF
FOSS, history and philosophy
ODP
Virtualization Techniques & Cloud Compting
ODP
A look at computer security
ODP
Networking in Gnu/Linux
ODP
Foss Movement In Egypt
ODP
Sysprog17
ODP
Sysprog 15
ODP
Sysprog 9
ODP
Sysprog 12
ODP
Sysprog 14
ODP
Sysprog 11
ODP
Sysprog 7
Encrypted Traffic in Egypt - an attempt to understand
Securing Governmental Public Services with Free/Open Source Tools - Egyptian ...
OpenData for governments
شركة سبيرولا للأنظمة والجمعية المصرية للمصادر المفتوحة
Everything is a Game
Why Cloud Computing has to go the FOSS way
FOSS Enterpreneurship
Intro to FOSS & using it in development
FOSS, history and philosophy
Virtualization Techniques & Cloud Compting
A look at computer security
Networking in Gnu/Linux
Foss Movement In Egypt
Sysprog17
Sysprog 15
Sysprog 9
Sysprog 12
Sysprog 14
Sysprog 11
Sysprog 7

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
cuic standard and advanced reporting.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Cloud computing and distributed systems.
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Encapsulation_ Review paper, used for researhc scholars
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
cuic standard and advanced reporting.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Machine learning based COVID-19 study performance prediction
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Electronic commerce courselecture one. Pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Cloud computing and distributed systems.
Diabetes mellitus diagnosis method based random forest with bat algorithm
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Unlocking AI with Model Context Protocol (MCP)
Reach Out and Touch Someone: Haptics and Empathic Computing
The AUB Centre for AI in Media Proposal.docx
Review of recent advances in non-invasive hemoglobin estimation
sap open course for s4hana steps from ECC to s4
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Digital-Transformation-Roadmap-for-Companies.pptx

Infrastructure as a Code

  • 1. - 1 - Infrastructure as-a-Code How can DevOps automation help you boosting your startup By : Ahmed Mekkawy
  • 2. - 2 - The presenter ● Ahmed Mekkawy AKA linuxawy. ● CEO | Founder of Spirula Systems. ● Co-founder of OpenEgypt. ● Free Software Foundation (FSF) member. ● Independent consultant at MCIT. ● Advisory board member at Mushtarak. ● One of the authors of the Egyptian government's FOSS  adoption strategy. Intro BG Ansible Docker
  • 3. - 3 - Who is this for ? ● Entrepreneur with a technical background, to take wise  decision. ● Developers, to get closer to operations and DevOps. ● SysAdmins/SysOps, to get closer to developers and  DevOps. ● Entry level DevOps. Intro BG Ansible Docker
  • 4. - 4 - prerequisites ● A background of development or system administration. ● Linux systems awareness. ● Familiarity with Linux command line. Intro BG Ansible Docker
  • 5. - 5 - Infrastructure as a code ● Definition ● Unlocked potentials : ● Dynamic infrastructure ● Minimizing cycle ● Environment versioning – through source control ● Testing your code/environment Intro BG Ansible Docker
  • 6. - 6 - Devops ? ● DevOps (a clipped compound of "development" and  "operations") is a culture, movement or practice that  emphasizes the collaboration and communication of both  software developers and other information-technology (IT)  professionals while automating the process of software  delivery and infrastructure changes. It aims at establishing  a culture and environment where building, testing, and  releasing software, can happen rapidly, frequently, and  more reliably. - Wikipedia Intro BG Ansible Docker
  • 7. - 7 - DevOps Culture ● The opposite of DevOps is despair — Gene Kim ● Technology has became more reliable than our  management and our process. ● People > Process > Tools. ● DevOps is not a job title, nor a product, but rather a culture  and practices. ● It's an extension to « You operate what you build » to «  everyone's involved ». Everyone includes more than devs  and SysOps. Business guys are in, too. ● Everyone involved knows how the entire system works, and  is clear about the underlying business value they bring to  the table. Availability becomes the problem for the entire  organization, not just for the SysOps. Intro BG Ansible Docker
  • 8. - 8 - DevOps Culture ● DevOps is not a technology problem. DevOps is a business  problem. ● Waterfall  ● Complete isolation between Devs, SysOps, Business  department. ● Each new release has destabilizing influence. ● DevOps ● Devs and Ops are a single team. ● « us » instead of « them ». ● Emphasizing people and process over tools. ● Allows tight alignment of operations with business needs  and thus with customer needs. Intro BG Ansible Docker
  • 9. - 9 - DevOps Automation ● Why automation?  ● SysAdmin POV : ● Handle growing scale ● Counter increasing failures ● Ensuring servers consistency ● Stop repeating tasks ● Design for failure ● No more server documentation (yaaay!) ● Developers POV : ● Automation is fun ● Environment versioning ● You understand how production environment impact your  code, hence you write more efficient code. Intro BG Ansible Docker
  • 10. - 10 - DevOps Automation ● Entrepreneur POV : ● Decrease operation overhead with scale ● Move among infrastructure providers ● Be agile on the infrastructure level ● Disaster Recovery ● Rapid Growth ● Slashdot Effect / Reddit Hug of Death Intro BG Ansible Docker
  • 12. - 12 - DevOps Automation ● Why not ? ● Oopses here are bad, really bad. ● It can be tempting to do risky things. ● Knowing how to automate doesn't mean that you know what to automate. ● Knowing what to operate doesn't mean that you know how to automate. ● With great power comes great responsibility. Intro BG Ansible Docker
  • 13. - 13 - I. backgroundIntro BG Ansible Docker
  • 14. - 14 - Cloud ● On-demand computing: (I|P|S)aaS, the aaS part is what matters. ● Why? Too late to ask that now. ● Its impact from the infrastructure POV: resulting IT systems become more complex and scalable Intro BG Ansible Docker
  • 15. - 15 - Configuration management ● Concept ● Since when ● Push vs. Pull Intro BG Ansible Docker
  • 16. - 16 - conf. Management tools ● Ansible ● Chef ● Puppet ● Saltstack ● Fabric ● CFEngine Intro BG Ansible Docker
  • 17. - 17 - Containers ● OS level virtualization ● Containers vs. Virtualization ● Most known container engines: ● FreeBSD jails ● Solaris Zones ● Virtuozzo / OpenVZ ● LXC ● Docker Intro BG Ansible Docker
  • 18. - 18 - Microservices ● A software architecture style ● Application is broken down to lots of tiny services. ● The service does a single function. ● Each service is elastic, resilient, composable, minimal, and complete. ● Services can be implemented using different programming langages and environments. ● Services communicate using APIs ● Unix philosophy : Do one thing and do it well. Intro BG Ansible Docker
  • 19. - 19 - II. ansible Intro BG Ansible Docker
  • 20. - 20 - What is ansible ? ● named after the fictional instantaneous hyperspace communication system featured in Ender's Game. ● Feb 2012, Michael DeHaan – author of cobbler - started Ansible project, after working in puppet labs. ● Design goals: ● Minimal ● Consistent ● Secure ● Highly reliable ● Low learning curve ● Commercially supported (Ansible Tower - GUI). Intro BG Ansible Docker
  • 21. - 21 - Why ansible ? ● Agentless : uses plain SSH. ● Idempotent : safe to re-run. ● Modular : large number of contributed modules. ● Simple ● Easy to use : ● YAML syntax ● JSON output ● It's python :) ● FOSS, naturally. Intro BG Ansible Docker
  • 22. - 22 - First look : ad-hoc command ● pip install ansible ● Echo “localhost” > hosts ● ansible all -i hosts -m ping ● ansible all -i hosts -m setup Intro BG Ansible Docker
  • 23. - 23 - Modules ● ansible all -i hosts -s -m shell -a 'apt- get install nginx' ● ansible all -i hosts -s -m apt -a 'pkg=nginx state=installed update_cache=true' ● Note : 'state' not 'change' ● You can write your own on any language, but please  use python. ● https://docs.ansible.com/ansible/modules_by_category.html Intro BG Ansible Docker
  • 24. - 24 - task ● The basic unit of ansible code ● Playbook => roles => tasks tasks: - name: Install Nginx apt: pkg=nginx state=installed update_cache=true Intro BG Ansible Docker
  • 25. - 25 - Inventory file ● Usually named « hosts » [loadbalancers] lb1 server_role= « lb » ansible_ssh_port=22 ansible_ssh_host=xx.xx.xx.xx [app:children] user_app admin_app [user_app] app1 server_role « app » ansible_ssh_port=22 ansible_ssh_host=xxxx Intro BG Ansible Docker
  • 26. - 26 - Dynamic InvEntory ● Getting the inventory file from another system : ● LDAP ● Cobbler ● OpenStack ● EC2 ● … etc ● https://docs.ansible.com/ansible/intro_dynamic_inventory.html Intro BG Ansible Docker
  • 27. - 27 - roles ● Organized set of tasks with their needs rolename - defaults - files - handlers - meta - templates - tasks - vars ● Each of those directories include main.yml, except files  and templates. Intro BG Ansible Docker
  • 28. - 28 - Files ● Files to be copied to the servers as is. ● No main.yml here. ● Example : startup scripts. Intro BG Ansible Docker
  • 29. - 29 - Templates ● Files to be copied to the server after substituting the  variables, or doing some minor logic (i.e. loops) ● Python's Jinja2 template engine. ● No main.yml here too. ● Simple use : echo {{ ip_forward }} > /proc/sys/net/ipv4/ip_forward Intro BG Ansible Docker
  • 30. - 30 - Templates ● Adbanced use : {% for service in outgoing %} {{'##'|e }} {{ service.name }} {{'##'|e }} {{'=' * service.name|length }} iptables -A OUTPUT -p {{ service.protocol | default('tcp') }} {{ '-d '+service.destination if service.destination is defined else '' }} --dport {{ service.port }} -j ACCEPT iptables -A INPUT -p {{ service.protocol | default('tcp') }} {{ '-s '+service.destination if service.destination is defined else '' }} --sport {{ service.port }} {{ '' if service.protocol is defined and service.protocol == 'udp' else '! --syn ' }} -j ACCEPT {% endfor %} Intro BG Ansible Docker
  • 31. - 31 - handler ● Just as a task, but triggered from within another task. ● Notifiers are only run if the Task is run. Think Event tasks: - name: Install Nginx apt: pkg=nginx state=installed update_cache=true notify: - Start Nginx handlers: - name: Start Nginx service: name=nginx state=started Intro BG Ansible Docker
  • 32. - 32 - Meta ● Role meta data, including dependencies on other roles. --- author: your name description: what this role does company: your_company licence: GPLv2 min_ansible_version: 1.2 dependencies: - { role: ssl } Intro BG Ansible Docker
  • 33. - 33 - playbook ● A complete project playbook - group_vars - group1.yml - all.yml - hosts - playbook.yml - roles - role1 - role2 Intro BG Ansible Docker
  • 34. - 34 - variables ● declaration (in override order): ● command line ● playbook file ● group_vars ● role (vars) ● role (defaults) ● facts. ● https://docs.ansible.com/ansible/playbooks_variables.html Intro BG Ansible Docker
  • 35. - 35 - Spirula's practices ● Treat your CM code as code : ● Use version control. ● Comment on commits. ● Code reuse. ● Have a testing procedure. ● Keep your /etc/ansible/hosts empty, so you have to define inventory file on each run. ● Keep your variable definition clean: ● Don't define vars in playbook file. ● Keep your project vars in playbook's group_vars, in all.yml, or in the group if needed. Intro BG Ansible Docker
  • 36. - 36 - Ansible Galaxy ● Community hub for contributing, downloading, and reviewing ansible roles. ansible-galaxy install Spirula.common ● https://galaxy.ansible.com Intro BG Ansible Docker
  • 37. - 37 - III. dockerIntro BG Ansible Docker
  • 38. - 38 - Docker Architecture Intro BG Ansible Docker
  • 39. - 39 - Containerization soln Intro BG Ansible Docker
  • 40. - 40 - Build Ship Run ● Build images using Dockerfiles. ● Ship images to different environments (testing, staging, production). ● Run and scale your containers on different platform. Intro BG Ansible Docker
  • 41. - 41 - Docker 'Hello world' ● Install Docker engine on your Linux platform. ● Run : $ docker run -it ubuntu:14.04 /bin/bash ● Docker will run a /bin/bash process inside a container and give you control of this process. Intro BG Ansible Docker
  • 43. - 43 - Resources ● Ansible: ● https://docs.ansible.com/ansible/ ● https://serversforhackers.com/an-ansible-tutorial ● http://slash4.net/blog/deployment-automation/howto-use-ansible-to ● https://www.spirulasystems.com/blog/tech ● Book : Ansible for DevOps ● Book: The Practice of Cloud System Administration ● Docker ● https://the.binbashtheory.com/before-you-start-with-lxc-and-docke ● https://serversforhackers.com/getting-started-with-docker
  • 44. - 44 - Thank you Ahmed Mekkawy mekkawy@spiru.la www.spirulasystems.com