aboutsummaryrefslogtreecommitdiff
path: root/lib/leap_cli/commands/deploy.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-04-01 00:04:54 -0700
committerelijah <elijah@riseup.net>2013-04-01 00:04:54 -0700
commitb9a20186350a0315ee7159f2df2b55a47e9f90a4 (patch)
tree845b08feaa723a00d6dc7da26be68471fc4c7e1e /lib/leap_cli/commands/deploy.rb
parentc3f78c9df38f6e4dec94737863dcfcc1f4e60e96 (diff)
downloadleap_cli-b9a20186350a0315ee7159f2df2b55a47e9f90a4.tar.gz
leap_cli-b9a20186350a0315ee7159f2df2b55a47e9f90a4.tar.bz2
remove supply_drop, add support for puppet_command.
Diffstat (limited to 'lib/leap_cli/commands/deploy.rb')
-rw-r--r--lib/leap_cli/commands/deploy.rb62
1 files changed, 33 insertions, 29 deletions
diff --git a/lib/leap_cli/commands/deploy.rb b/lib/leap_cli/commands/deploy.rb
index 76df4fb..12e8294 100644
--- a/lib/leap_cli/commands/deploy.rb
+++ b/lib/leap_cli/commands/deploy.rb
@@ -2,8 +2,6 @@
module LeapCli
module Commands
- DEFAULT_TAGS = ['leap_base','leap_service']
-
desc 'Apply recipes to a node or set of nodes.'
long_desc 'The FILTER can be the name of a node, service, or tag.'
arg_name 'FILTER'
@@ -13,6 +11,9 @@ module LeapCli
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
+ # --force
+ c.switch :force, :desc => 'Deploy even if there is a lockfile.', :negatable => false
+
# --tags
c.flag :tags, :desc => 'Specify tags to pass through to puppet (overriding the default).',
:default_value => DEFAULT_TAGS.join(','), :arg_name => 'TAG[,TAG]'
@@ -34,37 +35,16 @@ module LeapCli
ssh.leap.log :checking, 'node' do
ssh.leap.assert_initialized
end
-
ssh.leap.log :synching, "configuration files" do
sync_hiera_config(ssh)
sync_support_files(ssh)
end
-
- # sync puppet manifests and apply them
- ssh.set :puppet_source, [Path.platform, 'puppet'].join('/')
- ssh.set :puppet_destination, '/srv/leap'
-
- # set tags
- if options[:tags]
- tags = options[:tags].split(',')
- else
- tags = DEFAULT_TAGS.dup
+ ssh.leap.log :synching, "puppet manifests" do
+ sync_puppet_files(ssh)
end
- tags << 'leap_slow' unless options[:fast]
-
- # set verbosity
- verbosity = case LeapCli.log_level
- when 3 then '--verbose'
- when 4 then '--verbose --debug'
- when 5 then '--verbose --debug --trace'
- else ''
+ ssh.leap.log :applying, "puppet" do
+ ssh.puppet.apply(:verbosity => LeapCli.log_level, :tags => tags(options), :force => options[:force])
end
-
- ssh.set :puppet_command, "/usr/bin/puppet apply --color=false --tags=#{tags.join(',')} --detailed-exitcodes #{verbosity}"
- ssh.set :puppet_lib, "puppet/modules"
- ssh.set :puppet_parameters, '--libdir puppet/lib --confdir puppet puppet/manifests/site.pp'
- ssh.set :puppet_stream_output, true
- ssh.apply_puppet
end
end
end
@@ -73,7 +53,7 @@ module LeapCli
def sync_hiera_config(ssh)
dest_dir = provider.hiera_sync_destination
- ssh.leap.rsync_update do |server|
+ ssh.rsync.update do |server|
node = manager.node(server.host)
hiera_file = Path.relative_path([:hiera, node.name])
ssh.leap.log hiera_file + ' -> ' + node.name + ':' + dest_dir + '/hiera.yaml'
@@ -83,7 +63,7 @@ module LeapCli
def sync_support_files(ssh)
dest_dir = provider.hiera_sync_destination
- ssh.leap.rsync_update do |server|
+ ssh.rsync.update do |server|
node = manager.node(server.host)
files_to_sync = node.file_paths.collect {|path| Path.relative_path(path, Path.provider) }
if files_to_sync.any?
@@ -102,6 +82,20 @@ module LeapCli
end
end
+ def sync_puppet_files(ssh)
+ ssh.rsync.update do |server|
+ ssh.leap.log(Path.platform + '/[bin,puppet] -> ' + server.host + ':' + LeapCli::PUPPET_DESTINATION)
+ {
+ :dest => LeapCli::PUPPET_DESTINATION,
+ :source => '.',
+ :chdir => Path.platform,
+ :excludes => '*',
+ :includes => ['/bin', '/bin/**', '/puppet', '/puppet/**'],
+ :flags => "--relative --dirs --delete --copy-links"
+ }
+ end
+ end
+
def init_submodules
Dir.chdir Path.platform do
assert_run! "git submodule sync"
@@ -141,6 +135,16 @@ module LeapCli
return includes
end
+ def tags(options)
+ if options[:tags]
+ tags = options[:tags].split(',')
+ else
+ tags = LeapCli::DEFAULT_TAGS.dup
+ end
+ tags << 'leap_slow' unless options[:fast]
+ tags.join(',')
+ end
+
#
# for safety, we allow production deploys to be turned off in the Leapfile.
#