Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mind the Gap

Robb Kidd
April 17, 2014
92

Mind the Gap

Deploying an on-premises, multi-node product with chef on networks you don't control.

Robb Kidd

April 17, 2014
Tweet

Transcript

  1. View Slide

  2. Deploying in Unforgiving
    Environments
    (Control Your Dependencies)
    (the network is a dependency)

    View Slide

  3. /(robbkidd)/
    twitter.com/$1
    github.com/$1

    View Slide

  4. View Slide

  5. History

    View Slide

  6. Configker

    View Slide

  7. Chef-Server

    View Slide

  8. Chef-Solo

    View Slide

  9. Patterns for Getting Stuff
    on Your Servers

    View Slide

  10. remote_file

    View Slide

  11. The Essential remote_file
    remote_file "/opt/sauce/sauce_#{node[:sauce][:version]}.tgz" do
    source "#{node[:sauce][:url]}/awesome_sauce_#{node[:sauce][:version]}.tgz"
    end

    View Slide

  12. Better: Give It a Checksum
    remote_file "/opt/sauce/sauce_#{node[:sauce][:version]}.tgz" do
    source "#{node[:sauce][:url]}/awesome_sauce_#{node[:sauce][:version]}.tgz"
    * checksum node[:sauce][:checksum]
    end

    View Slide

  13. Ever Better: Put It in the Chef Cache
    # v-------------------------------v
    * remote_file "#{Chef::Config[:file_cache_path]}/sauce_#{node[:sauce][:version]}.tgz" do
    source "#{node[:sauce][:url]}/awesome_sauce_#{node[:sauce][:version]}.tgz"
    checksum node[:sauce][:checksum]
    end

    View Slide

  14. packaging

    View Slide

  15. fpm

    View Slide

  16. Example Packaging Step
    fpm -s dir \
    -t deb \
    --name awesome_sauce \
    --version "$(shell git describe --always --tag)" \
    --before-install ./etc/preinst.sh \
    --deb-upstart ./etc/saucy \
    --config-files /etc/saucy.yml \
    ./bin/saucy=/usr/bin/ \
    saucy.yml.sample=/etc/saucy/

    View Slide

  17. shelling out

    View Slide

  18. View Slide

  19. RVM
    4 custom RVM install ahead of chef-rvm
    4 install RVM via tarball according to the offline
    steps
    4 rvm mount ruby-version.tgz
    4 carry on with our uses of chev-rvm
    4 rvm-shell mostly

    View Slide

  20. View Slide

  21. View Slide

  22. python's default.rb
    include_recipe "python::#{node['python']['install_method']}"
    include_recipe "python::pip"
    include_recipe "python::virtualenv"

    View Slide

  23. python_shim.rb
    %w(python-pip python-virtualenv).each do |pkg|
    package pkg do
    action :install
    end
    end
    link "/usr/local/bin/pip" do
    to "/usr/bin/pip"
    end
    directory "/root/.pip/"
    file "/root/.pip/pip.conf" do
    content "[global]\ntimeout = 1\n"
    end

    View Slide

  24. Getting Stuff on Your Servers
    (Review)
    4 remote_file
    4 packages
    4 shelling out :(

    View Slide

  25. A Tale of Three Caches

    View Slide

  26. Library Cache

    View Slide

  27. bundle package
    (for ruby peeps)

    View Slide

  28. Package Cache

    View Slide

  29. View Slide

  30. apt-cacher-ng

    View Slide

  31. Chef Cache

    View Slide

  32. vagrant-cachier

    View Slide

  33. monkeypatch

    View Slide

  34. class ::Chef
    class Provider
    class RemoteFile
    class Content < Chef::FileContentManagement::ContentBase
    private
    def current_resource_matches_target_checksum?
    ::Chef::Log.info("Airgapped - skipping content checksum for #{@new_resource}")
    true
    end
    end
    end
    end
    end

    View Slide

  35. Mo' Better?
    (things I haven't got working yet)

    View Slide

  36. chef-client --local-mode

    View Slide

  37. Shim Cookbook
    AntiPattern?

    View Slide

  38. no 3rd party cookbooks?

    View Slide

  39. omnibus packages?

    View Slide

  40. containers?

    View Slide

  41. Shoulders of Giants
    Mark Olson - Lookingglass
    Eric Sproul - Circonus

    View Slide

  42. Review
    4 history
    4 recipe patterns
    4 caching tricks
    4 future possibilities

    View Slide

  43. Payoff
    4 works without access to network resources
    4 chef convergence is faster!
    4 chef convergence is predictable!

    View Slide

  44. 4 Mind the Gap photo by Clicsouris
    4 Vagrant - Mitchell Hashimoto/Hashicorp
    4 vagrant-cachier - Fabio Rehm
    4 fpm - Jordan Sissell
    4 knife-solo - Mat Schaffer

    View Slide