Skip to content

Commit

Permalink
Merge "Add --local option in chef deployer to deploy local changes wh…
Browse files Browse the repository at this point in the history
…en using chef to deploy bosh."
  • Loading branch information
lisbakke authored and Gerrit Code Review committed Mar 27, 2012
2 parents ce0f434 + f6dbc1a commit bd90eab
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
39 changes: 20 additions & 19 deletions chef_deployer/Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
chef_deployer (0.0.7)
chef_deployer (0.0.9)
chef
nats
net-scp
Expand All @@ -13,57 +13,58 @@ PATH
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
bunny (0.6.0)
chef (0.9.14)
chef (0.9.12)
bunny (>= 0.6.0)
erubis
extlib
highline
json (<= 1.4.6, >= 1.4.4)
json (>= 1.4.4, <= 1.4.6)
mixlib-authentication (>= 1.1.0)
mixlib-cli (>= 1.1.0)
mixlib-config (>= 1.1.2)
mixlib-log (>= 1.2.0)
moneta
ohai (>= 0.5.7)
rest-client (< 1.7.0, >= 1.0.4)
rest-client (>= 1.0.4, < 1.7.0)
uuidtools
daemons (1.1.2)
erubis (2.7.0)
daemons (1.1.8)
erubis (2.6.6)
abstract (>= 1.0.0)
eventmachine (0.12.10)
extlib (0.9.15)
highline (1.6.1)
highline (1.6.11)
json (1.4.6)
json_pure (1.5.1)
mime-types (1.16)
json_pure (1.6.5)
mime-types (1.17.2)
mixlib-authentication (1.1.4)
mixlib-log
mixlib-cli (1.2.0)
mixlib-config (1.1.2)
mixlib-log (1.3.0)
moneta (0.6.0)
nats (0.4.8)
nats (0.4.10)
daemons (>= 1.1.0)
eventmachine (>= 0.12.10)
json_pure (>= 1.5.1)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-ssh (2.1.4)
net-ssh-gateway (1.0.1)
net-ssh (2.2.2)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
ohai (0.5.8)
extlib
json (<= 1.4.6, >= 1.4.4)
ohai (0.6.10)
mixlib-cli
mixlib-config
mixlib-log
systemu
rest-client (1.6.1)
systemu (~> 2.2.0)
yajl-ruby
rest-client (1.6.3)
mime-types (>= 1.16)
systemu (1.2.0)
systemu (2.2.0)
thor (0.14.6)
uuidtools (2.1.2)
yajl-ruby (0.8.2)
yajl-ruby (1.1.0)

PLATFORMS
ruby
Expand Down
14 changes: 11 additions & 3 deletions chef_deployer/lib/chef_deployer.rb
Expand Up @@ -20,7 +20,7 @@ class Deploy < Thor
BASE_PATH = Dir.pwd
COOKBOOKS_PATH = File.join(BASE_PATH, "cookbooks")
SSH_WRAPPER = File.join(File.expand_path("../../bin", __FILE__), "chef_deployer_ssh_wrapper")
ENV['GIT_SSH'] = SSH_WRAPPER
ENV["GIT_SSH"] = SSH_WRAPPER

no_tasks do
def mask
Expand Down Expand Up @@ -149,9 +149,12 @@ def answer_ssh(command, password)
end
end

def update_remote_repo(repo, ssh_host, ssh_user, ssh_options)
def update_remote_repo(repo, options, ssh_host, ssh_user, ssh_options)
Net::SSH.start(ssh_host, ssh_user, ssh_options) do |ssh|
# git init is safe to run on an existing repo
if options.local
ssh.exec!("rm -rf #{@remote_repo_cache}")
end
ssh.exec!("mkdir -p #{@remote_repo_cache}/#{repo} && cd #{@remote_repo_cache}/#{repo} && git init --bare")
end

Expand Down Expand Up @@ -288,6 +291,7 @@ def connect(uri)
desc "deploy CLOUD", "deploy CLOUD"
method_option :roles, :type => :array
method_option :metadata, :type => :boolean, :default => true
method_option :local, :type => :boolean, :default => false
method_option :config, :type => :string, :default => "config.yml"
def deploy(cloud)
if File.directory?(cloud)
Expand Down Expand Up @@ -372,6 +376,10 @@ def deploy(cloud)
say_status :config, "reading repo configuration"
role_repo_mapping = {}
repo_config = YAML.load_file(File.join(BASE_PATH, "config", "repos.yml"))
if options.local
repo_config["bosh"]["uri"] = `pwd`.split("/")[0..-2].join("/")
repo_config["bosh"]["SCM"] = "NONE"
end
repo_config.each do |name, config|
required_repo = false
config["roles"].each do |role|
Expand All @@ -392,7 +400,7 @@ def deploy(cloud)
repos.each do |repo|
say_status :repos, "uploading #{repo} to #{host}"
connect(uri) do |*ssh_args|
update_remote_repo(repo, *ssh_args)
update_remote_repo(repo, options, *ssh_args)
end
end
end
Expand Down

0 comments on commit bd90eab

Please sign in to comment.