Sha256: 63267a48af499de67d07211f4b78354d1a82648ea91dcc0b92d3823463a93e5a

Contents?: true

Size: 1.79 KB

Versions: 7

Compression:

Stored size: 1.79 KB

Contents

module CLIHelper

  def setup_new_recipe(path)
    puts "Setting up a new deployment recipe in #{File.expand_path(path)}"
    require 'fileutils'
    require 'yaml'
    FileUtils.mkdir_p(File.expand_path(path))
    FileUtils.cd(File.expand_path(path))
    %w{cdb config recipe}.each {|d| FileUtils.mkdir_p d}
    %w{DEV PROD}.each do |env|
      FileUtils.mkdir_p "cdb/#{env}"
      File.open("cdb/#{env}.yaml","w") {|f| f.write env_yaml("DEV")}
      File.open("cdb/#{env}/demoapplication.yaml","w") {|f| f.write application_yaml}
    end
    FileUtils.touch("config/some_file_that_is_needed_for_the_deployment.jar")
    File.open("recipe/deploy.rb","w") {|f| f.write deploy_recipe_template}
    exit 0
  end

  def env_yaml(env)
    { 'env' => env,
      'projektname' => 'Demoproject',
      'remote_user' => 'szzdep'
    }.to_yaml
  end

  def application_yaml
    { 'taskname' => 'A demo applicaition deployment',
      'app_hosts' => ['appserv01', 'appserv02'],
      'deploy_path' => '/some/path/to/deploy/to/',
      'patch_properties' => {'test.message' => 'foo'}
    }.to_yaml
  end

  def deploy_recipe_template
    %{set :application_name,         "The Demo Application"
# The module_name is used to select the correct file from cdb/$env/
set :module_name,              "demoapplication"

set :log_level,                "INFO"
set :log_file,                 "deploy.log"
set :log_file_level,           "DEBUG"

Deployment.deliver do
  config = get_all_config_parameters

  config['app_hosts'].each do |host|
    $log.writer.info "Copying .war to \#{host}..."
    rsync("target/some_application.war", config['deploy_path'], :remote_host => host)
    $log.writer.info "Restarting app servers..."
    remote_execute("sudo /etc/init.d/appserver restart", :remote_host => host)
  end
  $log.writer.info "Done."
end
}
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
depengine-3.0.20 lib/depengine/helper/cli_helper.rb
depengine-3.0.19 lib/depengine/helper/cli_helper.rb
depengine-3.0.18 lib/depengine/helper/cli_helper.rb
depengine-3.0.17 lib/depengine/helper/cli_helper.rb
depengine-3.0.16 lib/depengine/helper/cli_helper.rb
depengine-3.0.15 lib/depengine/helper/cli_helper.rb
depengine-3.0.14 lib/depengine/helper/cli_helper.rb