Top Banner
Chef Development Box with Packer, Vagrant and Travis CI build chef-takeaway by Simone Soldateschi 20150625
35

Build Chef development box from scratch

Jan 20, 2017

Download

Internet

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Build Chef development box from scratch

Chef Development Boxwith Packer, Vagrant and Travis CI

build chef-takeaway

by Simone Soldateschi20150625

Page 2: Build Chef development box from scratch

Who I am● Senior DevOps Engineer, Sydney● Lead DevOps Team at Rackspace AU● 15 years of experience as

○ Software Eng○ Systems Eng○ Been DevOps'in for the last 5-ish years

Page 3: Build Chef development box from scratch

Why

Page 4: Build Chef development box from scratch

chef-takeaway

Page 5: Build Chef development box from scratch

● simple● repeatable● versioned

Things should be

Page 6: Build Chef development box from scratch

“Simple”Just 3 steps:● git clone [email protected]:siso/chef-takeaway.git● .● vagrant up● vagrant ssh -- -A

Page 7: Build Chef development box from scratch

I lied ;)Just 3 steps:● git clone [email protected]:siso/chef-takeaway.git● cd chef-takeaway● vagrant up● vagrant ssh -- -A

Page 8: Build Chef development box from scratch

…/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/gem_dependency.rb:119:in `requirement': undefined local variable or method `version_requirements' for #<Rails::GemDependency:0xb7181c78> (NameError)from /usr/local/lib/site_ruby/1.8/rubygems.rb:254:in `activate'from /usr/local/lib/site_ruby/1.8/rubygems.rb:1204:in `gem'from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/gem_dependency.rb:73:in `add_load_paths'from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:301:in `add_gem_load_paths'from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:301:in `each'from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:301:in `add_gem_load_paths'from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:132:in `process'from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `send'from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `run'from /home/user/application/config/environment.rb:19from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/commands/server.rb:84from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'from script/server:3...

“Repeatable”

Page 9: Build Chef development box from scratch

vagrant destroy && vagrant up

“Repeatable”

Page 10: Build Chef development box from scratch

“Versioned”

Page 11: Build Chef development box from scratch

What

Page 12: Build Chef development box from scratch
Page 13: Build Chef development box from scratch

Linux

your favourite Linux distro

Page 14: Build Chef development box from scratch

Provisioning

install and configure all the things

Page 15: Build Chef development box from scratch

Test it

Page 16: Build Chef development box from scratch

Share

Page 17: Build Chef development box from scratch

Run it

manage boxes easily

Page 18: Build Chef development box from scratch

TDD

Kitchen CI and Docker

Page 19: Build Chef development box from scratch

How

Page 20: Build Chef development box from scratch

Build

Page 21: Build Chef development box from scratch

Build

Page 22: Build Chef development box from scratch

Build● variables● builders● provisioner● post-processor

Page 23: Build Chef development box from scratch

Build"variables": {

"core": 1,"memory": 512,"disk_size": 10140,"ssh_port": 22,"ssh_wait_timeout": "10000s","iso_url": "http://cdimage.debian.org/debian-cd/8.0.0/amd64/iso-cd/debian-8.0.0-amd64-netinst.iso","iso_md5": "d9209f355449fe13db3963571b1f52d4","vm_name": "chef-takeaway","vm_version": "0.3.1”},

Page 24: Build Chef development box from scratch

"builders": [{

"boot_command": ["<esc><wait>","install <wait>","preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-jessie.cfg <wait>",..."<enter><wait>"],"disk_size": "{{user `disk_size`}}","guest_os_type": "Debian_64","headless": true,...

Build

Page 25: Build Chef development box from scratch

"provisioners": [{

"type": "shell","execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'","inline": [

"sleep 30"]},...

Build

Page 26: Build Chef development box from scratch

"provisioners": [...,{

"type": "ansible-local","pause_before": "5s","playbook_dir": "../ansible","playbook_file": "../ansible/main.yml","role_paths": ["../ansible"],"extra_arguments": ["-vvvv", "-u", "root"]},

Build

Page 27: Build Chef development box from scratch

Build"post-processors": [

{"type": "vagrant","output": "./{{.Provider}}/{{user `vm_name`}}-{{user `vm_version`}}.box"

}],

Page 28: Build Chef development box from scratch

Push and Test

Page 29: Build Chef development box from scratch
Page 30: Build Chef development box from scratch

Share

Page 31: Build Chef development box from scratch
Page 32: Build Chef development box from scratch

Recap

Page 33: Build Chef development box from scratch
Page 34: Build Chef development box from scratch
Page 35: Build Chef development box from scratch

Simone Soldateschi