lib/serverspec/setup.rb in serverspec-2.0.0.beta14 vs lib/serverspec/setup.rb in serverspec-2.0.0.beta15
- old
+ new
@@ -11,11 +11,11 @@
ask_unix_backend
else
ask_windows_backend
end
- if @backend_type == 'Ssh'
+ if @backend_type == 'ssh'
print 'Vagrant instance y/n: '
@vagrant = $stdin.gets.chomp
if @vagrant =~ (/(true|t|yes|y|1)$/i)
@vagrant = true
print 'Auto-configure Vagrant from Vagrantfile? y/n: '
@@ -70,11 +70,11 @@
EOF
print prompt.chop
num = $stdin.gets.to_i - 1
puts
- @backend_type = ['Ssh', 'Exec'][num] || 'Exec'
+ @backend_type = ['ssh', 'exec'][num] || 'exec'
end
def self.ask_windows_backend
prompt = <<-EOF
Select a backend type:
@@ -86,11 +86,11 @@
EOF
print prompt.chop
num = $stdin.gets.to_i - 1
puts
- @backend_type = ['WinRM', 'Cmd'][num] || 'Exec'
+ @backend_type = ['winrm', 'cmd'][num] || 'exec'
end
def self.safe_create_spec
content = <<-EOF
require 'spec_helper'
@@ -239,26 +239,23 @@
end
def self.spec_helper_template
template = <<-'EOF'
require 'serverspec'
-<% if @backend_type == 'Ssh' -%>
+<% if @backend_type == 'ssh' -%>
require 'net/ssh'
<% end -%>
<%- if @vagrant -%>
require 'tempfile'
<% end -%>
-<% if @backend_type == 'WinRM' -%>
+<% if @backend_type == 'winrm' -%>
require 'winrm'
<% end -%>
-include Specinfra::Helper::<%= @backend_type %>
-<% if @os_type != 'UN*X' -%>
-include Specinfra::Helper::Windows
-<% end -%>
+set :backend, :<%= @backend_type %>
-<% if @os_type == 'UN*X' && @backend_type == 'Ssh' -%>
+<% if @os_type == 'UN*X' && @backend_type == 'ssh' -%>
if ENV['ASK_SUDO_PASSWORD']
begin
require 'highline/import'
rescue LoadError
fail "highline is not available. Try installing it."
@@ -266,11 +263,11 @@
set :sudo_password, ask("Enter sudo password: ") { |q| q.echo = false }
else
set :sudo_password, ENV['SUDO_PASSWORD']
end
-<%- if @backend_type == 'Ssh' -%>
+<%- if @backend_type == 'ssh' -%>
host = ENV['TARGET_HOST']
<%- if @vagrant -%>
`vagrant up #{host}`
@@ -296,10 +293,10 @@
# set :env, :LANG => 'C', :LC_MESSAGES => 'C'
# Set PATH
# set :path, '/sbin:/usr/local/sbin:$PATH'
-<% if @backend_type == 'WinRM'-%>
+<% if @backend_type == 'winrm'-%>
user = <username>
pass = <password>
endpoint = "http://<hostname>:5985/wsman"
c.winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true)