]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
bail `node init` on bad `apt-get update` (closes #3849)
authorelijah <elijah@riseup.net>
Tue, 13 May 2014 08:52:58 +0000 (01:52 -0700)
committerelijah <elijah@riseup.net>
Tue, 13 May 2014 08:52:58 +0000 (01:52 -0700)
lib/leap_cli/log.rb
lib/leap_cli/remote/tasks.rb

index 69e9f67835a44a8ac2d4f4ae2a67001a733dd6de..f496b9aa0a42c04309f55af930418b28d0afebdd 100644 (file)
@@ -80,6 +80,7 @@ module LeapCli
       if title
         prefix_options = case title
           when :error     then ['error', :red, :bold]
+          when :fatal_error then ['fatal error', :red, :bold]
           when :warning   then ['warning:', :yellow, :bold]
           when :info      then ['info', :cyan, :bold]
           when :updated   then ['updated', :cyan, :bold]
index 0a12a95d45c4cc89e071dac7aee2d90c7f576a26..e66b0a8a5987524e57a457c87786f72752e36daf 100644 (file)
@@ -30,12 +30,23 @@ task :install_insecure_vagrant_key, :max_hosts => MAX_HOSTS do
   end
 end
 
+BAD_APT_GET_UPDATE = /(BADSIG|NO_PUBKEY|KEYEXPIRED|REVKEYSIG|NODATA)/
+
 task :install_prerequisites, :max_hosts => MAX_HOSTS do
   apt_get = "DEBIAN_FRONTEND=noninteractive apt-get -q -y -o DPkg::Options::=--force-confold"
   leap.mkdirs LeapCli::PUPPET_DESTINATION
   run "echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen"
   leap.log :updating, "package list" do
-    run "apt-get update"
+    run "apt-get update" do |channel, stream, data|
+      # sadly exitcode is unreliable measure if apt-get update hit a failure.
+      if data =~ BAD_APT_GET_UPDATE
+        LeapCli::Util.bail! do
+          LeapCli::Util.log :fatal_error, "in `apt-get update`: #{data}", :host => channel[:host]
+        end
+      else
+        logger.log(1, data, channel[:host])
+      end
+    end
   end
   leap.log :updating, "server time" do
     run "( test -f /etc/init.d/ntp && /etc/init.d/ntp stop ) || true"