aboutsummaryrefslogtreecommitdiff
path: root/lib/leap_cli/commands/node.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-12-15 23:32:08 -0800
committerelijah <elijah@riseup.net>2012-12-15 23:32:08 -0800
commit19d41877d1ad2c0b0090ec303e171113f6ddeaf9 (patch)
tree40d308a2b6cf1da53e112e425b5fee3ec1c2c7a1 /lib/leap_cli/commands/node.rb
parent6b96be3fd05fb093be834e8cbc8d3af31a9e29ca (diff)
downloadleap_cli-19d41877d1ad2c0b0090ec303e171113f6ddeaf9.tar.gz
leap_cli-19d41877d1ad2c0b0090ec303e171113f6ddeaf9.tar.bz2
support `leap node init` with node-filter
Diffstat (limited to 'lib/leap_cli/commands/node.rb')
-rw-r--r--lib/leap_cli/commands/node.rb24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/leap_cli/commands/node.rb b/lib/leap_cli/commands/node.rb
index 91a30ae..87718e9 100644
--- a/lib/leap_cli/commands/node.rb
+++ b/lib/leap_cli/commands/node.rb
@@ -37,24 +37,28 @@ module LeapCli; module Commands
end
end
- node.desc 'Bootstraps a node, setting up SSH keys and installing prerequisite packages'
+ node.desc 'Bootstraps a node or nodes, setting up SSH keys and installing prerequisite packages'
node.long_desc "This command prepares a server to be used with the LEAP Platform by saving the server's SSH host key, " +
"copying the authorized_keys file, and installing packages that are required for deploying. " +
"Node init must be run before deploying to a server, and the server must be running and available via the network. " +
"This command only needs to be run once, but there is no harm in running it multiple times."
- node.arg_name '<node-name>' #, :optional => false, :multiple => false
+ node.arg_name '<node-filter>' #, :optional => false, :multiple => false
node.command :init do |init|
init.switch 'echo', :desc => 'If set, passwords are visible as you type them (default is hidden)', :negatable => false
init.action do |global_options,options,args|
- node = get_node_from_args(args)
- ping_node(node)
- save_public_host_key(node)
- update_compiled_ssh_configs
- ssh_connect(node, :bootstrap => true, :echo => options[:echo]) do |ssh|
- ssh.install_authorized_keys
- ssh.install_prerequisites
+ assert! args.any?, 'You must specify a node-filter'
+ finished = []
+ manager.filter(args).each_node do |node|
+ ping_node(node)
+ save_public_host_key(node)
+ update_compiled_ssh_configs
+ ssh_connect(node, :bootstrap => true, :echo => options[:echo]) do |ssh|
+ ssh.install_authorized_keys
+ ssh.install_prerequisites
+ end
+ finished << node.name
end
- log :completed, "node init #{node.name}"
+ log :completed, "initialization of nodes #{finished.join(', ')}"
end
end