summaryrefslogtreecommitdiff
path: root/lib/leap_cli
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2015-02-08 13:01:19 -0800
committerelijah <elijah@riseup.net>2015-02-08 13:01:19 -0800
commit5130afca6ff1f5ec49b8abeaccfbe17dec129e32 (patch)
treec527c4ac1b15fda138d27b8a93db4eb770b1d104 /lib/leap_cli
parenta32c332963e3bca8ab4bd40b636d36a77468e219 (diff)
pass --info to puppet_command (needed to support logging deploy details)
Diffstat (limited to 'lib/leap_cli')
-rw-r--r--lib/leap_cli/commands/deploy.rb40
-rw-r--r--lib/leap_cli/logger.rb10
-rw-r--r--lib/leap_cli/remote/puppet_plugin.rb2
3 files changed, 39 insertions, 13 deletions
diff --git a/lib/leap_cli/commands/deploy.rb b/lib/leap_cli/commands/deploy.rb
index 204be5f..a0b7c20 100644
--- a/lib/leap_cli/commands/deploy.rb
+++ b/lib/leap_cli/commands/deploy.rb
@@ -1,3 +1,4 @@
+require 'etc'
module LeapCli
module Commands
@@ -7,20 +8,17 @@ module LeapCli
arg_name 'FILTER'
command [:deploy, :d] do |c|
- # --fast
c.switch :fast, :desc => 'Makes the deploy command faster by skipping some slow steps. A "fast" deploy can be used safely if you recently completed a normal deploy.',
:negatable => false
- # --sync
- c.switch :sync, :desc => "Sync files, but don't actually apply recipes."
+ c.switch :sync, :desc => "Sync files, but don't actually apply recipes.", :negatable => false
- # --force
c.switch :force, :desc => 'Deploy even if there is a lockfile.', :negatable => false
- # --dev
+ c.switch :downgrade, :desc => 'Allows deploy to run with an older platform version.', :negatable => false
+
c.switch :dev, :desc => "Development mode: don't run 'git submodule update' before deploy.", :negatable => false
- # --tags
c.flag :tags, :desc => 'Specify tags to pass through to puppet (overriding the default).',
:arg_name => 'TAG[,TAG]'
@@ -71,7 +69,12 @@ module LeapCli
end
unless options[:sync]
ssh.leap.log :applying, "puppet" do
- ssh.puppet.apply(:verbosity => [LeapCli.log_level,5].min, :tags => tags(options), :force => options[:force])
+ ssh.puppet.apply(:verbosity => [LeapCli.log_level,5].min,
+ :tags => tags(options),
+ :force => options[:force],
+ :info => deploy_info,
+ :downgrade => options[:downgrade]
+ )
end
end
end
@@ -297,5 +300,28 @@ module LeapCli
return custom_files
end
+ def deploy_info
+ info = []
+ info << "user: %s" % Etc.getpwuid(Process.euid).name
+ if is_git_directory?(Path.platform) && current_git_branch(Path.platform) != 'master'
+ info << "platform: %s (%s %s)" % [
+ Leap::Platform.version,
+ current_git_branch(Path.platform),
+ current_git_commit(Path.platform)[0..4]
+ ]
+ else
+ info << "platform: %s" % Leap::Platform.version
+ end
+ if is_git_directory?(LEAP_CLI_BASE_DIR)
+ info << "leap_cli: %s (%s %s)" % [
+ LeapCli::VERSION,
+ current_git_branch(LEAP_CLI_BASE_DIR),
+ current_git_commit(LEAP_CLI_BASE_DIR)[0..4]
+ ]
+ else
+ info << "leap_cli: %s" % LeapCli::VERSION
+ end
+ info.join(', ')
+ end
end
end
diff --git a/lib/leap_cli/logger.rb b/lib/leap_cli/logger.rb
index 3560d21..328dc27 100644
--- a/lib/leap_cli/logger.rb
+++ b/lib/leap_cli/logger.rb
@@ -113,8 +113,8 @@ module LeapCli
{ :match => /sh: .+: command not found/, :color => :magenta, :match_level => 1, :priority => -30 },
# IMPORTANT
- { :match => /^err ::/, :color => :red, :match_level => 0, :priority => -10 },
- { :match => /^ERROR:/, :color => :red, :match_level => 0, :priority => -10 },
+ { :match => /^err ::/, :color => :red, :match_level => 0, :priority => -10, :exit => 1},
+ { :match => /^ERROR:/, :color => :red, :priority => -10, :exit => 1},
{ :match => /.*/, :color => :blue, :match_level => 0, :priority => -20 },
# CLEANUP
@@ -136,8 +136,8 @@ module LeapCli
{ :match => /^warning:/, :level => 0, :color => :yellow, :priority => -20},
{ :match => /^Duplicate declaration:/, :level => 0, :color => :red, :priority => -20},
{ :match => /Finished catalog run/, :level => 0, :color => :green, :priority => -10},
- { :match => /^Puppet apply complete \(changes made\)/, :level => 0, :color => :green, :priority => -10},
- { :match => /^Puppet apply complete \(no changes\)/, :level => 0, :color => :green, :priority => -10},
+ { :match => /^APPLY COMPLETE \(changes made\)/, :level => 0, :color => :green, :priority => -10},
+ { :match => /^APPLY COMPLETE \(no changes\)/, :level => 0, :color => :green, :priority => -10},
# PUPPET FATAL ERRORS
{ :match => /^err:/, :level => 0, :color => :red, :priority => -1, :exit => 1},
@@ -146,7 +146,7 @@ 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 => /^APPLY COMPLETE.*fail/, :level => 0, :color => :red, :priority => -1, :exit => 1},
# TESTS
{ :match => /^PASS: /, :color => :green, :priority => -20},
diff --git a/lib/leap_cli/remote/puppet_plugin.rb b/lib/leap_cli/remote/puppet_plugin.rb
index e3f6be2..77bb4a3 100644
--- a/lib/leap_cli/remote/puppet_plugin.rb
+++ b/lib/leap_cli/remote/puppet_plugin.rb
@@ -18,7 +18,7 @@ module LeapCli; module Remote; module PuppetPlugin
elsif item[1] === true
str << "--" + item[0].to_s
else
- str << "--" + item[0].to_s + " " + item[1].to_s
+ str << "--" + item[0].to_s + " " + item[1].inspect
end
}.join(' ')
end