Module: CLIHelper
- Defined in:
- lib/depengine/helper/cli_helper.rb
Instance Method Summary collapse
- #application_yaml ⇒ Object
- #deploy_recipe_template ⇒ Object
- #env_yaml(env) ⇒ Object
- #setup_new_recipe(path) ⇒ Object
Instance Method Details
#application_yaml ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/depengine/helper/cli_helper.rb', line 27 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 |
#deploy_recipe_template ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/depengine/helper/cli_helper.rb', line 35 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 |
#env_yaml(env) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/depengine/helper/cli_helper.rb', line 20 def env_yaml(env) { 'env' => env, 'projektname' => 'Demoproject', 'remote_user' => 'szzdep' }.to_yaml end |
#setup_new_recipe(path) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/depengine/helper/cli_helper.rb', line 3 def setup_new_recipe(path) puts "Setting up a new deployment recipe in #{File.(path)}" require 'fileutils' require 'yaml' FileUtils.mkdir_p(File.(path)) FileUtils.cd(File.(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 |