From 23a7805fe29848a647b2ac5347a39c4188e869a8 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Thu, 12 Mar 2015 16:12:54 -0300 Subject: [PATCH] Use separate SSH configs per environment --- .gitignore | 2 +- Rakefile | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 2542e95..99d88bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /utils/obs/isv* /Gemfile.lock -/.ssh_config +/config/development/ssh_config /.tmp /tmp /docs/_build diff --git a/Rakefile b/Rakefile index cfbbfc6..49719ad 100644 --- a/Rakefile +++ b/Rakefile @@ -1,10 +1,17 @@ -require 'chake' - $SPB_ENV = ENV.fetch('SPB_ENV', 'development') +ssh_config_file = "config/#{$SPB_ENV}/ssh_config" ips_file = "config/#{$SPB_ENV}/ips.yaml" config_file = "config/#{$SPB_ENV}/config.yaml" +ENV['CHAKE_SSH_CONFIG'] = ssh_config_file + +require 'chake' + +if Chake::VERSION < '0.4' + fail "Please upgrade to chake 0.4+" +end + config = YAML.load_file(config_file) ips = YAML.load_file(ips_file) $nodes.each do |node| @@ -24,7 +31,7 @@ end task :default => :test file 'ssh_config.erb' -file '.ssh_config' => ['nodes.yaml', ips_file,'ssh_config.erb'] do |t| +file 'config/development/ssh_config' => ['nodes.yaml', 'config/development/ips.yaml', 'ssh_config.erb'] do |t| require 'erb' template = ERB.new(File.read('ssh_config.erb')) File.open(t.name, 'w') do |f| @@ -33,7 +40,7 @@ file '.ssh_config' => ['nodes.yaml', ips_file,'ssh_config.erb'] do |t| puts 'ERB %s' % t.name end -task :bootstrap_common => '.ssh_config' +task :bootstrap_common => 'config/development/ssh_config' unless ENV['nodeps'] task 'converge:integration' => 'converge:database' -- libgit2 0.21.2