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

Mind the Gap

Robb Kidd
April 17, 2014
100

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. Deploying in Unforgiving
    Environments
    (Control Your Dependencies)
    (the network is a dependency)

    View full-size slide

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

    View full-size slide

  3. Patterns for Getting Stuff
    on Your Servers

    View full-size slide

  4. 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 full-size slide

  5. 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 full-size slide

  6. 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 full-size slide

  7. 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 full-size slide

  8. shelling out

    View full-size slide

  9. 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 full-size slide

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

    View full-size slide

  11. 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 full-size slide

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

    View full-size slide

  13. A Tale of Three Caches

    View full-size slide

  14. Library Cache

    View full-size slide

  15. bundle package
    (for ruby peeps)

    View full-size slide

  16. Package Cache

    View full-size slide

  17. apt-cacher-ng

    View full-size slide

  18. vagrant-cachier

    View full-size slide

  19. 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 full-size slide

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

    View full-size slide

  21. chef-client --local-mode

    View full-size slide

  22. Shim Cookbook
    AntiPattern?

    View full-size slide

  23. no 3rd party cookbooks?

    View full-size slide

  24. omnibus packages?

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  28. 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 full-size slide