diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/leap_cli/commands/deploy.rb | 5 | ||||
-rw-r--r-- | lib/leap_cli/commands/test.rb | 10 | ||||
-rw-r--r-- | lib/leap_cli/logger.rb | 8 | ||||
-rw-r--r-- | lib/leap_cli/remote/leap_plugin.rb | 21 |
4 files changed, 40 insertions, 4 deletions
diff --git a/lib/leap_cli/commands/deploy.rb b/lib/leap_cli/commands/deploy.rb index 23af0f7..61323c9 100644 --- a/lib/leap_cli/commands/deploy.rb +++ b/lib/leap_cli/commands/deploy.rb @@ -39,6 +39,7 @@ module LeapCli ssh_connect(nodes, connect_options(options)) do |ssh| ssh.leap.log :checking, 'node' do + ssh.leap.check_for_no_deploy ssh.leap.assert_initialized end ssh.leap.log :synching, "configuration files" do @@ -94,13 +95,13 @@ module LeapCli def sync_puppet_files(ssh) ssh.rsync.update do |server| - ssh.leap.log(Path.platform + '/[bin,puppet] -> ' + server.host + ':' + LeapCli::PUPPET_DESTINATION) + ssh.leap.log(Path.platform + '/[bin,tests,puppet] -> ' + server.host + ':' + LeapCli::PUPPET_DESTINATION) { :dest => LeapCli::PUPPET_DESTINATION, :source => '.', :chdir => Path.platform, :excludes => '*', - :includes => ['/bin', '/bin/**', '/puppet', '/puppet/**'], + :includes => ['/bin', '/bin/**', '/puppet', '/puppet/**', '/tests', '/tests/**'], :flags => "-rlt --relative --delete --copy-links" } end diff --git a/lib/leap_cli/commands/test.rb b/lib/leap_cli/commands/test.rb index c240a70..7066241 100644 --- a/lib/leap_cli/commands/test.rb +++ b/lib/leap_cli/commands/test.rb @@ -12,7 +12,11 @@ module LeapCli; module Commands test.desc 'Run tests.' test.command :run do |run| run.action do |global_options,options,args| - log 'not yet implemented' + manager.filter!(args).each_node do |node| + ssh_connect(node) do |ssh| + ssh.run(test_cmd) + end + end end end @@ -21,6 +25,10 @@ module LeapCli; module Commands private + def test_cmd + "#{PUPPET_DESTINATION}/bin/run_tests" + end + # # generates a whole bunch of openvpn configs that can be used to connect to different openvpn gateways # diff --git a/lib/leap_cli/logger.rb b/lib/leap_cli/logger.rb index a496260..91fa22d 100644 --- a/lib/leap_cli/logger.rb +++ b/lib/leap_cli/logger.rb @@ -133,7 +133,13 @@ module LeapCli { :match => /^Syntax error/, :level => 0, :color => :red, :priority => -1, :exit => 1}, { :match => /^Cannot reassign variable/, :level => 0, :color => :red, :priority => -1, :exit => 1}, { :match => /^Could not find template/, :level => 0, :color => :red, :priority => -1, :exit => 1}, - { :match => /^Puppet apply complete.*fail/, :level => 0, :color => :red, :priority => -1, :exit => 1} + { :match => /^Puppet apply complete.*fail/, :level => 0, :color => :red, :priority => -1, :exit => 1}, + + # TESTS + { :match => /^PASS: /, :color => :green, :priority => -20}, + { :match => /^(FAIL|ERROR): /, :color => :red, :priority => -20}, + { :match => /^SKIP: /, :color => :yellow, :priority => -20} + ] def self.sorted_formatters diff --git a/lib/leap_cli/remote/leap_plugin.rb b/lib/leap_cli/remote/leap_plugin.rb index 04b1e2c..a284712 100644 --- a/lib/leap_cli/remote/leap_plugin.rb +++ b/lib/leap_cli/remote/leap_plugin.rb @@ -21,6 +21,9 @@ module LeapCli; module Remote; module LeapPlugin run dirs.collect{|dir| "mkdir -m 700 -p #{dir}; "}.join end + # + # echos "ok" if the node has been initialized and the required packages are installed, bails out otherwise. + # def assert_initialized begin test_initialized_file = "test -f #{INITIALIZED_FILE}" @@ -35,6 +38,24 @@ module LeapCli; module Remote; module LeapPlugin end end + # + # bails out the deploy if the file /etc/leap/no-deploy exists. + # This kind of sucks, because it would be better to skip over nodes that have no-deploy set instead + # halting the entire deploy. As far as I know, with capistrano, there is no way to close one of the + # ssh connections in the pool and make sure it gets no further commands. + # + def check_for_no_deploy + begin + run "test ! -f /etc/leap/no-deploy" + rescue Capistrano::CommandError => exc + LeapCli::Util.bail! do + exc.hosts.each do |host| + LeapCli::Util.log "Can't continue because file /etc/leap/no-deploy exists", :host => host + end + end + end + end + def mark_initialized run "touch #{INITIALIZED_FILE}" end |