SlideShare une entreprise Scribd logo
1  sur  46
Télécharger pour lire hors ligne
Ansible is the
simplest way to
automate.
Alexander Schedrov aka sanchiz
Team Lead, DevOps Engineer, FFW
MoldCamp 2015
Alexander Schedrov
aka sanchiz
Team Lead, DevOps Engineer,
FFW (ex ProPeople)
I love Open Source
I'm contributor to Open Source
That’s why I’m here
Ukraine, Kyiv
How it was earlier
Developers wrote code
SysAdmins deployed code and
configure servers
until one day… DevOps and Ansible
What is Ansible
Ansible is a radically simple IT
automation engine.
Ansible
• Clear - Ansible uses a simple syntax (YAML).
• Fast - Fast to learn and fast to set up.
• Complete - You have everything you need in one
complete package.
• Efficient - No extra software on your servers. Extensible
with modules on any programming language.
• Secure - Ansible uses SSH and requires no extra open
ports or daemons
Ansible vs Shell scripts
# Install the PGP key
gpg --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
gpg --armor --export 561F9B9CAC40B2F7 | apt-key add -
# Install https support for apt
apt-get install apt-transport-https -y
# Add the passenger apt repository
echo "deb https://oss-binaries.phusionpassenger.com/apt/passenger
raring main" > /etc/apt/sources.list.d/passenger.list
chown root: /etc/apt/sources.list.d/passenger.list
chmod 600 /etc/apt/sources.list.d/passenger.list
# Update the apt cache so we can use the new repo
apt-get update
# Install nginx
apt-get install nginx-full passenger -y
# Set up passenger in the nginx configuration
sed -i "s/# passenger_root/passenger_root/" /etc/nginx/nginx.conf
sed -i "s/# passenger_ruby/passenger_ruby/" /etc/nginx/nginx.conf
# Start nginx
service nginx restart
Shell script
---
- hosts: all
tasks:
- name: Ensure the PGP key is installed
apt_key: id=AC40B2F7 state=present url="http://keyserver.ubuntu.com/
pks/lookup?op=get&fingerprint=on&search=0x561F9B9CAC40B2F7"
- name: Ensure https support for apt is installed
apt: pkg=apt-transport-https state=present
- name: Ensure the passenger apt repository is added
apt_repository: state=present repo='deb https://oss-
binaries.phusionpassenger.com/apt/passenger raring main'
- name: Ensure nginx is installed
apt: pkg=nginx-full state=present
- name: Ensure passenger is installed
apt: pkg=passenger state=present update_cache=yes
- name: Ensure the nginx configuration file is set
copy: src=/app/config/nginx.conf dest=/etc/nginx/nginx.conf
- name: Ensure nginx is running
service: name=nginx state=started
Ansible script
Why do we love Ansible
• It perfectly fit into our infrastructure
• It has a lot of modules and roles
• Can easily be executed on multiple servers
• Popular system
Installation
sudo pip install ansible
*nix
Packages: python-pip and python-devel
Windows
• Cywgin
• PyYAML
• Jinja2
• …
https://servercheck.in/blog/running-ansible-within-windows
What next?
3 main shell commands
• ansible-doc [options] [module...]
• ansible-playbook playbook.yml [options]
• ansible <host-pattern> <command> [options]
Additional commands
• ansible-galaxy [init|info|install|list|remove] [--help] [options]
• ansible-lint playbook.yml [options]
• ansible-pull [options] [playbook.yml]
• ansible-vault [create|decrypt|edit|encrypt|rekey] [--help]
[options] file_name
Playbook
What is playbook
Ansible playbook it’s a list of commands or
roles that will be executed on remote or local
machine.
What is Ansible role
Ansible role is clean, reusable abstraction
that provides certain functionality.
---
- hosts: all
# Get facts about hosts(OS, user and so on)
gather_facts: no
remote_user: root
vars_prompt:
# Variables that need should be entered
vars:
# List of variables
var_files:
# List of files with variables
roles:
# List of roles that should be included
pre_tasks:
# List of pre-tasks
tasks:
# List of main tasks
post_tasks:
# List of post-tasks
handlers:
# List of handlers
Ansible task
- name: Install libraries
apt: pkg={{ item }} state=installed
with_items:
- git
- apache2
- php5
- php5-mysql
Comment/Documentation
Module
Item
Iterate through array
Run playbook on remote
machine
Host Guest
192.168.1.1 192.168.1.2
Playbook on host
192.168.1.2
Run playbook on local
machine
Host
192.168.1.1
Playbook on host
192.168.1.1
Inventory
# Group name
[localhost]
# Hosts in group
127.0.0.1
# Group name
[mysql_group]
# Hosts in group
mysqlserver.com
192.168.1.1
# Group vars
[mysql_group:vars]
ansible_ssh_user=root
ansible_ssh_port=2222
/etc/ansible/hosts or ./hosts
Requirements: connection by ssh without password.
Ansible uses
templates
Jinja2.
---
- host: lamp_local
vars:
vhost_core_path: “/var/www/site.dev"
domain: "site"
tasks:
- name: Add Apache virtualhost for development.
template:
src: "templates/vhost.dev.conf.j2"
dest: "/etc/apache2/sites-available/{{ domain }}.dev.conf"
owner: root
group: root
mode: 0644
vhost.dev.conf.j2
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName {{ domain }}.192.168.60.25.xip.io
ServerAlias www.{{ domain }}.192.168.60.25.xip.io
DocumentRoot {{ vhost_core_path }}
<Directory "{{ vhost_core_path }}">
Options FollowSymLinks Indexes
AllowOverride All
</Directory>
</VirtualHost>
Ansible keeps things
organized
Roles
---
- hosts: webservers
roles:
- jenkins
- webservers
roles/jenkins
Use includes
---
- hosts: mysql_group
sudo: yes
vars_files:
- solr_vars.yml
pre_tasks:
- include: pre_tasks.yml
tasks:
- { include: deploy.yml, user: admin, ssh_keys: [ 'keys/
one.txt', 'keys/two.txt' ] }
handlers:
- include: handlers/handlers.yml
Migrate to Ansible
Just run shell scripts through Ansible
- name: Deploy system module
sudo: yes
shell: /usr/bin/deploy -t -v --tags=system
Start from small changes
Where we use Ansible
1. Configuration management
and infrastructure orchestration
Apahce, MySQL,
PHP
Dev Test
ProdLocal developer's server
2. Deployments and builds
Our approach
• Code Driven Development
• Deployments and builds should be automated
• We should test each feature before merging into
master
• Everything that may be automated - should be
automated
Simple and efficient way
ansible-playbook [filename]
How do we generate builds
• GitHub Pull Requests to inject new features to
master branch
• Jenkins triggers ansible script within repo
• Ansible playbook download database from
production
• Ansible playbook apply changes to database
3. Provisioner for Vagrant
PUPHPET
One day our Vagrantbox is
died
Vagrant + Ansible = ♥
Provisioning. Vagrant.
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network :private_network, ip: "192.168.60.77"
config.vm.network :forwarded_port, host: 4567, guest: 80
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
end
end
Vagrantfile:
Meet the CIBox
https://github.com/propeoplemd/cibox
Kudos to @podarok,@ygerasimov, @m1r1k and other
contributors
CIBox uses Ansible for:
• Provisioning in CI server (Jenkins)
• Provisioning in Vagrantbox
• GitHub Pull Request builder
Conclusion
• Ansible is a promising technology
• Easy to start
• It solves 95% of our DevOps
problems
• Ansible is awesome and we love it
Thank you!
GitHub: https://github.com/Sanchiz
Blog: http://sanchiz.net
Email: alexander.schedrov@gmail.com
Twitter: @alexschedrov
Drupal.org: https://www.drupal.org/u/sanchiz

Contenu connexe

Tendances

Tendances (20)

DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
 
Configuration Management in Ansible
Configuration Management in Ansible Configuration Management in Ansible
Configuration Management in Ansible
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
Ansible - Crash course
Ansible - Crash courseAnsible - Crash course
Ansible - Crash course
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricks
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansible
 
Introducing Ansible
Introducing AnsibleIntroducing Ansible
Introducing Ansible
 
Ansible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / QuickstartAnsible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / Quickstart
 
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
Ansible for beginners
Ansible for beginnersAnsible for beginners
Ansible for beginners
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible reference
 
Ansible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David KarbanAnsible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David Karban
 
Ansible for beginners ...?
Ansible for beginners ...?Ansible for beginners ...?
Ansible for beginners ...?
 

En vedette

Introduction to puppet
Introduction to puppetIntroduction to puppet
Introduction to puppet
Habeeb Rahman
 

En vedette (18)

Ansible
AnsibleAnsible
Ansible
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction
 
DevOps in the Cloud with Microsoft Azure
DevOps in the Cloud with Microsoft AzureDevOps in the Cloud with Microsoft Azure
DevOps in the Cloud with Microsoft Azure
 
Using Groovy with Jenkins
Using Groovy with JenkinsUsing Groovy with Jenkins
Using Groovy with Jenkins
 
DevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & AnsibleDevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & Ansible
 
Chef Delivery
Chef DeliveryChef Delivery
Chef Delivery
 
Puppets
PuppetsPuppets
Puppets
 
Introduction to chef
Introduction to chefIntroduction to chef
Introduction to chef
 
Survey: Frozen Yogurt Market in India (2013)
Survey: Frozen Yogurt Market in India (2013)Survey: Frozen Yogurt Market in India (2013)
Survey: Frozen Yogurt Market in India (2013)
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation Workshop
 
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
 
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
 
STIG Compliance and Remediation with Ansible
STIG Compliance and Remediation with AnsibleSTIG Compliance and Remediation with Ansible
STIG Compliance and Remediation with Ansible
 
Puppet overview
Puppet overviewPuppet overview
Puppet overview
 
Infrastructure Automation with Chef
Infrastructure Automation with Chef Infrastructure Automation with Chef
Infrastructure Automation with Chef
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Introduction to puppet
Introduction to puppetIntroduction to puppet
Introduction to puppet
 
3 Steps to Expand DevOps and Automation Throughout the Enterprise
3 Steps to Expand DevOps and Automation Throughout the Enterprise3 Steps to Expand DevOps and Automation Throughout the Enterprise
3 Steps to Expand DevOps and Automation Throughout the Enterprise
 

Similaire à Ansible is the simplest way to automate. MoldCamp, 2015

Similaire à Ansible is the simplest way to automate. MoldCamp, 2015 (20)

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
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
 
Automating with Ansible
Automating with AnsibleAutomating with Ansible
Automating with Ansible
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
 
A tour of Ansible
A tour of AnsibleA tour of Ansible
A tour of Ansible
 
DevOps for database
DevOps for databaseDevOps for database
DevOps for database
 
Go Faster with Ansible (AWS meetup)
Go Faster with Ansible (AWS meetup)Go Faster with Ansible (AWS meetup)
Go Faster with Ansible (AWS meetup)
 
Automating complex infrastructures with Puppet
Automating complex infrastructures with PuppetAutomating complex infrastructures with Puppet
Automating complex infrastructures with Puppet
 
Ansible new paradigms for orchestration
Ansible new paradigms for orchestrationAnsible new paradigms for orchestration
Ansible new paradigms for orchestration
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. Ansible
 
Ansible Devops North East - slides
Ansible Devops North East - slides Ansible Devops North East - slides
Ansible Devops North East - slides
 
Security workflow with ansible
Security  workflow with ansibleSecurity  workflow with ansible
Security workflow with ansible
 
Deploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleDeploying Symfony2 app with Ansible
Deploying Symfony2 app with Ansible
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
 
Devops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShiftDevops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShift
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Automação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOpsAutomação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOps
 
Ansible with oci
Ansible with ociAnsible with oci
Ansible with oci
 
ansible_rhel.pdf
ansible_rhel.pdfansible_rhel.pdf
ansible_rhel.pdf
 

Plus de Alex S

Feeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds APIFeeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds API
Alex S
 

Plus de Alex S (11)

Scaling and sharing: Building custom drupal distributions for federated organ...
Scaling and sharing: Building custom drupal distributions for federated organ...Scaling and sharing: Building custom drupal distributions for federated organ...
Scaling and sharing: Building custom drupal distributions for federated organ...
 
Drupal Training Days 2017 - Drupal 8 basic functions.
Drupal Training Days 2017 - Drupal 8 basic functions.Drupal Training Days 2017 - Drupal 8 basic functions.
Drupal Training Days 2017 - Drupal 8 basic functions.
 
Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...
 
Drupal and diversity of Single sign-on systems
Drupal and diversity of Single sign-on systemsDrupal and diversity of Single sign-on systems
Drupal and diversity of Single sign-on systems
 
Getting started with Ansible. Be efficient.
Getting started with Ansible. Be efficient.Getting started with Ansible. Be efficient.
Getting started with Ansible. Be efficient.
 
Building mobile applications with DrupalGap
Building mobile applications with DrupalGapBuilding mobile applications with DrupalGap
Building mobile applications with DrupalGap
 
Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGap
 
Drush - use full power - DrupalCamp Donetsk 2014
Drush - use full power - DrupalCamp Donetsk 2014Drush - use full power - DrupalCamp Donetsk 2014
Drush - use full power - DrupalCamp Donetsk 2014
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...
 
Drush. Secrets come out.
Drush. Secrets come out.Drush. Secrets come out.
Drush. Secrets come out.
 
Feeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds APIFeeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds API
 

Dernier

FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
rknatarajan
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 

Dernier (20)

Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 

Ansible is the simplest way to automate. MoldCamp, 2015

  • 1. Ansible is the simplest way to automate. Alexander Schedrov aka sanchiz Team Lead, DevOps Engineer, FFW MoldCamp 2015
  • 2. Alexander Schedrov aka sanchiz Team Lead, DevOps Engineer, FFW (ex ProPeople) I love Open Source I'm contributor to Open Source That’s why I’m here Ukraine, Kyiv
  • 3. How it was earlier Developers wrote code SysAdmins deployed code and configure servers
  • 4. until one day… DevOps and Ansible
  • 5. What is Ansible Ansible is a radically simple IT automation engine.
  • 6. Ansible • Clear - Ansible uses a simple syntax (YAML). • Fast - Fast to learn and fast to set up. • Complete - You have everything you need in one complete package. • Efficient - No extra software on your servers. Extensible with modules on any programming language. • Secure - Ansible uses SSH and requires no extra open ports or daemons
  • 8. # Install the PGP key gpg --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7 gpg --armor --export 561F9B9CAC40B2F7 | apt-key add - # Install https support for apt apt-get install apt-transport-https -y # Add the passenger apt repository echo "deb https://oss-binaries.phusionpassenger.com/apt/passenger raring main" > /etc/apt/sources.list.d/passenger.list chown root: /etc/apt/sources.list.d/passenger.list chmod 600 /etc/apt/sources.list.d/passenger.list # Update the apt cache so we can use the new repo apt-get update # Install nginx apt-get install nginx-full passenger -y # Set up passenger in the nginx configuration sed -i "s/# passenger_root/passenger_root/" /etc/nginx/nginx.conf sed -i "s/# passenger_ruby/passenger_ruby/" /etc/nginx/nginx.conf # Start nginx service nginx restart Shell script
  • 9. --- - hosts: all tasks: - name: Ensure the PGP key is installed apt_key: id=AC40B2F7 state=present url="http://keyserver.ubuntu.com/ pks/lookup?op=get&fingerprint=on&search=0x561F9B9CAC40B2F7" - name: Ensure https support for apt is installed apt: pkg=apt-transport-https state=present - name: Ensure the passenger apt repository is added apt_repository: state=present repo='deb https://oss- binaries.phusionpassenger.com/apt/passenger raring main' - name: Ensure nginx is installed apt: pkg=nginx-full state=present - name: Ensure passenger is installed apt: pkg=passenger state=present update_cache=yes - name: Ensure the nginx configuration file is set copy: src=/app/config/nginx.conf dest=/etc/nginx/nginx.conf - name: Ensure nginx is running service: name=nginx state=started Ansible script
  • 10. Why do we love Ansible • It perfectly fit into our infrastructure • It has a lot of modules and roles • Can easily be executed on multiple servers • Popular system
  • 11. Installation sudo pip install ansible *nix Packages: python-pip and python-devel Windows • Cywgin • PyYAML • Jinja2 • … https://servercheck.in/blog/running-ansible-within-windows
  • 13. 3 main shell commands • ansible-doc [options] [module...] • ansible-playbook playbook.yml [options] • ansible <host-pattern> <command> [options]
  • 14. Additional commands • ansible-galaxy [init|info|install|list|remove] [--help] [options] • ansible-lint playbook.yml [options] • ansible-pull [options] [playbook.yml] • ansible-vault [create|decrypt|edit|encrypt|rekey] [--help] [options] file_name
  • 16. What is playbook Ansible playbook it’s a list of commands or roles that will be executed on remote or local machine.
  • 17. What is Ansible role Ansible role is clean, reusable abstraction that provides certain functionality.
  • 18. --- - hosts: all # Get facts about hosts(OS, user and so on) gather_facts: no remote_user: root vars_prompt: # Variables that need should be entered vars: # List of variables var_files: # List of files with variables roles: # List of roles that should be included pre_tasks: # List of pre-tasks tasks: # List of main tasks post_tasks: # List of post-tasks handlers: # List of handlers
  • 19. Ansible task - name: Install libraries apt: pkg={{ item }} state=installed with_items: - git - apache2 - php5 - php5-mysql Comment/Documentation Module Item Iterate through array
  • 20. Run playbook on remote machine Host Guest 192.168.1.1 192.168.1.2 Playbook on host 192.168.1.2
  • 21. Run playbook on local machine Host 192.168.1.1 Playbook on host 192.168.1.1
  • 22. Inventory # Group name [localhost] # Hosts in group 127.0.0.1 # Group name [mysql_group] # Hosts in group mysqlserver.com 192.168.1.1 # Group vars [mysql_group:vars] ansible_ssh_user=root ansible_ssh_port=2222 /etc/ansible/hosts or ./hosts Requirements: connection by ssh without password.
  • 24. --- - host: lamp_local vars: vhost_core_path: “/var/www/site.dev" domain: "site" tasks: - name: Add Apache virtualhost for development. template: src: "templates/vhost.dev.conf.j2" dest: "/etc/apache2/sites-available/{{ domain }}.dev.conf" owner: root group: root mode: 0644 vhost.dev.conf.j2 <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName {{ domain }}.192.168.60.25.xip.io ServerAlias www.{{ domain }}.192.168.60.25.xip.io DocumentRoot {{ vhost_core_path }} <Directory "{{ vhost_core_path }}"> Options FollowSymLinks Indexes AllowOverride All </Directory> </VirtualHost>
  • 26. Roles --- - hosts: webservers roles: - jenkins - webservers roles/jenkins
  • 27. Use includes --- - hosts: mysql_group sudo: yes vars_files: - solr_vars.yml pre_tasks: - include: pre_tasks.yml tasks: - { include: deploy.yml, user: admin, ssh_keys: [ 'keys/ one.txt', 'keys/two.txt' ] } handlers: - include: handlers/handlers.yml
  • 29. Just run shell scripts through Ansible - name: Deploy system module sudo: yes shell: /usr/bin/deploy -t -v --tags=system Start from small changes
  • 30. Where we use Ansible
  • 31. 1. Configuration management and infrastructure orchestration
  • 33.
  • 36. Our approach • Code Driven Development • Deployments and builds should be automated • We should test each feature before merging into master • Everything that may be automated - should be automated
  • 37. Simple and efficient way ansible-playbook [filename]
  • 38. How do we generate builds • GitHub Pull Requests to inject new features to master branch • Jenkins triggers ansible script within repo • Ansible playbook download database from production • Ansible playbook apply changes to database
  • 40. PUPHPET One day our Vagrantbox is died
  • 42. Provisioning. Vagrant. Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu/trusty64" config.vm.network :private_network, ip: "192.168.60.77" config.vm.network :forwarded_port, host: 4567, guest: 80 config.vm.provision "ansible" do |ansible| ansible.playbook = "playbook.yml" end end Vagrantfile:
  • 43. Meet the CIBox https://github.com/propeoplemd/cibox Kudos to @podarok,@ygerasimov, @m1r1k and other contributors
  • 44. CIBox uses Ansible for: • Provisioning in CI server (Jenkins) • Provisioning in Vagrantbox • GitHub Pull Request builder
  • 45. Conclusion • Ansible is a promising technology • Easy to start • It solves 95% of our DevOps problems • Ansible is awesome and we love it
  • 46. Thank you! GitHub: https://github.com/Sanchiz Blog: http://sanchiz.net Email: alexander.schedrov@gmail.com Twitter: @alexschedrov Drupal.org: https://www.drupal.org/u/sanchiz