Click here to load reader

Build Chef development box from scratch

  • View
    227

  • Download
    4

Embed Size (px)

Text of Build Chef development box from scratch

Chef Development Boxwith Packer, Vagrant and Travis CIbuild chef-takeawayby Simone Soldateschi20150625

Who I amSenior DevOps Engineer, SydneyLead DevOps Team at Rackspace AU15 years of experience asSoftware EngSystems EngBeen DevOps'in for the last 5-ish years

Why

chef-takeaway

Enable developers, Automation Engineers and DevOps just use a box which works off-the-shelf

simplerepeatableversionedThings should be

Why?

SimpleJust 3 steps:git clone [email protected]:siso/chef-takeaway.git.vagrant upvagrant ssh -- -A

I lied ;)Just 3 steps:git clone [email protected]:siso/chef-takeaway.gitcd chef-takeawayvagrant upvagrant ssh -- -A

/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 # (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

Then, when, and not if, you get that...

vagrant destroy && vagrant upRepeatable

...fix it and restart easily.

Versioned

Need I to convince you that using GitHub is good idea?

What

Packer: easily build machine images for multiple platoform

Linuxyour favourite Linux distro

everything starts with a vanilla installation of a Linux distro of your choice

Provisioninginstall and configure all the things

Test it

Travis CI: Test it!

Share

Eventually share artifacts, machine images with the community and teammates

Run itmanage boxes easily

TDD

Kitchen CI and Docker

How

Build

Build

The machine build process is described in a JSON file

Build

variablesbuildersprovisionerpost-processor

The following stanzas will be used build the machine image

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},

Set up variables for the machine build task

"builders": [{"boot_command": ["","install ","preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-jessie.cfg ",...""],"disk_size": "{{user `disk_size`}}","guest_os_type": "Debian_64","headless": true,...Build

Packer types command, and interact with the installer on your behalf

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

Iteratively run provisioners, e.g. shell

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

Build

Iteratively run provisioners, e.g. Ansible

Build

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

Push and Test

Push changes to GitHubIt triggers the execution of TravisCI (.travis.yml)Result of CI job is displayed on GitHub repo

Share

SSH onto the Vagrant boxdevelop codetest with KitchenCIuse Docker for testing (faster!)

Recap

Simone Soldateschi

Search related