capistrano_winrm 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -13,6 +13,8 @@ BLOG: http://distributed-frostbite.blogspot.com/
13
13
  Add me in LinkedIn: http://www.linkedin.com/in/danwanek
14
14
 
15
15
  --------------------------------------------------------------------------
16
+ INSTALL (Resides on rubygems.org):
17
+ gem install -r capistrano_winrm
16
18
 
17
19
  TO USE:
18
20
  require 'capistrano_winrm'
data/Rakefile ADDED
@@ -0,0 +1,66 @@
1
+ require 'rubygems'
2
+ require 'rake/clean'
3
+ require 'rake/gempackagetask'
4
+ require 'date'
5
+
6
+ CLEAN.include("pkg")
7
+ CLEAN.include("doc")
8
+
9
+ GEMSPEC = Gem::Specification.new do |gem|
10
+ gem.name = "capistrano_winrm"
11
+ gem.version = File.open('VERSION').readline.chomp
12
+ gem.date = Date.today.to_s
13
+ gem.platform = Gem::Platform::RUBY
14
+ gem.rubyforge_project = nil
15
+
16
+ gem.author = "Dan Wanek"
17
+ gem.email = "dan.wanek@gmail.com"
18
+ gem.homepage = "http://github.com/zenchild/capistrano_winrm"
19
+
20
+ gem.summary = 'WinRM extensions for Capistrano'
21
+ gem.description = <<-EOF
22
+ WinRM extensions for Capistrano
23
+ EOF
24
+
25
+ gem.files = %w{ lib/capistrano_winrm.rb lib/capistrano_winrm/command.rb lib/capistrano_winrm/configuration/connections.rb lib/winrm_connection.rb }
26
+ gem.require_path = "lib"
27
+ gem.rdoc_options = %w(-x test/ -x examples/)
28
+ gem.extra_rdoc_files = %w(README)
29
+
30
+ gem.required_ruby_version = '>= 1.8.7'
31
+ gem.add_runtime_dependency 'capistrano'
32
+ gem.add_runtime_dependency 'winrm', '>=0.0.4'
33
+ end
34
+
35
+ Rake::GemPackageTask.new(GEMSPEC) do |pkg|
36
+ pkg.need_tar = true
37
+ end
38
+
39
+ task :default => [:buildgem]
40
+
41
+ desc "Build the gem without a version change"
42
+ task :buildgem => [:clean, :repackage]
43
+
44
+ desc "Build the gem, but increment the version first"
45
+ task :newrelease => [:versionup, :clean, :repackage]
46
+
47
+
48
+ desc "Increment the version by 1 minor release"
49
+ task :versionup do
50
+ ver = up_min_version
51
+ puts "New version: #{ver}"
52
+ end
53
+
54
+
55
+ def up_min_version
56
+ f = File.open('VERSION', 'r+')
57
+ ver = f.readline.chomp
58
+ v_arr = ver.split(/\./).map do |v|
59
+ v.to_i
60
+ end
61
+ v_arr[2] += 1
62
+ ver = v_arr.join('.')
63
+ f.rewind
64
+ f.write(ver)
65
+ ver
66
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'date'
3
+
4
+ version = File.read(File.expand_path("../VERSION", __FILE__)).strip
5
+
6
+ Gem::Specification.new do |s|
7
+ s.platform = Gem::Platform::RUBY
8
+ s.name = 'capistrano_winrm'
9
+ s.version = version
10
+ s.date = Date.today.to_s
11
+
12
+ s.author = 'Dan Wanek'
13
+ s.email = 'dan.wanek@gmail.com'
14
+ s.homepage = "https://github.com/zenchild/capistrano_winrm"
15
+
16
+ s.summary = "Extends Capistrano with WinRM support."
17
+ s.description = <<-EOF
18
+ This gem extends Capistrano's base functionality to support WinRM which
19
+ allows one to run commands across Windows boxes with the "winrm_run" method.
20
+ EOF
21
+
22
+ s.files = `git ls-files`.split(/\n/)
23
+ s.require_path = "lib"
24
+ s.rdoc_options = %w(-x test/ -x examples/)
25
+ s.extra_rdoc_files = %w(README)
26
+
27
+ s.required_ruby_version = '>= 1.9.0'
28
+ s.add_runtime_dependency 'capistrano', '>= 2.5.18'
29
+ s.add_runtime_dependency 'winrm', '>= 1.0.0rc1'
30
+ end
data/examples/capfile ADDED
@@ -0,0 +1,42 @@
1
+ require 'capistrano_winrm'
2
+
3
+ # The ssl port will either be 443 for older WinRM implementations or 5986 for new versions.
4
+ role :win_domain, 'myhost:5985'
5
+ role :win_standalone, 'myhost-allalone:5985'
6
+
7
+ def winrm_netstat
8
+ host_data = {}
9
+ cmd = 'netstat -an'
10
+ winrm cmd do |channel, stream, data|
11
+ host_data[channel[:host]] = "" unless host_data[channel[:host]].is_a?(String)
12
+ host_data[channel[:host]] << data
13
+ end
14
+
15
+ host_data.each_pair do |host,data|
16
+ puts "HOST: #{host}"
17
+ puts "---------------------------------------"
18
+ puts data
19
+ puts "---------------------------------------"
20
+ end
21
+ end
22
+
23
+ task :winrm_krb5, :roles => :win_domain do
24
+ set :winrm_krb5_realm, 'EXAMPLE.COM'
25
+ winrm_netstat
26
+ unset :winrm_krb5_realm
27
+ end
28
+
29
+ task :winrm_plain, :roles => :win_standalone do
30
+ set :winrm_user, 'myuser'
31
+ set :winrm_password, 'mypass'
32
+ #set :winrm_ssl_ca_store, '/etc/ssl/certs'
33
+ winrm_netstat
34
+ #unset :winrm_ssl_ca_store
35
+ unset :winrm_user
36
+ unset :winrm_password
37
+ end
38
+
39
+ task :allwinrm do
40
+ winrm_krb5
41
+ winrm_plain
42
+ end
@@ -4,16 +4,14 @@ module Capistrano
4
4
  class WinRMConnectionFactory #:nodoc:
5
5
  def initialize(options)
6
6
  @options = options
7
- @winrm = WINRM.new(options[:winrm_user], options[:winrm_password], nil, options[:winrm_ssl_ca_store])
8
7
  end
9
8
 
10
9
  def connect_to(server)
11
- @winrm.setup_connection(server, @options)
12
- @winrm
10
+ WINRM.new(server, @options)
13
11
  end
14
12
  end
15
13
 
16
- # Returns the object responsible for establishing new SSH connections.
14
+ # Returns the object responsible for establishing new connections.
17
15
  # The factory will respond to #connect_to, which can be used to
18
16
  # establish connections to servers defined via ServerDefinition objects.
19
17
  def connection_factory
@@ -1,15 +1,14 @@
1
1
  require 'winrm'
2
2
 
3
3
  class WINRM
4
+
4
5
  attr_reader :server
5
6
  alias :xserver :server
6
7
 
7
- def initialize(user, pass, endpoint = nil, ssl_ca_store = nil)
8
- @user = user
9
- @pass = pass
10
- @endpoint = endpoint
11
- @ssl_ca_store = ssl_ca_store
12
- @int_hash = {}
8
+ def initialize(server, opts)
9
+ @server = server
10
+ @int_hash = {:options => opts, :server => server}
11
+ @winrm = establish_winrm(opts)
13
12
  end
14
13
 
15
14
  def [](key)
@@ -20,24 +19,12 @@ class WINRM
20
19
  @int_hash[key.to_sym] = value
21
20
  end
22
21
 
23
- def setup_connection(server, options)
24
- @server = server
25
- @int_hash[:options] = options
26
- @int_hash[:server] = server
27
- end
28
-
29
22
  def open_channel
30
23
  yield self
31
24
  end
32
25
 
33
26
  def exec(cmd)
34
- http_method = ( server.port.to_s=~/(443|5986)/ ? 'https' : 'http' )
35
- endpoint = @endpoint ? @endpoint : "#{http_method}://#{server}/wsman"
36
- WinRM::WinRM.endpoint = endpoint
37
- WinRM::WinRM.set_auth(@user, @pass)
38
- WinRM::WinRM.set_ca_trust_path(@ssl_ca_store) unless @ssl_ca_store.nil?
39
- inst = WinRM::WinRM.instance
40
- @ios = inst.cmd(cmd)
27
+ @ios = @winrm.cmd(cmd)
41
28
  end
42
29
 
43
30
  def process_data
@@ -54,4 +41,25 @@ class WINRM
54
41
  def on_request(req_type); self; end
55
42
  def on_close; self; end
56
43
 
44
+
45
+ private
46
+
47
+ # Create a new WinRM instance
48
+ # @param [Hash] opts the option hash that was passed to initialize
49
+ # @return [WinRM] a new WinRM connection for a particular endpoint
50
+ def establish_winrm(opts)
51
+ http_method = ( server.port.to_s=~/(443|5986)/ ? 'https' : 'http' )
52
+ endpoint = "#{http_method}://#{server}/wsman"
53
+ if opts[:winrm_krb5_realm]
54
+ inst = WinRM::WinRMWebService.new(endpoint, :kerberos, :realm => opts[:winrm_krb5_realm])
55
+ else
56
+ unless opts[:winrm_ssl_ca_store]
57
+ inst = WinRM::WinRMWebService.new(endpoint, :plaintext, :user => opts[:winrm_user], :pass => opts[:winrm_password])
58
+ else
59
+ inst = WinRM::WinRMWebService.new(endpoint, :ssl, :user => opts[:winrm_user], :pass => opts[:winrm_password], :ca_trust_path => opts[:winrm_ssl_ca_store])
60
+ end
61
+ end
62
+ inst
63
+ end
64
+
57
65
  end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_winrm
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 1
9
- version: 0.0.1
4
+ prerelease:
5
+ version: 1.0.0
10
6
  platform: ruby
11
7
  authors:
12
8
  - Dan Wanek
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-09-24 00:00:00 -05:00
13
+ date: 2011-03-03 00:00:00 -06:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -25,9 +21,7 @@ dependencies:
25
21
  requirements:
26
22
  - - ">="
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
24
+ version: 2.5.18
31
25
  type: :runtime
32
26
  version_requirements: *id001
33
27
  - !ruby/object:Gem::Dependency
@@ -38,14 +32,10 @@ dependencies:
38
32
  requirements:
39
33
  - - ">="
40
34
  - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- - 0
44
- - 4
45
- version: 0.0.4
35
+ version: 1.0.0rc1
46
36
  type: :runtime
47
37
  version_requirements: *id002
48
- description: " WinRM extensions for Capistrano\n"
38
+ description: " This gem extends Capistrano's base functionality to support WinRM which\n allows one to run commands across Windows boxes with the \"winrm_run\" method.\n"
49
39
  email: dan.wanek@gmail.com
50
40
  executables: []
51
41
 
@@ -54,13 +44,17 @@ extensions: []
54
44
  extra_rdoc_files:
55
45
  - README
56
46
  files:
47
+ - README
48
+ - Rakefile
49
+ - VERSION
50
+ - capistrano_winrm.gemspec
51
+ - examples/capfile
57
52
  - lib/capistrano_winrm.rb
58
53
  - lib/capistrano_winrm/command.rb
59
54
  - lib/capistrano_winrm/configuration/connections.rb
60
55
  - lib/winrm_connection.rb
61
- - README
62
56
  has_rdoc: true
63
- homepage: http://github.com/zenchild/capistrano_winrm
57
+ homepage: https://github.com/zenchild/capistrano_winrm
64
58
  licenses: []
65
59
 
66
60
  post_install_message:
@@ -76,25 +70,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
70
  requirements:
77
71
  - - ">="
78
72
  - !ruby/object:Gem::Version
79
- segments:
80
- - 1
81
- - 8
82
- - 7
83
- version: 1.8.7
73
+ version: 1.9.0
84
74
  required_rubygems_version: !ruby/object:Gem::Requirement
85
75
  none: false
86
76
  requirements:
87
77
  - - ">="
88
78
  - !ruby/object:Gem::Version
89
- segments:
90
- - 0
91
79
  version: "0"
92
80
  requirements: []
93
81
 
94
82
  rubyforge_project:
95
- rubygems_version: 1.3.7
83
+ rubygems_version: 1.5.0
96
84
  signing_key:
97
85
  specification_version: 3
98
- summary: WinRM extensions for Capistrano
86
+ summary: Extends Capistrano with WinRM support.
99
87
  test_files: []
100
88