SlideShare a Scribd company logo
Usecase examples of Packer
the best tools for os image creation
self.introduce
=>
{
name: “SHIBATA Hiroshi”,
nickname: “hsbt”,
title: “Chief engineer at GMO Pepabo, Inc.”,
commit_bits: [“ruby”, “rake”, “rubygems”, “rdoc”, “tdiary”,
“hiki”, “railsgirls”, “railsgirls-jp”, “jenkins”],
sites: [“ruby-lang.org”, “rubyci.com”, “railsgirls.com”,
“railsgirls.jp”],
}
Do scale-out
Our service issue
Do scale-out
Do scale-out with automation!
Do scale-out with rapid automation!!!
Do scale-out with extremely rapid automation!!!!!1
Concerns of bootstrap time
Typical scenario of server set-up for scale out.
• OS boot
• OS Configuration
• Provisioning with puppet/chef
• Setting up to capistrano
• Deploy rails application
• Added load balancer (= Service in)
Concerns of bootstrap time
Slow operation
• OS boot
• Provisioning with puppet/chef
• Deploy rails application
Fast operation
• OS Configuration
• Setting up to capistrano
• Added load balancer (=
Service in)
Check point of Image creation
Slow operation
• OS boot
• Provisioning with puppet/chef
• Deploy rails application
Fast operation
• OS Configuration
• Setting up to capistrano
• Added load balancer (=
Service in)
Step1
Step2
2 phase strategy
• Official OS image
• Provided from platform like AWS, Azure, GCP, OpenStack…
• Minimal image(phase 1)
• Network, User, Package configuration
• Installed puppet/chef and platform cli-tools.
• Role specified(phase 2)
• Only boot OS and Rails application
Tuning tools(cloud-init)
We only use OS configuration. Do not use “run_cmd”
#cloud-config
repo_update: true
repo_upgrade: none
packages:
- git
- curl
- unzip
users:
- default
locale: ja_JP.UTF-8
timezone: Asia/Tokyo
Before packer age
We use IaaS API for image creation with cloud-init userdata.
We can create OS Image using cloud-init and provisioned puppet
when boot time of instance.
puppet agent -t
rm -rf /var/lib/cloud/sem /var/lib/cloud/instances/*
aws ec2 create-image --instance-id `cat /var/lib/cloud/data/instance-id` --name
www_base_`date +%Y%m%d%H%M`
After packer age
I couldn’t understand use-case of packer. Is it Provision tool?
Deployment tool?
We created cli tool with thor
We can run packer over thor code with advanced options.
$ some_cli_tool ami build-minimal
$ some_cli_tool ami build-www
$ some_cli_tool ami build-www —init
$ some_cli_tool ami build-www -a ami-id
module SomeCliTool
class Ami < Thor
method_option :ami_id, type: :string, aliases: "-a"
method_option :init, type: :boolean
desc 'build-www', 'wwwの最新イメージをビルドします'
def build_www
…
end
end
end
inside image creation with Packer
• Packer configuration
• JSON format
• select instance size, block volume,
• cloud-init
• Basic configuration of OS
• only default module of cloud-init
• provisioner
• shell script :)
minimal image
cloud-init provisioner
#cloud-config
repo_update: true
repo_upgrade: none
packages:
- git
- curl
- unzip
users:
- default
locale: ja_JP.UTF-8
timezone: Asia/Tokyo
rpm -ivh http://yum.puppetlabs.com/
puppetlabs-release-el-7.noarch.rpm
yum -y update
yum -y install puppet
yum -y install python-pip
pip install awscli
sed -i 's/name: centos/name: cloud-user/' /etc/
cloud/cloud.cfg
echo 'preserve_hostname: true' >> /etc/cloud/
cloud.cfg
www image
cloud-init provisioner
#cloud-config
preserve_hostname: false
puppet agent -t
set -e
monit stop unicorn
/usr/local/bin/globefish -w
rm -rf /var/www/deploys/minne/releases/*
rm -f /var/www/deploys/minne/current
# tar xf するだけで動くRails アプリケーションを取得
(snip)
# mackerel のホスト設定が packer 実行時のものとかぶらないように初期化
rm /var/lib/mackerel-agent/id
# cloud-init をもう一度動かすようにする準備
rm -rf /var/lib/cloud/sem /var/lib/cloud/instances/*
We can scale out with one command via our cli tool
One more thing…
scale out with cli command
$ some_cli_tool mackerel fixrole
$ some_cli_tool scale up
$ some_cli_tool deploy blue-green
$ some_cli_tool instances launch -c 10 …
Integration tests with Packer
We can tests results of Packer running. (Impl by @udzura)
"provisioners": [
(snip)
{
"type": "shell",
"script": "{{user `project_root`}}packer/minimal/provisioners/run-serverspec.sh",
"execute_command": "{{ .Vars }} sudo -E sh '{{ .Path }}'"
}
]
yum -y -q install rubygem-bundler
cd /tmp/serverspec
bundle install --path vendor/bundle
bundle exec rake spec
packer configuration
run-serverspec.sh
Next step of image creation with packer
• Automated all of test with image creation and launching
• Fail over with fragile API status
• Sync deployment with image creation
Appendix
Working
• vagrant + openstack plugin
• packer + openstack builder
• consul + consul-alerts
• nginx + consul-templates
Evaluating
• vault
• terraform
http://pepabo.com/recruit/career/
To be continued
I will full details of this talk at YAPC::Asia 2015

More Related Content

PDF
Rackspace Hack Night - Vagrant & Packer
PPTX
Baking in the cloud with packer and puppet
PPTX
Packer, where DevOps begins
PDF
Service Delivery Assembly Line with Vagrant, Packer, and Ansible
PPTX
Building Windows Images with Packer
PPTX
Introduction to Packer and Suitcase: A Packer-based OS Image Build System
PDF
A Introduction of Packer
PDF
OpenSource ToolChain for the Hybrid Cloud
Rackspace Hack Night - Vagrant & Packer
Baking in the cloud with packer and puppet
Packer, where DevOps begins
Service Delivery Assembly Line with Vagrant, Packer, and Ansible
Building Windows Images with Packer
Introduction to Packer and Suitcase: A Packer-based OS Image Build System
A Introduction of Packer
OpenSource ToolChain for the Hybrid Cloud

What's hot (20)

PDF
PPTX
Automation with Packer and TerraForm
ODP
Puppet and CloudStack
PDF
Using Ansible for Deploying to Cloud Environments
PPTX
Ansible - Crash course
PPTX
Ansible fest Presentation slides
ODP
Puppet and the HashiCorp Suite
ODP
Infrastructure as code with Puppet and Apache CloudStack
PPTX
Cyansible
PDF
Ansible Meetup Hamburg / Quickstart
PPT
Tips for a Faster Website
PDF
Automating CloudStack with Puppet - David Nalley
PDF
(2016-06-11) Packer: Make Multi-Platform Images
PDF
Rapid Infrastructure Provisioning
KEY
Node.js
PDF
Ansible roles done right
PPTX
Packer
PDF
Ansible 2 and Ansible Galaxy 2
PDF
Ansible is the simplest way to automate. MoldCamp, 2015
PDF
Ansible for beginners ...?
Automation with Packer and TerraForm
Puppet and CloudStack
Using Ansible for Deploying to Cloud Environments
Ansible - Crash course
Ansible fest Presentation slides
Puppet and the HashiCorp Suite
Infrastructure as code with Puppet and Apache CloudStack
Cyansible
Ansible Meetup Hamburg / Quickstart
Tips for a Faster Website
Automating CloudStack with Puppet - David Nalley
(2016-06-11) Packer: Make Multi-Platform Images
Rapid Infrastructure Provisioning
Node.js
Ansible roles done right
Packer
Ansible 2 and Ansible Galaxy 2
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible for beginners ...?
Ad

Similar to Usecase examples of Packer (20)

PDF
Large-scaled Deploy Over 100 Servers in 3 Minutes
PDF
PuppetCamp Nj 2015- Puppet/packer presentation
PDF
Aws + Puppet = Dynamic Scale
PDF
Packer by HashiCorp
PDF
AWS + Puppet = Dynamic Scale
PDF
Advanced technic for OS upgrading in 3 minutes
PDF
Chef vs. Puppet in the Cloud: How Telepictures and MoneySuperMarket Do It
PDF
Build automated Machine Images using Packer
ODP
Automated reproducible images on openstack using vagrant and packer
KEY
Puppet for Java developers - JavaZone NO 2012
PDF
Immutable AWS Deployments with Packer and Jenkins
KEY
Railsconf2011 deployment tips_for_slideshare
PDF
One-Man Ops
PPTX
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
PDF
20090514 Introducing Puppet To Sasag
KEY
From Dev to DevOps - FOSDEM 2012
PDF
From Dev to DevOps - Codemotion ES 2012
PPTX
Scaling Your App With Docker Swarm using Terraform, Packer on Openstack
PDF
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
PDF
Puppet Camp London 2014: Chasing AMI: baking Amazon machine images with Jenki...
Large-scaled Deploy Over 100 Servers in 3 Minutes
PuppetCamp Nj 2015- Puppet/packer presentation
Aws + Puppet = Dynamic Scale
Packer by HashiCorp
AWS + Puppet = Dynamic Scale
Advanced technic for OS upgrading in 3 minutes
Chef vs. Puppet in the Cloud: How Telepictures and MoneySuperMarket Do It
Build automated Machine Images using Packer
Automated reproducible images on openstack using vagrant and packer
Puppet for Java developers - JavaZone NO 2012
Immutable AWS Deployments with Packer and Jenkins
Railsconf2011 deployment tips_for_slideshare
One-Man Ops
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
20090514 Introducing Puppet To Sasag
From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - Codemotion ES 2012
Scaling Your App With Docker Swarm using Terraform, Packer on Openstack
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Puppet Camp London 2014: Chasing AMI: baking Amazon machine images with Jenki...
Ad

More from Hiroshi SHIBATA (20)

PDF
Introduction of Cybersecurity with Ruby at RedDotRubyConf 2024
PDF
Introduction of Cybersecurity with OSS at Code Europe 2024
PDF
Long journey of Ruby Standard library at RubyKaigi 2024
PDF
Long journey of Ruby standard library at RubyConf AU 2024
PDF
Deep dive into Ruby's require - RubyConf Taiwan 2023
PDF
How resolve Gem dependencies in your code?
PDF
How resolve Gem dependencies in your code?
PDF
Ruby コミッターと歩む Ruby を用いたプロダクト開発
PDF
Why ANDPAD commit Ruby and RubyKaigi?
PDF
RailsGirls から始める エンジニアリングはじめの一歩
PDF
How to develop the Standard Libraries of Ruby?
PDF
The details of CI/CD environment for Ruby
PDF
Dependency Resolution with Standard Libraries
PDF
Roadmap for RubyGems 4 and Bundler 3
PDF
The Future of library dependency management of Ruby
PDF
Ruby Security the Hard Way
PDF
OSS Security the hard way
PDF
The Future of library dependency manageement of Ruby
PDF
The Future of Dependency Management for Ruby
PDF
The Future of Bundled Bundler
Introduction of Cybersecurity with Ruby at RedDotRubyConf 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby standard library at RubyConf AU 2024
Deep dive into Ruby's require - RubyConf Taiwan 2023
How resolve Gem dependencies in your code?
How resolve Gem dependencies in your code?
Ruby コミッターと歩む Ruby を用いたプロダクト開発
Why ANDPAD commit Ruby and RubyKaigi?
RailsGirls から始める エンジニアリングはじめの一歩
How to develop the Standard Libraries of Ruby?
The details of CI/CD environment for Ruby
Dependency Resolution with Standard Libraries
Roadmap for RubyGems 4 and Bundler 3
The Future of library dependency management of Ruby
Ruby Security the Hard Way
OSS Security the hard way
The Future of library dependency manageement of Ruby
The Future of Dependency Management for Ruby
The Future of Bundled Bundler

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
cuic standard and advanced reporting.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPT
Teaching material agriculture food technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Cloud computing and distributed systems.
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Electronic commerce courselecture one. Pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Modernizing your data center with Dell and AMD
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Machine learning based COVID-19 study performance prediction
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
The AUB Centre for AI in Media Proposal.docx
cuic standard and advanced reporting.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Advanced methodologies resolving dimensionality complications for autism neur...
Teaching material agriculture food technology
Building Integrated photovoltaic BIPV_UPV.pdf
Cloud computing and distributed systems.
Digital-Transformation-Roadmap-for-Companies.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Network Security Unit 5.pdf for BCA BBA.
Electronic commerce courselecture one. Pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Modernizing your data center with Dell and AMD
“AI and Expert System Decision Support & Business Intelligence Systems”
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
MYSQL Presentation for SQL database connectivity
Encapsulation_ Review paper, used for researhc scholars
Machine learning based COVID-19 study performance prediction
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx

Usecase examples of Packer

  • 1. Usecase examples of Packer the best tools for os image creation
  • 2. self.introduce => { name: “SHIBATA Hiroshi”, nickname: “hsbt”, title: “Chief engineer at GMO Pepabo, Inc.”, commit_bits: [“ruby”, “rake”, “rubygems”, “rdoc”, “tdiary”, “hiki”, “railsgirls”, “railsgirls-jp”, “jenkins”], sites: [“ruby-lang.org”, “rubyci.com”, “railsgirls.com”, “railsgirls.jp”], }
  • 4. Our service issue Do scale-out Do scale-out with automation! Do scale-out with rapid automation!!! Do scale-out with extremely rapid automation!!!!!1
  • 5. Concerns of bootstrap time Typical scenario of server set-up for scale out. • OS boot • OS Configuration • Provisioning with puppet/chef • Setting up to capistrano • Deploy rails application • Added load balancer (= Service in)
  • 6. Concerns of bootstrap time Slow operation • OS boot • Provisioning with puppet/chef • Deploy rails application Fast operation • OS Configuration • Setting up to capistrano • Added load balancer (= Service in)
  • 7. Check point of Image creation Slow operation • OS boot • Provisioning with puppet/chef • Deploy rails application Fast operation • OS Configuration • Setting up to capistrano • Added load balancer (= Service in) Step1 Step2
  • 8. 2 phase strategy • Official OS image • Provided from platform like AWS, Azure, GCP, OpenStack… • Minimal image(phase 1) • Network, User, Package configuration • Installed puppet/chef and platform cli-tools. • Role specified(phase 2) • Only boot OS and Rails application
  • 9. Tuning tools(cloud-init) We only use OS configuration. Do not use “run_cmd” #cloud-config repo_update: true repo_upgrade: none packages: - git - curl - unzip users: - default locale: ja_JP.UTF-8 timezone: Asia/Tokyo
  • 10. Before packer age We use IaaS API for image creation with cloud-init userdata. We can create OS Image using cloud-init and provisioned puppet when boot time of instance. puppet agent -t rm -rf /var/lib/cloud/sem /var/lib/cloud/instances/* aws ec2 create-image --instance-id `cat /var/lib/cloud/data/instance-id` --name www_base_`date +%Y%m%d%H%M`
  • 11. After packer age I couldn’t understand use-case of packer. Is it Provision tool? Deployment tool?
  • 12. We created cli tool with thor We can run packer over thor code with advanced options. $ some_cli_tool ami build-minimal $ some_cli_tool ami build-www $ some_cli_tool ami build-www —init $ some_cli_tool ami build-www -a ami-id module SomeCliTool class Ami < Thor method_option :ami_id, type: :string, aliases: "-a" method_option :init, type: :boolean desc 'build-www', 'wwwの最新イメージをビルドします' def build_www … end end end
  • 13. inside image creation with Packer • Packer configuration • JSON format • select instance size, block volume, • cloud-init • Basic configuration of OS • only default module of cloud-init • provisioner • shell script :)
  • 14. minimal image cloud-init provisioner #cloud-config repo_update: true repo_upgrade: none packages: - git - curl - unzip users: - default locale: ja_JP.UTF-8 timezone: Asia/Tokyo rpm -ivh http://yum.puppetlabs.com/ puppetlabs-release-el-7.noarch.rpm yum -y update yum -y install puppet yum -y install python-pip pip install awscli sed -i 's/name: centos/name: cloud-user/' /etc/ cloud/cloud.cfg echo 'preserve_hostname: true' >> /etc/cloud/ cloud.cfg
  • 15. www image cloud-init provisioner #cloud-config preserve_hostname: false puppet agent -t set -e monit stop unicorn /usr/local/bin/globefish -w rm -rf /var/www/deploys/minne/releases/* rm -f /var/www/deploys/minne/current # tar xf するだけで動くRails アプリケーションを取得 (snip) # mackerel のホスト設定が packer 実行時のものとかぶらないように初期化 rm /var/lib/mackerel-agent/id # cloud-init をもう一度動かすようにする準備 rm -rf /var/lib/cloud/sem /var/lib/cloud/instances/*
  • 16. We can scale out with one command via our cli tool One more thing… scale out with cli command $ some_cli_tool mackerel fixrole $ some_cli_tool scale up $ some_cli_tool deploy blue-green $ some_cli_tool instances launch -c 10 …
  • 17. Integration tests with Packer We can tests results of Packer running. (Impl by @udzura) "provisioners": [ (snip) { "type": "shell", "script": "{{user `project_root`}}packer/minimal/provisioners/run-serverspec.sh", "execute_command": "{{ .Vars }} sudo -E sh '{{ .Path }}'" } ] yum -y -q install rubygem-bundler cd /tmp/serverspec bundle install --path vendor/bundle bundle exec rake spec packer configuration run-serverspec.sh
  • 18. Next step of image creation with packer • Automated all of test with image creation and launching • Fail over with fragile API status • Sync deployment with image creation
  • 19. Appendix Working • vagrant + openstack plugin • packer + openstack builder • consul + consul-alerts • nginx + consul-templates Evaluating • vault • terraform
  • 21. To be continued I will full details of this talk at YAPC::Asia 2015