3. Git hooks
• Stored in .git/hooks
• Hooks can be anything runnable
• The useful ones: post-commit and post-receive
• post-receive will receive branch reference
4. Git and remote
• Push changes to each deployment server
• Have the post-receive script on each server
• … or use branches and central Git repo
5. post-receive examples
#!/bin/bash
!
while read oldrev newrev ref
do
if [[ $newrev == "0000000000000000000000000000000000000000" ]]; then
exit 0
fi
!
branch=`echo $ref | cut -d/ -f3`
umask 0022
!
if [ ! -d /tmp/SimpleBlog ]; then
git clone /Users/probert/SimpleBlog.git /tmp/SimpleBlog
fi
!
if [ $branch == "dev" ]; then
ant -lib /opt/woproject.jar install
fi
fi
8. Puppet ?
• Not about politicians, consumers or Metallica
• Configuration management tool
• Rapid deployment
• Central point
• Changes history
• Standalone or client/server
9. Puppet
• Puppet uses recipes (modules)
• Ruby-like declarative language
• Works on UNIX/Linux, OS X and Windows
• You can install packages, create user account, start services, etc.
10. Sample configuration
manifests/site.pp:
!
node server.wocommunity.org {
include wodeploy
}
!
modules/wodeploy/manifests/init.pp:
!
package { ‘apache’:
name => ‘httpd’,
ensure => present
}
!
service { ‘httpd’:
name => ‘httpd’,
ensure => running,
require => Package[‘apache’]
}
!
package { ‘wotaskd’:
name => ‘wotaskd’,
ensure => present
}
!
user { ‘appserver’:
name => ‘appserver’
ensure => present
}
11. Puppet tips
• Use Git to store the configuration
• Be modular
• Use it!
13. Native packages
• Deploy with natives packages!
• Can mix it with Puppet or Chef
• Deploy from a central repository or manually
14. Ant RPM task
• Build a RPM package for RedHat-based Linux
• Still need to write a SPEC file
• Use it only if you really like Ant
15. fpm
• Ruby gem to create packages
• .pkg/.deb/.rpm/Puppet!
• Much more flexible than the Ant task
16. fpm in two steps
• gem install fpm
• fpm --prefix /WOApps -a noarch —rpm-user _appserver --rpm-
os linux -t rpm -s dir -n SimpleBlog -v 1.0 SimpleBlog.woa
17. Activating the app
• Bundle a shell script inside the package
• Use Puppet to install the package + restart the app