lib/rubber/recipes/rubber/utils.rb in sml-rubber-0.9.9 vs lib/rubber/recipes/rubber/utils.rb in sml-rubber-0.9.10
- old
+ new
@@ -6,27 +6,27 @@
but you can specify a different default in rubber.yml:staging_roles
At the end, the instance will be up and running
e.g. RUBBER_ENV=matt cap create_staging
DESC
required_task :create_staging do
- if rubber_cfg.instance.size > 0
+ if rubber_instances.size > 0
value = Capistrano::CLI.ui.ask("The #{RUBBER_ENV} environment already has instances, Are you SURE you want to create a staging instance that may interact with them [y/N]?: ")
fatal("Exiting", 0) if value !~ /^y/
end
instance_alias = ENV['ALIAS'] = rubber.get_env("ALIAS", "Hostname to use for staging instance", true, RUBBER_ENV)
- default_roles = rubber_cfg.environment.bind().staging_roles || "*"
+ default_roles = rubber_env.staging_roles || "*"
roles = ENV['ROLES'] = rubber.get_env("ROLES", "Roles to use for staging instance", true, default_roles)
# some bootstraps update code (bootstrap_db) but if you don't have that role, need to do it here
# Since release directory variable gets reused by cap, we have to just do the symlink here - doing
# a update again will fail
set :rubber_code_was_updated, false
after "deploy:update_code" do
set :rubber_code_was_updated, true
end
- if rubber_cfg.instance[instance_alias]
+ if rubber_instances[instance_alias]
logger.info "Instance already exists, skipping to bootstrap"
else
rubber.create
end
rubber.bootstrap
@@ -132,11 +132,11 @@
end
end
def find_alias(ip, instance_id, do_connect=true)
if instance_id
- instance = rubber_cfg.instance.find {|i| i.instance_id == instance_id }
+ instance = rubber_instances.find {|i| i.instance_id == instance_id }
local_alias = instance.full_name if instance
end
local_alias ||= File.read("/etc/hosts").grep(/#{ip}/).first.split[1] rescue nil
if ! local_alias && do_connect
task :_get_ip, :hosts => ip do
@@ -148,12 +148,11 @@
end
def prepare_script(name, contents)
script = "/tmp/#{name}"
# this lets us abort a script if a command in the middle of it errors out
- env = rubber_cfg.environment.bind()
- contents = "#{env.stop_on_error_cmd}\n#{contents}" if env.stop_on_error_cmd
+ contents = "#{rubber_env.stop_on_error_cmd}\n#{contents}" if rubber_env.stop_on_error_cmd
put(contents, script)
return script
end
def run_script(name, contents)
@@ -186,10 +185,10 @@
# This is used to run capistrano tasks scoped to the correct role/host so that a config value
# specific to a role/host will only be used for that role/host, e.g. the list of packages to
# be installed.
def get_host_options(cfg_name, &block)
opts = {}
- rubber_cfg.instance.each do | ic|
+ rubber_instances.each do | ic|
env = rubber_cfg.environment.bind(ic.role_names, ic.name)
cfg_value = env[cfg_name]
if cfg_value
if block
cfg_value = block.call(cfg_value)
\ No newline at end of file