2. Goals
●
Pull deployment with Chef
●
Environments
●
More about Berkshelf+Vagrant way
●
Chef in real live - base_server
●
Exception/Report handlers
●
Debugging with Chef
●
Testing with Chef
4. Pull deployment with Chef
# http://community.opscode.com/cookbooks/application
application "my_app" do
path "/var/www"
repository "git://github.com/werdan/hpmor.git"
end
copy/paste from http://goo.gl/6sEYT5
5. Deployment with Chef - Plan
●
Application cookbook
(Berksfile/metadata.rb)
●
Application resource in default.rb
●
git installation
●
docroot correction
6. Capistrano way
●
●
●
●
Check your /var/www after chef-client run
/var/www/current is a symlink to one of
releases
/var/www/releases contains code
releases
/var/www/shared – anything that is not
kept in repository
8. Git flow
●
New release is ready for deployement
●
It is in 'develop' branch
●
●
Our current server is going to be now QA
testing
We should maintain the second server
(LIVE) with master branch deployed
9. Branch deployment with Chef
application "my_app" do
path "/var/www"
repository "git://github.com/werdan/hpmor.git"
revision 'your_branch' # specified with attribute
end
14. Environments: knife
knife environment from file production.rb
knife environment from file
development.rb
knife environment list
knife environment show production
15. Configuring DEV server
●
set environment to 'development'
> knife node edit your_node
> Chef Server GUI
●
●
run chef-client
check result in browser (is it in English
now?)
16. Branch deployment with Chef
application "my_app" do
path "/var/www"
repository "git://github.com/werdan/hpmor.git"
revision 'your_branch' # specified with attribute
end
17. Another PCI DSS failure
Go to http://YOUR_NODE_ADDRESS/icons/
20. We have to keep LIVE stable!
●
●
●
environments/production.rb
cookbook "webserver", "= 0.1.0"
webserver/metadata.rb
version '0.1.1'
upload cookbook
●
upload production environment
●
knife cookbook show webserver
25. Vagrant provision - chef-solo
●
No API (no databag search , for instance)
●
No cookbook version pin in environment
●
No persistent attributes (normal[..][..])
27. base_server
●
●
●
Create new cookbook with Berks
cd cookbooks
berks cookbook base_server
Add base_server to Berskfile
Include dependences on
apt, ntp, chef-client, cron, openssh
●
Include base_server to role[node] run_list
28. Recipes to include
base_server/recipes/default.rb
include_recipe "chef-client"
include_recipe "chef-client::delete_validation"
include_recipe "chef-client::config"
include_recipe "ntp"
include_recipe "cron"
include_recipe "apt"
include_recipe "openssh"
●
Bump minor cookbook version of 'base_server'
copy/paste from http://goo.gl/6sEYT5
30. chef_client
On node: ps ajx | grep chef-client
On workstation: knife status
NB! It is a good idea to establish internal procedure
to check knife status on regular basis
32. Exception handlers
●
Report about any exceptions in chef run
●
Many community handlers are available:
–
Airbrake
–
Email
–
Syslog
–
Graphite
–
HipChat