Sha256: d5753a43cc5d5df98ac208fd35d1f092257d62140cd8f2cf803a7d501f399440

Contents?: true

Size: 1.8 KB

Versions: 3

Compression:

Stored size: 1.8 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' => %w(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

3 entries across 3 versions & 1 rubygems

Version Path
depengine-3.0.23 lib/depengine/helper/cli_helper.rb
depengine-3.0.22 lib/depengine/helper/cli_helper.rb
depengine-3.0.21 lib/depengine/helper/cli_helper.rb