# # Author:: Seth Chisamore () # Copyright:: Copyright (c) 2011 Opscode, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # require File.join(File.dirname(__FILE__), 'mixin/windows/bootstrap') class Chef class Knife class BootstrapWindowsSsh < Bootstrap include Chef::Mixin::Bootstrap deps do require 'chef/knife/core/windows_bootstrap_context' require 'chef/json_compat' require 'tempfile' require 'highline' require 'net/ssh' require 'net/ssh/multi' Chef::Knife::Ssh.load_deps end banner "knife bootstrap windows ssh FQDN (options)" option :ssh_user, :short => "-x USERNAME", :long => "--ssh-user USERNAME", :description => "The ssh username", :default => "root" option :ssh_password, :short => "-P PASSWORD", :long => "--ssh-password PASSWORD", :description => "The ssh password" option :ssh_port, :short => "-p PORT", :long => "--ssh-port PORT", :description => "The ssh port", :default => "22", :proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key } option :identity_file, :short => "-i IDENTITY_FILE", :long => "--identity-file IDENTITY_FILE", :description => "The SSH identity file used for authentication" option :chef_node_name, :short => "-N NAME", :long => "--node-name NAME", :description => "The Chef node name for your new node" option :prerelease, :long => "--prerelease", :description => "Install the pre-release chef gems" option :bootstrap_version, :long => "--bootstrap-version VERSION", :description => "The version of Chef to install", :proc => Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v } option :bootstrap_proxy, :long => "--bootstrap-proxy PROXY_URL", :description => "The proxy server for the node being bootstrapped", :proc => Proc.new { |p| Chef::Config[:knife][:bootstrap_proxy] = p } option :distro, :short => "-d DISTRO", :long => "--distro DISTRO", :description => "Bootstrap a distro using a template", :default => "windows-shell" option :template_file, :long => "--template-file TEMPLATE", :description => "Full path to location of template to use", :default => false option :run_list, :short => "-r RUN_LIST", :long => "--run-list RUN_LIST", :description => "Comma separated list of roles/recipes to apply", :proc => lambda { |o| o.split(",") }, :default => [] option :no_host_key_verify, :long => "--no-host-key-verify", :description => "Disable host key verification", :boolean => true, :default => false def run bootstrap end def run_command(command = '') ssh = Chef::Knife::Ssh.new ssh.name_args = [ server_name, command ] ssh.config[:ssh_user] = locate_config_value(:ssh_user) ssh.config[:ssh_password] = locate_config_value(:ssh_password) ssh.config[:ssh_port] = locate_config_value(:ssh_port) ssh.config[:identity_file] = config[:identity_file] ssh.config[:manual] = true ssh.config[:no_host_key_verify] = config[:no_host_key_verify] ssh end end end end