SlideShare a Scribd company logo
1 of 18
Automating AWS Infrastructure and code
deployments using Ansible
Who Am I ?
Vishal Uderani (@vishallud)
Lead DevOps Engineer @WebEngage
Grand Maester , House of Bash
(when annoyed , I replace things with tiny shell
scripts)
Infrastructure at a glance
150+ instances on AWS
2 billion http req/month
Java , JS , Node , React.js , Clojure
Kafka , Zookeeper , Mongodb , Mysql
Redshift , Blueshift , CitusDB
https://engineering.webengage.com/
Pre-ansible deployments
Cumbersome
Slow/too much manual intervention
Error-prone
SPOF on the dev/ops guy who would know
how to deploy
Why choose Ansible ?
●Immutable Infrastructure
* ability to create/destroy/replace servers
at anytime without service disruptions
* become vendor-agnostic by having
playbooks run on AWS/GCE/Rackspace etc
https://github.com/jlund/streisand
●push based instead of pull
* ideal for deployments
* needs no agents to be installed(ssh-keys)
●configuration is ordered
* commands are structured and executed
one after another
●gentler learning curve/time to get started
$ sudo easy_install pip
$ sudo pip install ansible
●dynamic inventory
* helps maintain inventory sanity in a
distributed cloud
* can run against ec2-tags/hostnames/tons
of predefined variables
“ec2_tag_monitoring": "true"
“ec2_tag_env”: "production”
https://github.com/vishalud/ansible-
playbooks/tree/master/users
Deployment playbooks
$ cat deploy-webengage.yml
---
# This playbook deploys the whole application stack for webengage
- name: apply common configuration to base node/build the stack
hosts: ami-nodes
user: "{{ deploy_user }}"
sudo: yes
roles:
- common
- aws
$ cat roles/common/tasks/main.yml
---
- include: config_ant_deploy.yml tags=ant-deploy
- include: config_ant_deploy_api.yml tags=ant-deploy-api
$ cat roles/common/tasks/config_ant_deploy.yml
- name: checkout latest web app code from github
git: repo=git@somerepo.com/webengage.git dest=/our/deploy/location key_file=/path/to/id_rsa
accept_hostkey=yes
- name: Ensure the build directory has the correct permissions before building
file: dest=/our/deploy/location/ owner=webengage group=webengage recurse=yes
# Runs ant deploy and poll as an async task
- name: Do ant deploy app
command: /usr/local/ant/bin/ant web clean deploy chdir=/our/deploy/location
async: 1800
poll: 10
#aysnc on very long running operations which may subject to ssh timeout . poll 0 to fire and forget
#Use a higher value for --forks will result in async tasks running faster and increases polling efficiency
$ cat roles/aws/tasks/create_new_ami.yml
- name: Creating new test-ami
ec2_ami:
aws_access_key: "{{ ec2_access_key }}"
aws_secret_key: "{{ ec2_secret_key }}"
region: "{{ region }}"
instance_id: "{{ hostvars[inventory_hostname]['ansible_ec2_instance_id'] }}"
no_reboot: yes
name: ansible-created-ami-{{ timestamp.stdout }}
wait: yes
$ cat roles/aws/tasks/create_ec2_dashboard.yml
- name: Get latest ami based on date
local_action:
module: ec2_ami_find
region: "{{ region }}"
name: "ansible-created-ami-{{ timestamp.stdout }}"
sort: name
sort_order: descending
sort_end: 1
register: existing_ami
- debug: var=existing_ami.results[0].ami_id
● ec2_ami_find is an ansible 2.0 module and must be imported manually for it work under
../library/ec2_ami_find.py
- name: Creating a new instance for dashboard
ec2:
key_name: webengage
aws_access_key: "{{ ec2_access_key }}"
aws_secret_key: "{{ ec2_secret_key }}"
count: 1
image: "{{ existing_ami.results[0].ami_id }}"
region: "{{ region }}"
group_id: “{{ ec2_sg_group }}”
zone: {{ az_zone }}
instance_type: m3.large
instance_tags:
env: production
Name: prod-dashboard{{ new_dashboard_version }}
wait: yes
user_data: prod dashboard
register: ec2
- name: Wait for HTTP to come up
local_action:
module: wait_for
host: "{{ item.public_ip }}"
port: 80
delay: 60
timeout: 400
state: started
with_items: ec2.instances
- name: Associate the dashboard EIP to the new instance
local_action:
module: ec2_eip
aws_access_key: "{{ ec2_access_key }}"
aws_secret_key: "{{ ec2_secret_key }}"
region: "{{ region }}"
instance_id: '{{ item.id }}'
ip: “{{ dashboard_ip }}”
with_items: ec2.instances
- name: Send notification message via Slack
local_action:
module: slack
channel: "#dev"
token: {{ slack_token }}
msg: "Dashboard has been deployed
successfully.<http://repo.webengage.com/api/v3/projects/18/repository/commits/master?private_token=<token>|Cl
ick here> for details on the last git commit"
$ cat roles/aws/tasks/main.yml
- include: create_ec2_feedback.yml tags=deploy-feedback
- include: create_ec2_notification.yml tags=deploy-notification
- include: create_ec2_dashboard.yml tags=deploy-dashboard
- include: create_new_ami.yml tags=create-ami
- include: search-ami.yml tags=search-ami
$ ansible-playbook deploy-webengage.yml -i hosts --tags "create-ami,deploy-dashboard"
$ ansible-playbook deploy-webengage.yml -i hosts --tags “search-ami,deploy-notification”
Using ansible-pull
1. each host has Ansible installed
2. the configuration is stored in a Git repository
3. ansible-pull checkouts the configuration repository at a given branch or tag (hint: think prod,
staging,web,db etc),
4. ansible-pull executes a specified playbook(users , sudoers , logrotate)
5. you automate the process using a cronjob, and then all you have to do is pushing the configuration
changes to a Git repository.
Integrating Ansible with Rundeck
● Free replacement for Ansible Tower
● One click deployments/running of ansible playbooks
● Job monitoring/statistics/time taken to execute jobs
● Use workflows . Eg: if playbook A fails , continue executing playbook B
● Delegate jobs to multiple users/Avoid SPOF completely (Integrate with AD)
● Stay lazy
https://github.com/vishalud/ansible-playbooks/tree/master/ansible-elasticsearch
https://github.com/vishalud/ansible-playbooks/tree/master/ansible-newrelic
https://github.com/vishalud/ansible-playbooks/tree/master/ansible-oracle-java
https://github.com/vishalud/ansible-playbooks/tree/master/datadog-agent
https://github.com/vishalud/ansible-playbooks/tree/master/sudo
Automating aws infrastructure and code deployments using Ansible @WebEngage

More Related Content

What's hot

Ansible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel AvivAnsible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel AvivAmazon Web Services
 
Mitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpMitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpOntico
 
How Ansible Makes Automation Easy
How Ansible Makes Automation EasyHow Ansible Makes Automation Easy
How Ansible Makes Automation EasyPeter Sankauskas
 
Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)Richard Donkin
 
Monitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleMonitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleItamar Hassin
 
Docker ansible-make-chef-puppet-unnecessary-minnihan
Docker ansible-make-chef-puppet-unnecessary-minnihanDocker ansible-make-chef-puppet-unnecessary-minnihan
Docker ansible-make-chef-puppet-unnecessary-minnihanjbminn
 
Ansible 2 and Ansible Galaxy 2
Ansible 2 and Ansible Galaxy 2Ansible 2 and Ansible Galaxy 2
Ansible 2 and Ansible Galaxy 2Jeff Geerling
 
Continuous Testing with Molecule, Ansible, and GitHub Actions
Continuous Testing with Molecule, Ansible, and GitHub ActionsContinuous Testing with Molecule, Ansible, and GitHub Actions
Continuous Testing with Molecule, Ansible, and GitHub ActionsJeff Geerling
 
Introduction to ansible galaxy
Introduction to ansible galaxyIntroduction to ansible galaxy
Introduction to ansible galaxyIvan Serdyuk
 
Managing Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with AnsibleManaging Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with Ansiblefmaccioni
 
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...Simplilearn
 
OpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid CloudOpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid CloudIsaac Christoffersen
 
Fake IT, until you make IT
Fake IT, until you make ITFake IT, until you make IT
Fake IT, until you make ITBas Meijer
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleOrestes Carracedo
 
Distributed automation sel_conf_2015
Distributed automation sel_conf_2015Distributed automation sel_conf_2015
Distributed automation sel_conf_2015aragavan
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with AnsibleAnas
 
Ansible introduction - XX Betabeers Galicia
Ansible introduction - XX Betabeers GaliciaAnsible introduction - XX Betabeers Galicia
Ansible introduction - XX Betabeers GaliciaJuan Diego Pereiro Arean
 
Automation with Packer and TerraForm
Automation with Packer and TerraFormAutomation with Packer and TerraForm
Automation with Packer and TerraFormWesley Charles Blake
 

What's hot (20)

Ansible Case Studies
Ansible Case StudiesAnsible Case Studies
Ansible Case Studies
 
Ansible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel AvivAnsible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel Aviv
 
Mitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpMitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorp
 
How Ansible Makes Automation Easy
How Ansible Makes Automation EasyHow Ansible Makes Automation Easy
How Ansible Makes Automation Easy
 
Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)
 
Monitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleMonitor-Driven Development Using Ansible
Monitor-Driven Development Using Ansible
 
Docker ansible-make-chef-puppet-unnecessary-minnihan
Docker ansible-make-chef-puppet-unnecessary-minnihanDocker ansible-make-chef-puppet-unnecessary-minnihan
Docker ansible-make-chef-puppet-unnecessary-minnihan
 
Ansible 2 and Ansible Galaxy 2
Ansible 2 and Ansible Galaxy 2Ansible 2 and Ansible Galaxy 2
Ansible 2 and Ansible Galaxy 2
 
Continuous Testing with Molecule, Ansible, and GitHub Actions
Continuous Testing with Molecule, Ansible, and GitHub ActionsContinuous Testing with Molecule, Ansible, and GitHub Actions
Continuous Testing with Molecule, Ansible, and GitHub Actions
 
Introduction to ansible galaxy
Introduction to ansible galaxyIntroduction to ansible galaxy
Introduction to ansible galaxy
 
Managing Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with AnsibleManaging Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with Ansible
 
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
 
OpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid CloudOpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid Cloud
 
Fake IT, until you make IT
Fake IT, until you make ITFake IT, until you make IT
Fake IT, until you make IT
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
 
Distributed automation sel_conf_2015
Distributed automation sel_conf_2015Distributed automation sel_conf_2015
Distributed automation sel_conf_2015
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with Ansible
 
Ansible introduction - XX Betabeers Galicia
Ansible introduction - XX Betabeers GaliciaAnsible introduction - XX Betabeers Galicia
Ansible introduction - XX Betabeers Galicia
 
Automation with Packer and TerraForm
Automation with Packer and TerraFormAutomation with Packer and TerraForm
Automation with Packer and TerraForm
 

Viewers also liked

Patterns and antipatterns in Docker image lifecycle @ Codemash 2017
Patterns and antipatterns in Docker image lifecycle @ Codemash 2017Patterns and antipatterns in Docker image lifecycle @ Codemash 2017
Patterns and antipatterns in Docker image lifecycle @ Codemash 2017Baruch Sadogursky
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Alex S
 
Talk about Ansible and Infrastructure as Code
Talk about Ansible and Infrastructure as CodeTalk about Ansible and Infrastructure as Code
Talk about Ansible and Infrastructure as CodeSATOSHI TAGOMORI
 
Introduction to Automated Deployments with Ansible
Introduction to Automated Deployments with AnsibleIntroduction to Automated Deployments with Ansible
Introduction to Automated Deployments with AnsibleMartin Etmajer
 
Ansible Oxford - Cows & Containers
Ansible Oxford - Cows & ContainersAnsible Oxford - Cows & Containers
Ansible Oxford - Cows & Containersjonatanblue
 
Choosing the Right Framework for Running Docker Containers in Prod
Choosing the Right Framework for Running Docker Containers in ProdChoosing the Right Framework for Running Docker Containers in Prod
Choosing the Right Framework for Running Docker Containers in ProdJosh Padnick
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationJohn Lynch
 
Automated Deployments with Ansible
Automated Deployments with AnsibleAutomated Deployments with Ansible
Automated Deployments with AnsibleMartin Etmajer
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleStein Inge Morisbak
 
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...Yevgeniy Brikman
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricksbcoca
 
Infrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & AnsibleInfrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & AnsibleRobert Reiz
 
Capacity Planning
Capacity PlanningCapacity Planning
Capacity PlanningMOHD ARISH
 

Viewers also liked (16)

Patterns and antipatterns in Docker image lifecycle @ Codemash 2017
Patterns and antipatterns in Docker image lifecycle @ Codemash 2017Patterns and antipatterns in Docker image lifecycle @ Codemash 2017
Patterns and antipatterns in Docker image lifecycle @ Codemash 2017
 
Monitoring @haptik
Monitoring @haptikMonitoring @haptik
Monitoring @haptik
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015
 
Talk about Ansible and Infrastructure as Code
Talk about Ansible and Infrastructure as CodeTalk about Ansible and Infrastructure as Code
Talk about Ansible and Infrastructure as Code
 
Introduction to Automated Deployments with Ansible
Introduction to Automated Deployments with AnsibleIntroduction to Automated Deployments with Ansible
Introduction to Automated Deployments with Ansible
 
Ansible Oxford - Cows & Containers
Ansible Oxford - Cows & ContainersAnsible Oxford - Cows & Containers
Ansible Oxford - Cows & Containers
 
Choosing the Right Framework for Running Docker Containers in Prod
Choosing the Right Framework for Running Docker Containers in ProdChoosing the Right Framework for Running Docker Containers in Prod
Choosing the Right Framework for Running Docker Containers in Prod
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Automated Deployments with Ansible
Automated Deployments with AnsibleAutomated Deployments with Ansible
Automated Deployments with Ansible
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricks
 
Infrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & AnsibleInfrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & Ansible
 
Capacity Planning
Capacity PlanningCapacity Planning
Capacity Planning
 
Rundeck & Ansible
Rundeck & AnsibleRundeck & Ansible
Rundeck & Ansible
 

Similar to Automating aws infrastructure and code deployments using Ansible @WebEngage

Kubernetes Boston — Custom High Availability of Kubernetes
Kubernetes Boston — Custom High Availability of KubernetesKubernetes Boston — Custom High Availability of Kubernetes
Kubernetes Boston — Custom High Availability of KubernetesMike Splain
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
A tour of Ansible
A tour of AnsibleA tour of Ansible
A tour of AnsibleDevOps Ltd.
 
AWS Lambda with Serverless Framework and Java
AWS Lambda with Serverless Framework and JavaAWS Lambda with Serverless Framework and Java
AWS Lambda with Serverless Framework and JavaManish Pandit
 
Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila - docker clusters (solit 2015)Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila - docker clusters (solit 2015)Artem Zhurbila
 
Deploying your web application with AWS ElasticBeanstalk
Deploying your web application with AWS ElasticBeanstalkDeploying your web application with AWS ElasticBeanstalk
Deploying your web application with AWS ElasticBeanstalkJulien SIMON
 
Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)DECK36
 
Ansible inside
Ansible insideAnsible inside
Ansible insideIdeato
 
Fullstack conf 2017 - Basic dev pipeline end-to-end
Fullstack conf 2017 - Basic dev pipeline end-to-endFullstack conf 2017 - Basic dev pipeline end-to-end
Fullstack conf 2017 - Basic dev pipeline end-to-endEzequiel Maraschio
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierCarlos Sanchez
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansibleahamilton55
 
Containerizing your Security Operations Center
Containerizing your Security Operations CenterContainerizing your Security Operations Center
Containerizing your Security Operations CenterJimmy Mesta
 
Extend and build on Kubernetes
Extend and build on KubernetesExtend and build on Kubernetes
Extend and build on KubernetesStefan Schimanski
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)Wesley Beary
 
Cloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the CloudCloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the Cloudpetriojala123
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the CloudWesley Beary
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Carlos Sanchez
 

Similar to Automating aws infrastructure and code deployments using Ansible @WebEngage (20)

Discovering OpenBSD on AWS
Discovering OpenBSD on AWSDiscovering OpenBSD on AWS
Discovering OpenBSD on AWS
 
Kubernetes Boston — Custom High Availability of Kubernetes
Kubernetes Boston — Custom High Availability of KubernetesKubernetes Boston — Custom High Availability of Kubernetes
Kubernetes Boston — Custom High Availability of Kubernetes
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
A tour of Ansible
A tour of AnsibleA tour of Ansible
A tour of Ansible
 
AWS Lambda with Serverless Framework and Java
AWS Lambda with Serverless Framework and JavaAWS Lambda with Serverless Framework and Java
AWS Lambda with Serverless Framework and Java
 
Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila - docker clusters (solit 2015)Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila - docker clusters (solit 2015)
 
One-Man Ops
One-Man OpsOne-Man Ops
One-Man Ops
 
Deploying your web application with AWS ElasticBeanstalk
Deploying your web application with AWS ElasticBeanstalkDeploying your web application with AWS ElasticBeanstalk
Deploying your web application with AWS ElasticBeanstalk
 
Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)
 
Ansible inside
Ansible insideAnsible inside
Ansible inside
 
Fullstack conf 2017 - Basic dev pipeline end-to-end
Fullstack conf 2017 - Basic dev pipeline end-to-endFullstack conf 2017 - Basic dev pipeline end-to-end
Fullstack conf 2017 - Basic dev pipeline end-to-end
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
 
Sheep it
Sheep itSheep it
Sheep it
 
Containerizing your Security Operations Center
Containerizing your Security Operations CenterContainerizing your Security Operations Center
Containerizing your Security Operations Center
 
Extend and build on Kubernetes
Extend and build on KubernetesExtend and build on Kubernetes
Extend and build on Kubernetes
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
 
Cloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the CloudCloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the Cloud
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloud
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
 

Recently uploaded

IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxsomshekarkn64
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 

Recently uploaded (20)

IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 

Automating aws infrastructure and code deployments using Ansible @WebEngage

  • 1. Automating AWS Infrastructure and code deployments using Ansible
  • 2. Who Am I ? Vishal Uderani (@vishallud) Lead DevOps Engineer @WebEngage Grand Maester , House of Bash (when annoyed , I replace things with tiny shell scripts)
  • 3.
  • 4. Infrastructure at a glance 150+ instances on AWS 2 billion http req/month Java , JS , Node , React.js , Clojure Kafka , Zookeeper , Mongodb , Mysql Redshift , Blueshift , CitusDB https://engineering.webengage.com/
  • 5. Pre-ansible deployments Cumbersome Slow/too much manual intervention Error-prone SPOF on the dev/ops guy who would know how to deploy
  • 6. Why choose Ansible ? ●Immutable Infrastructure * ability to create/destroy/replace servers at anytime without service disruptions * become vendor-agnostic by having playbooks run on AWS/GCE/Rackspace etc https://github.com/jlund/streisand
  • 7. ●push based instead of pull * ideal for deployments * needs no agents to be installed(ssh-keys) ●configuration is ordered * commands are structured and executed one after another ●gentler learning curve/time to get started $ sudo easy_install pip $ sudo pip install ansible
  • 8. ●dynamic inventory * helps maintain inventory sanity in a distributed cloud * can run against ec2-tags/hostnames/tons of predefined variables “ec2_tag_monitoring": "true" “ec2_tag_env”: "production” https://github.com/vishalud/ansible- playbooks/tree/master/users
  • 9. Deployment playbooks $ cat deploy-webengage.yml --- # This playbook deploys the whole application stack for webengage - name: apply common configuration to base node/build the stack hosts: ami-nodes user: "{{ deploy_user }}" sudo: yes roles: - common - aws $ cat roles/common/tasks/main.yml --- - include: config_ant_deploy.yml tags=ant-deploy - include: config_ant_deploy_api.yml tags=ant-deploy-api
  • 10. $ cat roles/common/tasks/config_ant_deploy.yml - name: checkout latest web app code from github git: repo=git@somerepo.com/webengage.git dest=/our/deploy/location key_file=/path/to/id_rsa accept_hostkey=yes - name: Ensure the build directory has the correct permissions before building file: dest=/our/deploy/location/ owner=webengage group=webengage recurse=yes # Runs ant deploy and poll as an async task - name: Do ant deploy app command: /usr/local/ant/bin/ant web clean deploy chdir=/our/deploy/location async: 1800 poll: 10 #aysnc on very long running operations which may subject to ssh timeout . poll 0 to fire and forget #Use a higher value for --forks will result in async tasks running faster and increases polling efficiency
  • 11. $ cat roles/aws/tasks/create_new_ami.yml - name: Creating new test-ami ec2_ami: aws_access_key: "{{ ec2_access_key }}" aws_secret_key: "{{ ec2_secret_key }}" region: "{{ region }}" instance_id: "{{ hostvars[inventory_hostname]['ansible_ec2_instance_id'] }}" no_reboot: yes name: ansible-created-ami-{{ timestamp.stdout }} wait: yes
  • 12. $ cat roles/aws/tasks/create_ec2_dashboard.yml - name: Get latest ami based on date local_action: module: ec2_ami_find region: "{{ region }}" name: "ansible-created-ami-{{ timestamp.stdout }}" sort: name sort_order: descending sort_end: 1 register: existing_ami - debug: var=existing_ami.results[0].ami_id ● ec2_ami_find is an ansible 2.0 module and must be imported manually for it work under ../library/ec2_ami_find.py
  • 13. - name: Creating a new instance for dashboard ec2: key_name: webengage aws_access_key: "{{ ec2_access_key }}" aws_secret_key: "{{ ec2_secret_key }}" count: 1 image: "{{ existing_ami.results[0].ami_id }}" region: "{{ region }}" group_id: “{{ ec2_sg_group }}” zone: {{ az_zone }} instance_type: m3.large instance_tags: env: production Name: prod-dashboard{{ new_dashboard_version }} wait: yes user_data: prod dashboard register: ec2
  • 14. - name: Wait for HTTP to come up local_action: module: wait_for host: "{{ item.public_ip }}" port: 80 delay: 60 timeout: 400 state: started with_items: ec2.instances - name: Associate the dashboard EIP to the new instance local_action: module: ec2_eip aws_access_key: "{{ ec2_access_key }}" aws_secret_key: "{{ ec2_secret_key }}" region: "{{ region }}" instance_id: '{{ item.id }}' ip: “{{ dashboard_ip }}” with_items: ec2.instances
  • 15. - name: Send notification message via Slack local_action: module: slack channel: "#dev" token: {{ slack_token }} msg: "Dashboard has been deployed successfully.<http://repo.webengage.com/api/v3/projects/18/repository/commits/master?private_token=<token>|Cl ick here> for details on the last git commit" $ cat roles/aws/tasks/main.yml - include: create_ec2_feedback.yml tags=deploy-feedback - include: create_ec2_notification.yml tags=deploy-notification - include: create_ec2_dashboard.yml tags=deploy-dashboard - include: create_new_ami.yml tags=create-ami - include: search-ami.yml tags=search-ami $ ansible-playbook deploy-webengage.yml -i hosts --tags "create-ami,deploy-dashboard" $ ansible-playbook deploy-webengage.yml -i hosts --tags “search-ami,deploy-notification”
  • 16. Using ansible-pull 1. each host has Ansible installed 2. the configuration is stored in a Git repository 3. ansible-pull checkouts the configuration repository at a given branch or tag (hint: think prod, staging,web,db etc), 4. ansible-pull executes a specified playbook(users , sudoers , logrotate) 5. you automate the process using a cronjob, and then all you have to do is pushing the configuration changes to a Git repository.
  • 17. Integrating Ansible with Rundeck ● Free replacement for Ansible Tower ● One click deployments/running of ansible playbooks ● Job monitoring/statistics/time taken to execute jobs ● Use workflows . Eg: if playbook A fails , continue executing playbook B ● Delegate jobs to multiple users/Avoid SPOF completely (Integrate with AD) ● Stay lazy https://github.com/vishalud/ansible-playbooks/tree/master/ansible-elasticsearch https://github.com/vishalud/ansible-playbooks/tree/master/ansible-newrelic https://github.com/vishalud/ansible-playbooks/tree/master/ansible-oracle-java https://github.com/vishalud/ansible-playbooks/tree/master/datadog-agent https://github.com/vishalud/ansible-playbooks/tree/master/sudo