aboutsummaryrefslogtreecommitdiff
path: root/lib/leap_cli/remote
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-10-23 03:53:06 -0700
committerelijah <elijah@riseup.net>2012-10-23 03:53:06 -0700
commit628165fd0a4e03bb7bbef3a464447924195e10b8 (patch)
tree746280b6f4d6d488fcece4fff41b4addfb77d0c1 /lib/leap_cli/remote
parent4f38e99c629f60d9524d1cf23efa7ab927ac9cf4 (diff)
downloadleap_cli-628165fd0a4e03bb7bbef3a464447924195e10b8.tar.gz
leap_cli-628165fd0a4e03bb7bbef3a464447924195e10b8.tar.bz2
added a bunch of new commands, including init-node and deploy
Diffstat (limited to 'lib/leap_cli/remote')
-rw-r--r--lib/leap_cli/remote/plugin.rb35
-rw-r--r--lib/leap_cli/remote/tasks.rb36
2 files changed, 71 insertions, 0 deletions
diff --git a/lib/leap_cli/remote/plugin.rb b/lib/leap_cli/remote/plugin.rb
new file mode 100644
index 0000000..22ffe34
--- /dev/null
+++ b/lib/leap_cli/remote/plugin.rb
@@ -0,0 +1,35 @@
+#
+# these methods are made available in capistrano tasks as 'leap.method_name'
+#
+
+module LeapCli; module Remote; module Plugin
+
+ def mkdir_leap(base_dir)
+ run "mkdir -p #{base_dir}/config && chown -R root #{base_dir} && chmod -R ag-rwx,u+rwX #{base_dir}"
+ end
+
+ #
+ # takes a block, yielded a server, that should return {:source => '', :dest => ''}
+ #
+ def rsync_update
+ SupplyDrop::Util.thread_pool_size = puppet_parallel_rsync_pool_size
+ servers = SupplyDrop::Util.optionally_async(find_servers, puppet_parallel_rsync)
+ failed_servers = servers.map do |server|
+ #p server
+ #p server.options
+ # build rsync command
+ _paths = yield server
+ _source = _paths[:source]
+ _user = server.user || fetch(:user, ENV['USER'])
+ _dest = SupplyDrop::Rsync.remote_address(_user, server.host, _paths[:dest])
+ _opts = {:ssh => ssh_options.merge(server.options[:ssh_options]||{})}
+ rsync_cmd = SupplyDrop::Rsync.command(_source, _dest, _opts)
+
+ # run command
+ logger.debug rsync_cmd
+ server.host unless system rsync_cmd
+ end.compact
+ raise "rsync failed on #{failed_servers.join(',')}" if failed_servers.any?
+ end
+
+end; end; end \ No newline at end of file
diff --git a/lib/leap_cli/remote/tasks.rb b/lib/leap_cli/remote/tasks.rb
new file mode 100644
index 0000000..e524133
--- /dev/null
+++ b/lib/leap_cli/remote/tasks.rb
@@ -0,0 +1,36 @@
+#
+# This file is evaluated just the same as a typical capistrano "deploy.rb"
+# For DSL manual, see https://github.com/capistrano/capistrano/wiki
+#
+
+require 'supply_drop'
+
+MAX_HOSTS = 10
+
+task :install_authorized_keys, :max_hosts => MAX_HOSTS do
+ run 'mkdir -p /root/.ssh && chmod 700 /root/.ssh'
+ upload LeapCli::Path.named_path(:authorized_keys), '/root/.ssh/authorized_keys', :mode => '600'
+end
+
+task :install_prerequisites, :max_hosts => MAX_HOSTS do
+ puppet.bootstrap.ubuntu
+ #
+ # runs this:
+ # run "mkdir -p #{puppet_destination}"
+ # run "#{sudo} apt-get update"
+ # run "#{sudo} apt-get install -y puppet rsync"
+ #
+end
+
+#task :update_platform, :max_hosts => MAX_HOSTS do
+# puppet.update_code
+#end
+
+#task :mk_leap_dir, :max_hosts => MAX_HOSTS do
+# run 'mkdir -p /root/leap/config && chown -R root /root/leap && chmod -R ag-rwx,u+rwX /root/leap'
+#end
+
+task :apply_puppet, :max_hosts => MAX_HOSTS do
+ raise "now such directory #{puppet_source}" unless File.directory?(puppet_source)
+ puppet.apply
+end