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

What's hot (20)

PDF
Packer
Diego Pacheco
 
PPTX
Automation with Packer and TerraForm
Wesley Charles Blake
 
ODP
Puppet and CloudStack
ke4qqq
 
PDF
Using Ansible for Deploying to Cloud Environments
ahamilton55
 
PPTX
Ansible - Crash course
Simone Soldateschi
 
PPTX
Ansible fest Presentation slides
Aaron Carey
 
ODP
Puppet and the HashiCorp Suite
Bram Vogelaar
 
ODP
Infrastructure as code with Puppet and Apache CloudStack
ke4qqq
 
PPTX
Cyansible
Alan Norton
 
PDF
Ansible Meetup Hamburg / Quickstart
Henry Stamerjohann
 
PPT
Tips for a Faster Website
Rayed Alrashed
 
PDF
Automating CloudStack with Puppet - David Nalley
Puppet
 
PDF
(2016-06-11) Packer: Make Multi-Platform Images
garrett honeycutt
 
PDF
Rapid Infrastructure Provisioning
Uchit Vyas ☁
 
KEY
Node.js
Mat Schaffer
 
PDF
Ansible roles done right
Dan Vaida
 
PPTX
Packer
Nitesh Saini
 
PDF
Ansible 2 and Ansible Galaxy 2
Jeff Geerling
 
PDF
Ansible is the simplest way to automate. MoldCamp, 2015
Alex S
 
PDF
Ansible for beginners ...?
shirou wakayama
 
Automation with Packer and TerraForm
Wesley Charles Blake
 
Puppet and CloudStack
ke4qqq
 
Using Ansible for Deploying to Cloud Environments
ahamilton55
 
Ansible - Crash course
Simone Soldateschi
 
Ansible fest Presentation slides
Aaron Carey
 
Puppet and the HashiCorp Suite
Bram Vogelaar
 
Infrastructure as code with Puppet and Apache CloudStack
ke4qqq
 
Cyansible
Alan Norton
 
Ansible Meetup Hamburg / Quickstart
Henry Stamerjohann
 
Tips for a Faster Website
Rayed Alrashed
 
Automating CloudStack with Puppet - David Nalley
Puppet
 
(2016-06-11) Packer: Make Multi-Platform Images
garrett honeycutt
 
Rapid Infrastructure Provisioning
Uchit Vyas ☁
 
Node.js
Mat Schaffer
 
Ansible roles done right
Dan Vaida
 
Packer
Nitesh Saini
 
Ansible 2 and Ansible Galaxy 2
Jeff Geerling
 
Ansible is the simplest way to automate. MoldCamp, 2015
Alex S
 
Ansible for beginners ...?
shirou wakayama
 

Similar to Usecase examples of Packer (20)

PDF
Large-scaled Deploy Over 100 Servers in 3 Minutes
Hiroshi SHIBATA
 
PDF
Advanced technic for OS upgrading in 3 minutes
Hiroshi SHIBATA
 
PDF
Padrino - the Godfather of Sinatra
Stoyan Zhekov
 
PDF
PDXPortland - Dockerize Django
Hannes Hapke
 
PPTX
Lessons from Driverless AI going to Production
Sri Ambati
 
PPTX
Toolbox of a Ruby Team
Arto Artnik
 
ODP
Puppet and Apache CloudStack
Puppet
 
PDF
EC2 AMI Factory with Chef, Berkshelf, and Packer
George Miranda
 
PPTX
Amazon Web Services and Docker: from developing to production
Paolo latella
 
ODP
Puppetpreso
ke4qqq
 
PDF
Docker presentasjon java bin
Olve Hansen
 
PDF
Dependencies Managers in C/C++. Using stdcpp 2014
biicode
 
PDF
JBoss Developer Webinar: Cloud: BoxGrinder & SteamCannon
bobmcwhirter
 
PDF
Server-Side JavaScript Developement - Node.JS Quick Tour
q3boy
 
PDF
JUDCon 2010 Boston : BoxGrinder
marekgoldmann
 
PDF
Rapid Development With Docker Compose
Justin Crown
 
PPTX
Reactive summit 2020 microsoft orleans the easy way
John Azariah
 
PDF
Future of Development and Deployment using Docker
Tamer Abdul-Radi
 
PDF
Django dev-env-my-way
Robert Lujo
 
PPTX
Ansible: How to Get More Sleep and Require Less Coffee
Sarah Z
 
Large-scaled Deploy Over 100 Servers in 3 Minutes
Hiroshi SHIBATA
 
Advanced technic for OS upgrading in 3 minutes
Hiroshi SHIBATA
 
Padrino - the Godfather of Sinatra
Stoyan Zhekov
 
PDXPortland - Dockerize Django
Hannes Hapke
 
Lessons from Driverless AI going to Production
Sri Ambati
 
Toolbox of a Ruby Team
Arto Artnik
 
Puppet and Apache CloudStack
Puppet
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
George Miranda
 
Amazon Web Services and Docker: from developing to production
Paolo latella
 
Puppetpreso
ke4qqq
 
Docker presentasjon java bin
Olve Hansen
 
Dependencies Managers in C/C++. Using stdcpp 2014
biicode
 
JBoss Developer Webinar: Cloud: BoxGrinder & SteamCannon
bobmcwhirter
 
Server-Side JavaScript Developement - Node.JS Quick Tour
q3boy
 
JUDCon 2010 Boston : BoxGrinder
marekgoldmann
 
Rapid Development With Docker Compose
Justin Crown
 
Reactive summit 2020 microsoft orleans the easy way
John Azariah
 
Future of Development and Deployment using Docker
Tamer Abdul-Radi
 
Django dev-env-my-way
Robert Lujo
 
Ansible: How to Get More Sleep and Require Less Coffee
Sarah Z
 
Ad

More from Hiroshi SHIBATA (20)

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

Recently uploaded (20)

PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Per Axbom: The spectacular lies of maps
Nexer Digital
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PDF
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PPTX
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
PPTX
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PPTX
PCU Keynote at IEEE World Congress on Services 250710.pptx
Ramesh Jain
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PPTX
Using Google Data Studio (Looker Studio) to Create Effective and Easy Data Re...
Orage Technologies
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PPTX
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Per Axbom: The spectacular lies of maps
Nexer Digital
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PCU Keynote at IEEE World Congress on Services 250710.pptx
Ramesh Jain
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Using Google Data Studio (Looker Studio) to Create Effective and Easy Data Re...
Orage Technologies
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 

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