Application Automation with Habitat
Simon Fisher / Fletcher Nichol
Errno::EACCES: Permission denied - /home/-----
/#####/-----/vendor/bundle/ruby/1.9.1/cache/bundler
/home/-----/.rvm/rubies/ruby-1.9.3-
p551/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir'
/home/-----/.rvm/rubies/ruby-1.9.3-
p551/lib/ruby/1.9.1/fileutils.rb:247:in `fu_mkdir'
/home/-----/.rvm/rubies/ruby-1.9.3-
p551/lib/ruby/1.9.1/fileutils.rb:221:in `block (2
levels) in mkdir_p'
/home/-----/.rvm/rubies/ruby-1.9.3-
p551/lib/ruby/1.9.1/fileutils.rb:219:in
`reverse_each'
/home/-----/.rvm/rubies/ruby-1.9.3-
p551/lib/ruby/1.9.1/fileutils.rb:219:in `block in
mkdir_p'
include_recipe 'nginx::default’
template "#{node['dafne_online']['deploy_base']}/shared/config/nginx.conf" do
source 'nginx_conf.erb’
owner 'rails’
group 'admin’
mode '0644’
notifies :restart, 'service[nginx]’
end
deploy node['dafne_online']['deploy_base'] do
repository "https://#{node['dafne_online']['git_user']}:#{git_pw}@dafneonline.git.cloudforge.com/dafneonline.git" rollback_on_error true
environment rails_user_env
restart_command 'sudo -H -u rails bash -c "export PATH=/opt/rubies/2.2.3/bin:$PATH && /etc/init.d/unicorn_dafneonline restart"’
action :deploy symlinks shared_hash
user node['dafne_online']['deploy_user']
group 'admin’
before_symlink do
execute 'bundle install' do
command "bundle install --path #{node['dafne_online']['deploy_base']}/shared/bundle --without development test --deployment --quiet”
user node['dafne_online']['deploy_user']
environment rails_user_env
cwd release_path
action :run
end
end
before_restart do
link '/etc/init.d/unicorn_dafneonline' do
to '/home/rails/apps/dafneonline/current/config/unicorn_init.sh’
end
template "#{node['dafne_online']['deploy_base']}/current/config/unicorn.rb" do
source 'unicorn.rb.erb' owner node['dafne_online']['deploy_user']
group 'admin’
mode 00744
end
execute 'compile assets' do
command "RAILS_ENV=#{node['dafne_online']['rails_env']} bundle exec rake assets:precompile”
user node['dafne_online']['deploy_user']
environment rails_user_env
cwd release_path
action :run
end
end
after_restart do
execute 'notify Airbrake of deployment' do
command "RAILS_ENV=#{node['dafne_online']['rails_env']} bundle exec rake airbrake:deploy TO=#{node['dafne_online']['rails_env']} REVISION=
REPO=https://dafneonline.git.cloudforge.com/dafneonline.git USER=#{node['dafne_online']['deploy_user']}”
environment rails_user_env
user node['dafne_online']['deploy_user']
cwd release_path
action :run
end
end
end
9
Habitat Technology
Plan Artifact Depot
Build
Service
Supervis
or
Supervis
or
Supervis
or
Supervis
or
Ring
Bare Metal
Containers
AMI
VM
Depot
Build Service &
Workflow
Package Format Artifact Distribution
Server
Artifact Distribution
Server
Intelligent Run-Time Supervisor w/REST
API
Source
Code
Repo
Supervisor Supervisor
Stop!
Demo Time
What’s New?
Habitat features and updates post-launch 2016
Package Search from Command Line
$ hab pkg search hab-studio
core/hab-studio/0.10.0/20160929200453
core/hab-studio/0.10.0/20160929200924
core/hab-studio/0.10.1/20160929223112
core/hab-studio/0.10.2/20160930230930
core/hab-studio/0.6.0/20160612082608
core/hab-studio/0.6.0/20160613075329
core/hab-studio/0.7.0/20160614232531
core/hab-studio/0.8.0/20160708162421
core/hab-studio/0.8.0/20160729121901
core/hab-studio/0.8.0/20160729180228
core/hab-studio/0.8.0/20160729195909
core/hab-studio/0.9.0/20160815225526
core/hab-studio/0.9.1/20160901205418
core/hab-studio/0.9.3/20160916192516
core/hab-studio/0.9.3/20160922234920
core/hab-studio/0.9.3/20160926154214
Improved Proxy Support
• Supports $http_proxy, $https_proxy, $no_proxy environment
variables
• Basic authentication
• Propagate into Studios
Iterate Service Configurations Quicker
using
–config-from
• Faster iteration of configuration templates during plan
development
• $ hab start yourorigin/yourpackage --config-from /path/to/config
• Intended only for development
Improved Root/Non-Root Behavior via
sudo
• Drop the need to prefix most hab commands with sudo
• Entering a Studio with sudo detects user’s key cache (not
root’s)
• $ hab setup; sudo hab studio enter
• Future release will “auto-sudo” when using Studio
subcommands
Better Mac Docker/Studio Upgrading
• Mac uses a Docker image for Linux Studio
• Runs Docker image with same version as hab CLI
• On upgrading hab CLI, new Docker image automatically pulled
Process: Release Train Model
• Userland tooling: hab CLI, Supervisor, Director
• Every second Thursday, cut from master
• Typically a minor version revision
• Features ship when ready and early features will hide behind
feature flags
Process: (Upcoming) Continuous
Deployment
• Platform infrastructure: web site, Depot, Builder
• Packages built off master and published to Depot
• Platform upgrades when new packages publish
• Decoupled release from userland tooling
Builder: A Distributed Build Service
• Micro service architecture, built with Habitat in mind
• Habitat runs on Habitat
• Upcoming: early access to build a package on the platform via
feature flag/invite
• Upcoming: building packages on pushes to GitHub
• Upcoming: dependent package rebuilding
• More details: “Habitat 301: Building Habitats” ChefConf 2016
Talk by Jamie Winsor
Expanding Horizons: Windows
• Bring Mac Habitat experience to Windows
• Building hab CLI
• Upcoming: ship first hab packages for Windows
• Upcoming: native Windows Habitat packages
• Upcoming: Supervisor running on Windows
Contribute to “Habtoberfest”!
• Habitat participating in Digital Ocean’s Hacktoberfest event
• Runs October 1st through 31st
• Make 4 pull requests (on any FOSS project), earn a limited
edition Hacktoberfest T-shirt
• Habitat repo has “Hacktoberfest” tagged issues
• http://hacktoberfest.digitalocean.com
Help Shape the Direction of Habitat
• Try out Habitat https://www.habitat.sh/try/
• Build a package
• Try out use cases, contact us when: you win, you come up
short, (i.e. anytime)
• Join us in HabiChat http://slack.habitat.sh/
• We’re at a Community Summit—let’s talk!

London Community Summit 2016 - Habitat

  • 1.
    Application Automation withHabitat Simon Fisher / Fletcher Nichol
  • 4.
    Errno::EACCES: Permission denied- /home/----- /#####/-----/vendor/bundle/ruby/1.9.1/cache/bundler /home/-----/.rvm/rubies/ruby-1.9.3- p551/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir' /home/-----/.rvm/rubies/ruby-1.9.3- p551/lib/ruby/1.9.1/fileutils.rb:247:in `fu_mkdir' /home/-----/.rvm/rubies/ruby-1.9.3- p551/lib/ruby/1.9.1/fileutils.rb:221:in `block (2 levels) in mkdir_p' /home/-----/.rvm/rubies/ruby-1.9.3- p551/lib/ruby/1.9.1/fileutils.rb:219:in `reverse_each' /home/-----/.rvm/rubies/ruby-1.9.3- p551/lib/ruby/1.9.1/fileutils.rb:219:in `block in mkdir_p'
  • 7.
    include_recipe 'nginx::default’ template "#{node['dafne_online']['deploy_base']}/shared/config/nginx.conf"do source 'nginx_conf.erb’ owner 'rails’ group 'admin’ mode '0644’ notifies :restart, 'service[nginx]’ end
  • 8.
    deploy node['dafne_online']['deploy_base'] do repository"https://#{node['dafne_online']['git_user']}:#{git_pw}@dafneonline.git.cloudforge.com/dafneonline.git" rollback_on_error true environment rails_user_env restart_command 'sudo -H -u rails bash -c "export PATH=/opt/rubies/2.2.3/bin:$PATH && /etc/init.d/unicorn_dafneonline restart"’ action :deploy symlinks shared_hash user node['dafne_online']['deploy_user'] group 'admin’ before_symlink do execute 'bundle install' do command "bundle install --path #{node['dafne_online']['deploy_base']}/shared/bundle --without development test --deployment --quiet” user node['dafne_online']['deploy_user'] environment rails_user_env cwd release_path action :run end end before_restart do link '/etc/init.d/unicorn_dafneonline' do to '/home/rails/apps/dafneonline/current/config/unicorn_init.sh’ end template "#{node['dafne_online']['deploy_base']}/current/config/unicorn.rb" do source 'unicorn.rb.erb' owner node['dafne_online']['deploy_user'] group 'admin’ mode 00744 end execute 'compile assets' do command "RAILS_ENV=#{node['dafne_online']['rails_env']} bundle exec rake assets:precompile” user node['dafne_online']['deploy_user'] environment rails_user_env cwd release_path action :run end end after_restart do execute 'notify Airbrake of deployment' do command "RAILS_ENV=#{node['dafne_online']['rails_env']} bundle exec rake airbrake:deploy TO=#{node['dafne_online']['rails_env']} REVISION= REPO=https://dafneonline.git.cloudforge.com/dafneonline.git USER=#{node['dafne_online']['deploy_user']}” environment rails_user_env user node['dafne_online']['deploy_user'] cwd release_path action :run end end end
  • 9.
  • 10.
    Habitat Technology Plan ArtifactDepot Build Service Supervis or Supervis or Supervis or Supervis or Ring Bare Metal Containers AMI VM Depot Build Service & Workflow Package Format Artifact Distribution Server Artifact Distribution Server Intelligent Run-Time Supervisor w/REST API Source Code Repo Supervisor Supervisor
  • 11.
  • 12.
    What’s New? Habitat featuresand updates post-launch 2016
  • 13.
    Package Search fromCommand Line $ hab pkg search hab-studio core/hab-studio/0.10.0/20160929200453 core/hab-studio/0.10.0/20160929200924 core/hab-studio/0.10.1/20160929223112 core/hab-studio/0.10.2/20160930230930 core/hab-studio/0.6.0/20160612082608 core/hab-studio/0.6.0/20160613075329 core/hab-studio/0.7.0/20160614232531 core/hab-studio/0.8.0/20160708162421 core/hab-studio/0.8.0/20160729121901 core/hab-studio/0.8.0/20160729180228 core/hab-studio/0.8.0/20160729195909 core/hab-studio/0.9.0/20160815225526 core/hab-studio/0.9.1/20160901205418 core/hab-studio/0.9.3/20160916192516 core/hab-studio/0.9.3/20160922234920 core/hab-studio/0.9.3/20160926154214
  • 14.
    Improved Proxy Support •Supports $http_proxy, $https_proxy, $no_proxy environment variables • Basic authentication • Propagate into Studios
  • 15.
    Iterate Service ConfigurationsQuicker using –config-from • Faster iteration of configuration templates during plan development • $ hab start yourorigin/yourpackage --config-from /path/to/config • Intended only for development
  • 16.
    Improved Root/Non-Root Behaviorvia sudo • Drop the need to prefix most hab commands with sudo • Entering a Studio with sudo detects user’s key cache (not root’s) • $ hab setup; sudo hab studio enter • Future release will “auto-sudo” when using Studio subcommands
  • 17.
    Better Mac Docker/StudioUpgrading • Mac uses a Docker image for Linux Studio • Runs Docker image with same version as hab CLI • On upgrading hab CLI, new Docker image automatically pulled
  • 18.
    Process: Release TrainModel • Userland tooling: hab CLI, Supervisor, Director • Every second Thursday, cut from master • Typically a minor version revision • Features ship when ready and early features will hide behind feature flags
  • 19.
    Process: (Upcoming) Continuous Deployment •Platform infrastructure: web site, Depot, Builder • Packages built off master and published to Depot • Platform upgrades when new packages publish • Decoupled release from userland tooling
  • 20.
    Builder: A DistributedBuild Service • Micro service architecture, built with Habitat in mind • Habitat runs on Habitat • Upcoming: early access to build a package on the platform via feature flag/invite • Upcoming: building packages on pushes to GitHub • Upcoming: dependent package rebuilding • More details: “Habitat 301: Building Habitats” ChefConf 2016 Talk by Jamie Winsor
  • 21.
    Expanding Horizons: Windows •Bring Mac Habitat experience to Windows • Building hab CLI • Upcoming: ship first hab packages for Windows • Upcoming: native Windows Habitat packages • Upcoming: Supervisor running on Windows
  • 22.
    Contribute to “Habtoberfest”! •Habitat participating in Digital Ocean’s Hacktoberfest event • Runs October 1st through 31st • Make 4 pull requests (on any FOSS project), earn a limited edition Hacktoberfest T-shirt • Habitat repo has “Hacktoberfest” tagged issues • http://hacktoberfest.digitalocean.com
  • 23.
    Help Shape theDirection of Habitat • Try out Habitat https://www.habitat.sh/try/ • Build a package • Try out use cases, contact us when: you win, you come up short, (i.e. anytime) • Join us in HabiChat http://slack.habitat.sh/ • We’re at a Community Summit—let’s talk!

Editor's Notes

  • #11 And that’s basically how it comes together. You, as a user, make plans that get turned into artifacts that are accessible via a depot. Supervisors then pick up and run those artifacts on a variety of platforms and are equipped to make decisions about how they’re configured as they are starting up their child process (i.e. at runtime). Your applications can act autonomously and are equipped to make decisions about how they manage and update themselves. They intercommunicate securely and the supervisors all constantly watch, update, and share the status of the entire cluster with each other. Bam! That’s how Habitat works.