SlideShare une entreprise Scribd logo
1  sur  38
How Ansible helps Backbase
Ansible Benelux meetup
Pavel Chunyayev
Amsterdam, 27-5-2015
Who am I
• Come from Ukraine
• 11 years in IT
• Worked in Ukraine, Estonia and the Netherlands
• Continuous Delivery architect at Levi9 IT Services
• Last 6 months - Automation architect at Backbase
Backbase CXP
Backbase Customer Experience Platform
• Core services
• Content services
• Publication services
• 3 environments – Editorial, Staging, Live
Different configuration options
• Java version
• Application Server
• RDBMS
• HTTP/HTTPS
• Internal configuration options
• Optional application features
A lot of things are already automated
• There are servers for released CXP version
• With different configurations
• They can be started/stopped when needed
• Newest version of the application needs to be deployed.
• In most cases manually.
• For some configurations deployment required repackaging of the application.
• Automated through maven
• There is a sandbox environment with the nightly build
• Deployed automatically
• Far from production setup
Handcrafted servers
• Hard to maintain
• Very time/cost sensitive
• Setup is not easily reproducible
• May be buggy
• It should take less time to rebuild a server from the scratch than to
log in and fix/update it.
Solution
Solution diagram
Why Ansible
• Python powered
• No master, agentless
• Free, open source
• Plenty of modules (batteries included)
• Great EC2 support
• Windows support (kind of)
• Parallel, but controllable execution
• Quite simple for developer to understand
Why REST service
• Create infrastructure easily
• Just send JSON formatted configuration
• Service will analyze it and trigger Ansible run
• Service is the single point of contact for any infrastructure requests
• Can be integrated into any CI, script, application or other service
Why UI
• Everyone needs to create an environment from time to time
• Opening a ticket and then waiting is not an option
• In most situations environments are required for a short period of
time.
• Self-service
Demo
• Directory structure
• Flow of work
• Decision tree
Ansible features we are using
• Handlers
• Variables
• Jinja2 templates
• Facts
• Conditions
• Playbook includes
• Inventory (fake) – hostgroups!
• Roles :(
ec2
ec2:
key_name: '{{ keypair }}'
group_id: '{{ security_group }}'
instance_type: '{{ instance }}'
image: '{{ image }}'
region: '{{ region }}'
vpc_subnet_id: '{{ subnet }}'
user_data: "{{ item }}"
instance_profile_name: 'access-to-s3'
instance_tags:
origin: "{{ origin }}"
environment_name: "{{ environment_name }}"
stack_id: "{{ stack_id }}"
owner_id: "{{ owner_id }} "
role: "{{ item }}"
timestamp: "{{ timestamp }}"
with_items: server_roles
register: ec2
Facts
- name: Set the facts and hostnames
hosts: all_hosts
connection: ssh
gather_facts: True
max_fail_percentage: 0
tasks:
- name: Gather EC2 facts
ec2_facts:
- name: Set environment fact
set_fact: this_environment="{{ ansible_ec2_user_data }}"
- name: Set hostnames
hostname: name="{{ environment_name }}-{{ this_environment }}"
route53
route53:
command: create
zone: backbase.dev
private_zone: yes
overwrite: yes
record: "{{ environment_name }}-{{ item.0 }}.backbase.dev"
type: A
ttl: 10
value: "{{ item.1.instances[0].private_ip }}"
with_together:
- server_roles
- ec2.results
register: r53_result
until: r53_result|success
retries: 20
delay: "{{ 10 |random }}"
Jinja2 templates
{% block portal_db %}{% endblock %}
{% if http_or_https == 'http' %}
{% set port = http_port %}
{% else %}
{% set port = https_port %}
{% endif %}
{% if this_environment == "editorial" %}
foundation.environment.editorial=true
{% else %}
foundation.environment.editorial=false
{% endif %}
foundation.content.proxy.destination={{ http_or_https }}://{{ environment_name }}-{{
this_environment }}.backbase.dev:{{ port }}/contentservices
wait_for
- name: Start WSLC
shell: /opt/IBM/Websphere/INIT.websphere start {{ this_environment }}
- name: Wait for WSLC to start
wait_for: path=“/opt/IBM/Websphere/usr/servers/{{ this_environment }}/logs/console.log”
search_regex=“The server {{ this_environment }} is ready to run a smarter planet.”
timeout=30"
- name: Run the trigger
shell: /opt/install/app_start_trigger.sh &> /opt/install/app_start_trigger.log; sleep 2
- name: Wait for all apps to start
wait_for:
path="/opt/IBM/Websphere/usr/servers/{{ this_environment }}/logs/messages.log"
search_regex="SRVE0242I: [portalserver] [/portalserver] [/WEB-INF/index.jsp]:
Initialization successful."
timeout=600
Recovering from failure
- name: Download CXP
shell: s3cmd get s3://s3_bucket_here/Backbase_Portal_5.6.0-{{ version }}.zip
/opt/install/portal-package-5.6.0-{{ version }}.zip --force 2>&1 | tee
/opt/install/direct_loader.log
register: cxp_download_sleeper
until: cxp_download_sleeper.stdout.find("saved as") != -1
retries: 10
delay: "{{ 10 | random }}"
API
• /api/stacks - GET - List stacks available for provisioning
• /api/stacks/stack_name - GET - List the stack configuration
• /api/environments - GET - List all currently provisioned
environments
• /api/stacks/stack_name - POST - Provision specified stack
• /api/environments/environment_id - DELETE - Destroy
environment with specified id
• /api/environments/all - DELETE - Destroy all environments
Infrastructure life cycle
• Create
• Check if the user is valid
• Parse the requested configurarion
• Generate unique environment name
• Trigger Ansible run
• Return environment name
• Destroy
• Check if requested environment exists
• Check if the user can destroy this environment
• Delete environment and clean everything up (DNS, ELB, etc.)
REST Service demo
• Create a set of instances
• Destroy them
Current UI :)
Ansible testing
• No way to test playbook without applying it
• Currently there’s a quick sanity test suite
• We do testing every commit for a selected number of stacks
Demo
• Stash
• Feature branches
• Ansible testing pipeline
Results
• 14-40 minutes to provision and fully configure environments
• From 1 stack to 10 stacks automated testing (~25 soon)
• We continuously improve to make a robust process
Continuous Delivery
without Production
Goals for Continuous Delivery
• Create a repeatable and robust process
• Treat all configurations identically
• Some are more important of course
• Provide feedback as soon as possible
• For now – in the morning
• Provide feedback for feature branches
• Release tested artifacts more frequently
• For now – every iteration
Stages for Continuous Delivery
• Components are built
• Unit and integration tests
• Main application is build and packaged
• Published to Artifactory and s3
• Testing pipeline is triggered
• Environments are created
• Sanity tests, API tests, Functional tests, etc. are run
• Notification is sent in case of any test failure
• Environments are disposed
Continuous Delivery diagram
Build
components
Package
Provision
Stack1
API Tests E2E Tests … Dispose
Provision
Stack 2
API Tests E2E Tests … Dispose
Provision
Stack 3
API Tests E2E Tests … Dispose
… … … … …
Provision
Stack 10
API Tests E2E Tests … Dispose
More pipelines…
• Performance tests pipeline
• Feature branches
• Security tests
• Earlier versions of the applications
• Bugfix releases
• More applications
Achievements
• Huge quality improvements
• Numerous bugs were found in the ‘rare’ stacks
• Regressions are found during the night
• Minimum cycle time is 1h 30m, maximum – 2h 30m
• Dozens environments are created every day
• Repeatable process allows to identify instabilities in tests and
configurations
Closing thoughts
Zero downtime deployments
Future
• Asynchronous provisioning
• Ansible roles?
• Optimization (time)
• Pre-baked images
• Docker containers
• Plugins to help our specific needs
Ansible v2
• Blocks
• begin
• rescue
• always
• Execution strategy – linear vs free (or anything else)
• Execution time include evaluation (with*)
• Better variable management
Key takeaways
• Use Ansible – it’s a great tool :)
• Think about immutable infrastructure
• Create repeatable and reliable process
for releasing software
• Build quality in
• Improve continuously
pavel@levi9.com
@PavelChunyayev
Any questions?

Contenu connexe

Tendances

Tendances (20)

CI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page AppsCI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page Apps
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Heroku
HerokuHeroku
Heroku
 
Manage your environment with DSC
Manage your environment with DSCManage your environment with DSC
Manage your environment with DSC
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
PP_Eric_Gandt
PP_Eric_GandtPP_Eric_Gandt
PP_Eric_Gandt
 
Infrastructure as Code
Infrastructure as CodeInfrastructure as Code
Infrastructure as Code
 
Continous integration and delivery for single page applications
Continous integration and delivery for single page applicationsContinous integration and delivery for single page applications
Continous integration and delivery for single page applications
 
NC Wisconsin SuperVMUG 2019 Tools and Tips
NC Wisconsin SuperVMUG 2019 Tools and TipsNC Wisconsin SuperVMUG 2019 Tools and Tips
NC Wisconsin SuperVMUG 2019 Tools and Tips
 
4 JVM Web Frameworks
4 JVM Web Frameworks4 JVM Web Frameworks
4 JVM Web Frameworks
 
User-percieved performance
User-percieved performanceUser-percieved performance
User-percieved performance
 
Five Years of EC2 Distilled
Five Years of EC2 DistilledFive Years of EC2 Distilled
Five Years of EC2 Distilled
 
Validating latest changes with XCI
Validating latest changes with XCIValidating latest changes with XCI
Validating latest changes with XCI
 
Serverless with Azure Functions
Serverless with Azure FunctionsServerless with Azure Functions
Serverless with Azure Functions
 
JustLetMeCode-Final
JustLetMeCode-FinalJustLetMeCode-Final
JustLetMeCode-Final
 
CI/CD with Azure DevOps and Azure Databricks
CI/CD with Azure DevOps and Azure DatabricksCI/CD with Azure DevOps and Azure Databricks
CI/CD with Azure DevOps and Azure Databricks
 
Developing Resilient Cloud Native Apps with Spring Cloud
Developing Resilient Cloud Native Apps with Spring CloudDeveloping Resilient Cloud Native Apps with Spring Cloud
Developing Resilient Cloud Native Apps with Spring Cloud
 
Top 10 PowerShell Features in Server 2012
Top 10 PowerShell Features in Server 2012Top 10 PowerShell Features in Server 2012
Top 10 PowerShell Features in Server 2012
 
Legacy Sins
Legacy SinsLegacy Sins
Legacy Sins
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's Guide
 

Similaire à Ansible benelux meetup - Amsterdam 27-5-2015

Automating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAutomating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps Approach
Akshaya Mahapatra
 

Similaire à Ansible benelux meetup - Amsterdam 27-5-2015 (20)

Splunk: Forward me the REST of those shells
Splunk: Forward me the REST of those shellsSplunk: Forward me the REST of those shells
Splunk: Forward me the REST of those shells
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performance
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Iac d.damyanov 4.pptx
Iac d.damyanov 4.pptxIac d.damyanov 4.pptx
Iac d.damyanov 4.pptx
 
Cloud Platforms for Java
Cloud Platforms for JavaCloud Platforms for Java
Cloud Platforms for Java
 
[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
 
Managing Infrastructure as Code
Managing Infrastructure as CodeManaging Infrastructure as Code
Managing Infrastructure as Code
 
Hosting Ruby Web Apps
Hosting Ruby Web AppsHosting Ruby Web Apps
Hosting Ruby Web Apps
 
Docker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukDocker based Architecture by Denys Serdiuk
Docker based Architecture by Denys Serdiuk
 
Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)
 
Automating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAutomating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps Approach
 
Local development environment evolution
Local development environment evolutionLocal development environment evolution
Local development environment evolution
 
To Build My Own Cloud with Blackjack…
To Build My Own Cloud with Blackjack…To Build My Own Cloud with Blackjack…
To Build My Own Cloud with Blackjack…
 
ITB2017 - Keynote
ITB2017 - KeynoteITB2017 - Keynote
ITB2017 - Keynote
 
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
 
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfO365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
 

Plus de Pavel Chunyayev

Plus de Pavel Chunyayev (10)

Experiment and validate business ideas - Talk outline at DevOps Showcase Amst...
Experiment and validate business ideas - Talk outline at DevOps Showcase Amst...Experiment and validate business ideas - Talk outline at DevOps Showcase Amst...
Experiment and validate business ideas - Talk outline at DevOps Showcase Amst...
 
Lifecycle of a microservices application - Iasi, Levi9 meetup - 28-6-2017
Lifecycle of a microservices application - Iasi, Levi9 meetup - 28-6-2017Lifecycle of a microservices application - Iasi, Levi9 meetup - 28-6-2017
Lifecycle of a microservices application - Iasi, Levi9 meetup - 28-6-2017
 
#nostaging - Software Circus - Amsterdam, 2-9-2016
#nostaging - Software Circus - Amsterdam, 2-9-2016#nostaging - Software Circus - Amsterdam, 2-9-2016
#nostaging - Software Circus - Amsterdam, 2-9-2016
 
Continuous Feedback from Testing - Continuous Delivery meetup - Amsterdam, 14...
Continuous Feedback from Testing - Continuous Delivery meetup - Amsterdam, 14...Continuous Feedback from Testing - Continuous Delivery meetup - Amsterdam, 14...
Continuous Feedback from Testing - Continuous Delivery meetup - Amsterdam, 14...
 
Lean part of DevOps - DevOps Amsterdam meetup - 17-8-2016
Lean part of DevOps - DevOps Amsterdam meetup - 17-8-2016Lean part of DevOps - DevOps Amsterdam meetup - 17-8-2016
Lean part of DevOps - DevOps Amsterdam meetup - 17-8-2016
 
Want Continuous Delivery? Give testing a priority! 16-6-2016, Friss, Utrecht
Want Continuous Delivery? Give testing a priority! 16-6-2016, Friss, UtrechtWant Continuous Delivery? Give testing a priority! 16-6-2016, Friss, Utrecht
Want Continuous Delivery? Give testing a priority! 16-6-2016, Friss, Utrecht
 
Versioning schemes and branching models for Continuous Delivery - Continuous ...
Versioning schemes and branching models for Continuous Delivery - Continuous ...Versioning schemes and branching models for Continuous Delivery - Continuous ...
Versioning schemes and branching models for Continuous Delivery - Continuous ...
 
DevOpsDays Ignite - Immutable infrastructure - Amsterdam 24-5-2015
DevOpsDays Ignite - Immutable infrastructure - Amsterdam 24-5-2015DevOpsDays Ignite - Immutable infrastructure - Amsterdam 24-5-2015
DevOpsDays Ignite - Immutable infrastructure - Amsterdam 24-5-2015
 
Arch9 - A cloud based continuous delivery implementation
Arch9 - A cloud based continuous delivery implementationArch9 - A cloud based continuous delivery implementation
Arch9 - A cloud based continuous delivery implementation
 
State of continuous delivery in 2015 - Minsk 15-5-2015
State of continuous delivery in 2015 - Minsk 15-5-2015State of continuous delivery in 2015 - Minsk 15-5-2015
State of continuous delivery in 2015 - Minsk 15-5-2015
 

Dernier

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Dernier (20)

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

Ansible benelux meetup - Amsterdam 27-5-2015

  • 1. How Ansible helps Backbase Ansible Benelux meetup Pavel Chunyayev Amsterdam, 27-5-2015
  • 2. Who am I • Come from Ukraine • 11 years in IT • Worked in Ukraine, Estonia and the Netherlands • Continuous Delivery architect at Levi9 IT Services • Last 6 months - Automation architect at Backbase
  • 4. Backbase Customer Experience Platform • Core services • Content services • Publication services • 3 environments – Editorial, Staging, Live
  • 5. Different configuration options • Java version • Application Server • RDBMS • HTTP/HTTPS • Internal configuration options • Optional application features
  • 6. A lot of things are already automated • There are servers for released CXP version • With different configurations • They can be started/stopped when needed • Newest version of the application needs to be deployed. • In most cases manually. • For some configurations deployment required repackaging of the application. • Automated through maven • There is a sandbox environment with the nightly build • Deployed automatically • Far from production setup
  • 7. Handcrafted servers • Hard to maintain • Very time/cost sensitive • Setup is not easily reproducible • May be buggy • It should take less time to rebuild a server from the scratch than to log in and fix/update it.
  • 10. Why Ansible • Python powered • No master, agentless • Free, open source • Plenty of modules (batteries included) • Great EC2 support • Windows support (kind of) • Parallel, but controllable execution • Quite simple for developer to understand
  • 11. Why REST service • Create infrastructure easily • Just send JSON formatted configuration • Service will analyze it and trigger Ansible run • Service is the single point of contact for any infrastructure requests • Can be integrated into any CI, script, application or other service
  • 12. Why UI • Everyone needs to create an environment from time to time • Opening a ticket and then waiting is not an option • In most situations environments are required for a short period of time. • Self-service
  • 13. Demo • Directory structure • Flow of work • Decision tree
  • 14. Ansible features we are using • Handlers • Variables • Jinja2 templates • Facts • Conditions • Playbook includes • Inventory (fake) – hostgroups! • Roles :(
  • 15. ec2 ec2: key_name: '{{ keypair }}' group_id: '{{ security_group }}' instance_type: '{{ instance }}' image: '{{ image }}' region: '{{ region }}' vpc_subnet_id: '{{ subnet }}' user_data: "{{ item }}" instance_profile_name: 'access-to-s3' instance_tags: origin: "{{ origin }}" environment_name: "{{ environment_name }}" stack_id: "{{ stack_id }}" owner_id: "{{ owner_id }} " role: "{{ item }}" timestamp: "{{ timestamp }}" with_items: server_roles register: ec2
  • 16. Facts - name: Set the facts and hostnames hosts: all_hosts connection: ssh gather_facts: True max_fail_percentage: 0 tasks: - name: Gather EC2 facts ec2_facts: - name: Set environment fact set_fact: this_environment="{{ ansible_ec2_user_data }}" - name: Set hostnames hostname: name="{{ environment_name }}-{{ this_environment }}"
  • 17. route53 route53: command: create zone: backbase.dev private_zone: yes overwrite: yes record: "{{ environment_name }}-{{ item.0 }}.backbase.dev" type: A ttl: 10 value: "{{ item.1.instances[0].private_ip }}" with_together: - server_roles - ec2.results register: r53_result until: r53_result|success retries: 20 delay: "{{ 10 |random }}"
  • 18. Jinja2 templates {% block portal_db %}{% endblock %} {% if http_or_https == 'http' %} {% set port = http_port %} {% else %} {% set port = https_port %} {% endif %} {% if this_environment == "editorial" %} foundation.environment.editorial=true {% else %} foundation.environment.editorial=false {% endif %} foundation.content.proxy.destination={{ http_or_https }}://{{ environment_name }}-{{ this_environment }}.backbase.dev:{{ port }}/contentservices
  • 19. wait_for - name: Start WSLC shell: /opt/IBM/Websphere/INIT.websphere start {{ this_environment }} - name: Wait for WSLC to start wait_for: path=“/opt/IBM/Websphere/usr/servers/{{ this_environment }}/logs/console.log” search_regex=“The server {{ this_environment }} is ready to run a smarter planet.” timeout=30" - name: Run the trigger shell: /opt/install/app_start_trigger.sh &> /opt/install/app_start_trigger.log; sleep 2 - name: Wait for all apps to start wait_for: path="/opt/IBM/Websphere/usr/servers/{{ this_environment }}/logs/messages.log" search_regex="SRVE0242I: [portalserver] [/portalserver] [/WEB-INF/index.jsp]: Initialization successful." timeout=600
  • 20. Recovering from failure - name: Download CXP shell: s3cmd get s3://s3_bucket_here/Backbase_Portal_5.6.0-{{ version }}.zip /opt/install/portal-package-5.6.0-{{ version }}.zip --force 2>&1 | tee /opt/install/direct_loader.log register: cxp_download_sleeper until: cxp_download_sleeper.stdout.find("saved as") != -1 retries: 10 delay: "{{ 10 | random }}"
  • 21. API • /api/stacks - GET - List stacks available for provisioning • /api/stacks/stack_name - GET - List the stack configuration • /api/environments - GET - List all currently provisioned environments • /api/stacks/stack_name - POST - Provision specified stack • /api/environments/environment_id - DELETE - Destroy environment with specified id • /api/environments/all - DELETE - Destroy all environments
  • 22. Infrastructure life cycle • Create • Check if the user is valid • Parse the requested configurarion • Generate unique environment name • Trigger Ansible run • Return environment name • Destroy • Check if requested environment exists • Check if the user can destroy this environment • Delete environment and clean everything up (DNS, ELB, etc.)
  • 23. REST Service demo • Create a set of instances • Destroy them
  • 25. Ansible testing • No way to test playbook without applying it • Currently there’s a quick sanity test suite • We do testing every commit for a selected number of stacks
  • 26. Demo • Stash • Feature branches • Ansible testing pipeline
  • 27. Results • 14-40 minutes to provision and fully configure environments • From 1 stack to 10 stacks automated testing (~25 soon) • We continuously improve to make a robust process
  • 29. Goals for Continuous Delivery • Create a repeatable and robust process • Treat all configurations identically • Some are more important of course • Provide feedback as soon as possible • For now – in the morning • Provide feedback for feature branches • Release tested artifacts more frequently • For now – every iteration
  • 30. Stages for Continuous Delivery • Components are built • Unit and integration tests • Main application is build and packaged • Published to Artifactory and s3 • Testing pipeline is triggered • Environments are created • Sanity tests, API tests, Functional tests, etc. are run • Notification is sent in case of any test failure • Environments are disposed
  • 31. Continuous Delivery diagram Build components Package Provision Stack1 API Tests E2E Tests … Dispose Provision Stack 2 API Tests E2E Tests … Dispose Provision Stack 3 API Tests E2E Tests … Dispose … … … … … Provision Stack 10 API Tests E2E Tests … Dispose
  • 32. More pipelines… • Performance tests pipeline • Feature branches • Security tests • Earlier versions of the applications • Bugfix releases • More applications
  • 33. Achievements • Huge quality improvements • Numerous bugs were found in the ‘rare’ stacks • Regressions are found during the night • Minimum cycle time is 1h 30m, maximum – 2h 30m • Dozens environments are created every day • Repeatable process allows to identify instabilities in tests and configurations
  • 36. Future • Asynchronous provisioning • Ansible roles? • Optimization (time) • Pre-baked images • Docker containers • Plugins to help our specific needs
  • 37. Ansible v2 • Blocks • begin • rescue • always • Execution strategy – linear vs free (or anything else) • Execution time include evaluation (with*) • Better variable management
  • 38. Key takeaways • Use Ansible – it’s a great tool :) • Think about immutable infrastructure • Create repeatable and reliable process for releasing software • Build quality in • Improve continuously pavel@levi9.com @PavelChunyayev Any questions?