Build and deployment

906 views

Published on

Published in: Software, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
906
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Build and deployment

  1. 1. Build & Deployment Pascal Robert Druide informatique
  2. 2. Git
  3. 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. 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. 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
  6. 6. Submodules • You could use Git submodules to build everything at the same time
  7. 7. Puppet
  8. 8. Puppet ? • Not about politicians, consumers or Metallica • Configuration management tool • Rapid deployment • Central point • Changes history • Standalone or client/server
  9. 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. 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. 11. Puppet tips • Use Git to store the configuration • Be modular • Use it!
  12. 12. Native Packages
  13. 13. Native packages • Deploy with natives packages! • Can mix it with Puppet or Chef • Deploy from a central repository or manually
  14. 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. 15. fpm • Ruby gem to create packages • .pkg/.deb/.rpm/Puppet! • Much more flexible than the Ant task
  16. 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. 17. Activating the app • Bundle a shell script inside the package • Use Puppet to install the package + restart the app
  18. 18. Puppet + RPM package { ‘SimpleBlog’: source => ‘http://myserver/storage/SimpleBlog-1.0-1.rpm', name => ‘SimpleBlog’, ensure => ‘installed’ } ! file { ‘wodeploy.py’: { source => ‘puppet:///modules/wotools/scripts/wodeploy.py', path => ‘/opt/bin/wodeploy.py’ } ! exec { ‘run-wodeploy’ command => ‘/opt/bin/wodeploy.py SimpleBlog’ }
  19. 19. wodeploy.py #!/usr/bin/python ! import json, urllib2, sys ! base_url = "http://mywotaskd:1085/cgi-bin/WebObjects/JavaMonitor.woa/ra/mApplications" app_name = sys.argv[1] ! stop_instance = True response = json.load(urllib2.urlopen(base_url + ".json?type=app&name=" + app_name)) if len(response) == 0: query = { 'id' : app_name, 'type' : 'MApplication', 'name' : app_name, 'unixOutputPath' : '/opt/Local/Library/WebObjects/Logs', 'unixPath' : '/opt/Local/Library/WebObjects/Applications/' + app_name + '.woa/' + app_name } query_as_json = json.dumps(query) request = urllib2.Request(base_url + ".json", query_as_json, {'Content-Type': 'application/json'}) response = urllib2.urlopen(request) stop_instance = False if stop_instance: urllib2.urlopen(base_url + "/" + app_name + "/stop") ! urllib2.urlopen(base_url + "/" + app_name + "/start")
  20. 20. Large distribution • Use a central repository • Use Puppet • … or both
  21. 21. Maven
  22. 22. Q&A

×