vagrant-winrm-s 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .vagrant/
16
+ Vagrantfile
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ Exclude:
3
+ - '*.gemspec'
4
+
5
+ Metrics/LineLength:
6
+ Max: 120
7
+
8
+ Style/Documentation:
9
+ Enabled: false
10
+
11
+ Metrics/MethodLength:
12
+ Max: 20
13
+
14
+ StringLiterals:
15
+ EnforcedStyle: double_quotes
16
+
17
+ Style/FileName:
18
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in vagrant-winrm-s.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
8
+ gem "vagrant-spec", git: "https://github.com/mitchellh/vagrant-spec.git"
9
+ end
10
+
11
+ group :plugins do
12
+ gem "vagrant-winrm-s", path: "."
13
+ gem "vagrant-managed-servers"
14
+ gem "vagrant-orchestrate"
15
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2015 Cimpress
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # Vagrant-WinRM-S
2
+
3
+ A Vagrant communicator that uses the `winrm-s` gem to communicate over winrm. Notably, allows for SSPI authentication of domain accounts when using a Windows host.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ $ vagrant plugin install vagrant-winrm-s
9
+ ```
10
+
11
+ Or, to install and test a locally-developed version:
12
+ ```bash
13
+ $ rake install
14
+ ```
15
+
16
+ ## Use
17
+
18
+ Vargrant-WinRM-S uses the `:winrm` communicator built in to vagrant as
19
+ its base, so existing Vagrantfiles should continue to work with this plugin.
20
+
21
+ The extra configuration value that gets exposed is `config.winrm.transport`.
22
+ The default transport is `:plaintext`. This is for basic authentication of
23
+ local accounts over HTTP. The plugin exposes the `:sspinegotiate`
24
+ transport from the `winrm-s` gem in order to do Negotiate authentication
25
+ of domain accounts (still only over HTTP).
26
+
27
+ An example Vagrant communicator block for `:sspinegotiate` would look something
28
+ like:
29
+
30
+ ```ruby
31
+ config.vm.provision "shell", inline: "echo Hello, World!"
32
+ config.vm.communicator = :winrm
33
+ config.winrm.username = "domain\\auser"
34
+ config.winrm.password = "It5@p455w0rd!"
35
+ config.winrm.transport = :sspinegotiate
36
+ ```
37
+
38
+ ### What about the SSL transport?
39
+
40
+ The `:ssl` transport is available and can be used to authenticate local accounts.
41
+ However, the versions of `WinRM` and `HTTPClient` bundled with Vagrant make it
42
+ difficult to ignore untrusted/self-signed certificates. But users with proper
43
+ certificates should have no problem.
44
+
45
+ ## Setting up your server
46
+
47
+ For authentication of local accounts over HTTP, the `winrm quickconfig`
48
+ command should suffice. This will enable the HTTP listener for basic authentication.
49
+
50
+ In order to connect via the `:plaintext` transport, you should ensure that
51
+ `winrm/config/service/auth/Basic` and `winrm/config/service/AllowUnencrypted` are enabled.
52
+
53
+ ```
54
+ winrm set winrm/config/service/auth @{Basic="true"}
55
+ winrm set winrm/config/service @{AllowUnencrypted="true"}
56
+ ```
57
+
58
+ For the `:sspinegotiate` transport, ensure `winrm/config/service/auth/Negotiate` is true and `winrm/config/service/AllowUnencrypted` is false.
59
+
60
+ ```
61
+ winrm set winrm/config/service/auth @{Negotiate="true"}
62
+ winrm set winrm/config/service @{AllowUnencrypted="false"}
63
+ ```
64
+
65
+ See also:
66
+
67
+ * [MSDN article about configuring WinRM](http://msdn.microsoft.com/en-us/library/aa384372\(v=vs.85\).aspx)
68
+ * [WinRM gem](https://github.com/WinRb/WinRM/blob/master/README.md#troubleshooting)
69
+ * [WinRM-S gem](https://github.com/opscode/winrm-s/blob/master/README.md)
70
+
71
+ ## Contributing
72
+
73
+ 1. Fork it ( https://github.com/Cimpress-MCP/vagrant-winrm-s/fork )
74
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
75
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
76
+ 4. Push to the branch (`git push origin my-new-feature`)
77
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rubocop/rake_task"
3
+
4
+ RuboCop::RakeTask.new
5
+
6
+ task :install_local do
7
+ system("rake build")
8
+ system("vagrant plugin install ./pkg/vagrant-winrm-s-0.0.1.gem")
9
+ end
@@ -0,0 +1,17 @@
1
+ require "vagrant-winrm-s/version"
2
+ require "vagrant-winrm-s/plugin"
3
+ require "vagrant-winrm-s/config"
4
+
5
+ module VagrantPlugins
6
+ module CommunicatorWinRM
7
+ lib_path = Pathname.new(File.expand_path("../vagrant-winrm-s", __FILE__))
8
+ autoload :Communicator, lib_path.join("communicator")
9
+
10
+ # This returns the path to the source of this plugin.
11
+ #
12
+ # @return [Pathname]
13
+ def self.source_root
14
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,32 @@
1
+ require "timeout"
2
+ require "log4r"
3
+
4
+ require "vagrant/../../plugins/communicators/winrm/helper"
5
+ require_relative "shell"
6
+ require "vagrant/../../plugins/communicators/winrm/communicator"
7
+
8
+ module VagrantPlugins
9
+ module CommunicatorWinRM
10
+ class WinrmSCommunicator < Communicator
11
+ def initialize(machine)
12
+ super(machine)
13
+ end
14
+
15
+ protected
16
+
17
+ def create_shell
18
+ winrm_info = Helper.winrm_info(@machine)
19
+
20
+ WinRMSShell.new(
21
+ winrm_info[:host],
22
+ @machine.config.winrm.username,
23
+ @machine.config.winrm.password,
24
+ transport: @machine.config.winrm.transport,
25
+ port: @machine.config.winrm.port,
26
+ timeout_in_seconds: @machine.config.winrm.timeout,
27
+ max_tries: @machine.config.winrm.max_tries)
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,40 @@
1
+ require "vagrant/../../plugins/communicators/winrm/config"
2
+
3
+ module VagrantPlugins
4
+ module CommunicatorWinRM
5
+ class WinrmSConfig < Config
6
+
7
+ attr_accessor :transport
8
+
9
+ def initialize
10
+ super
11
+ @transport = UNSET_VALUE
12
+ end
13
+
14
+ def finalize!
15
+ @username = "vagrant" if @username == UNSET_VALUE
16
+ @password = "vagrant" if @password == UNSET_VALUE
17
+ @host = nil if @host == UNSET_VALUE
18
+ @port = 5985 if @port == UNSET_VALUE
19
+ @guest_port = 5985 if @guest_port == UNSET_VALUE
20
+ @max_tries = 20 if @max_tries == UNSET_VALUE
21
+ @timeout = 1800 if @timeout == UNSET_VALUE
22
+ @transport = :plaintext if @transport == UNSET_VALUE
23
+ end
24
+
25
+ def validate(_machine)
26
+ errors = []
27
+
28
+ errors << "winrm.username cannot be nil." if @username.nil?
29
+ errors << "winrm.password cannot be nil." if @password.nil?
30
+ errors << "winrm.port cannot be nil." if @port.nil?
31
+ errors << "winrm.guest_port cannot be nil." if @guest_port.nil?
32
+ errors << "winrm.max_tries cannot be nil." if @max_tries.nil?
33
+ errors << "winrm.timeout cannot be nil." if @timeout.nil?
34
+ errors << "winrm.transport cannot be nil." if @transport.nil?
35
+
36
+ { "WinRM" => errors }
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,30 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "vagrant-winrm-s must be run from within vagrant."
5
+ end
6
+
7
+ require "vagrant/../../plugins/communicators/winrm/plugin"
8
+
9
+ module VagrantPlugins
10
+ module CommunicatorWinRM
11
+ class WinrmSPlugin < Plugin
12
+ name "winrms communicator"
13
+ description <<-DESC
14
+ This plugin allows Vagrant to communicate with remote machines using
15
+ SSPINegotiate when run from Windows Hosts.
16
+ DESC
17
+
18
+ communicator("winrm") do
19
+ require File.expand_path("../communicator", __FILE__)
20
+ init!
21
+ WinrmSCommunicator
22
+ end
23
+
24
+ config("winrm") do
25
+ require_relative "config"
26
+ WinrmSConfig
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,59 @@
1
+ require "timeout"
2
+ require "log4r"
3
+ require "vagrant/util/retryable"
4
+ require "vagrant/util/silence_warnings"
5
+
6
+ Vagrant::Util::SilenceWarnings.silence! do
7
+ require "winrm-s"
8
+ end
9
+
10
+ require "vagrant/../../plugins/communicators/winrm/file_manager"
11
+ require "vagrant/../../plugins/communicators/winrm/shell"
12
+
13
+ module VagrantPlugins
14
+ module CommunicatorWinRM
15
+ class WinRMSShell < WinRMShell
16
+ include Vagrant::Util::Retryable
17
+
18
+ attr_reader :transport
19
+ attr_reader :protocol
20
+
21
+ def initialize(host, username, password, options = {})
22
+ super(host, username, password, options)
23
+
24
+ @logger = Log4r::Logger.new("vagrant::communication::winrmsshell")
25
+ @transport = options[:transport] || :plaintext
26
+ @protocol = (options[:transport] == :ssl) ? "https" : "http"
27
+ end
28
+
29
+ protected
30
+
31
+ def new_session
32
+ @logger.info("Attempting to connect to WinRM...")
33
+ @logger.info(" - Host: #{@host}")
34
+ @logger.info(" - Port: #{@port}")
35
+ @logger.info(" - Username: #{@username}")
36
+ @logger.info(" - Transport: #{@transport}")
37
+ @logger.info(" - Endpoint: #{endpoint}")
38
+
39
+ client = ::WinRM::WinRMWebService.new(endpoint, @transport, endpoint_options)
40
+ client.set_timeout(@timeout_in_seconds)
41
+ client.toggle_nori_type_casting(:off)
42
+ client
43
+ end
44
+
45
+ def endpoint
46
+ "#{@protocol}://#{@host}:#{@port}/wsman"
47
+ end
48
+
49
+ def endpoint_options
50
+ { user: @username,
51
+ pass: @password,
52
+ host: @host,
53
+ port: @port,
54
+ operation_timeout: @timeout_in_seconds,
55
+ basic_auth_only: (@transport == :plaintext) }
56
+ end
57
+ end # WinShell class
58
+ end
59
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module CommunicatorWinRMS
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-winrm-s/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-winrm-s"
8
+ spec.version = VagrantPlugins::CommunicatorWinRMS::VERSION
9
+ spec.authors = ["Norm MacLennan"]
10
+ spec.email = ["nmaclennan@cimpress.com"]
11
+ spec.summary = "Secure WinRM vagrant communicator"
12
+ spec.description = "A Vagrant plugin that allows for secure communication over WinRM"
13
+ spec.homepage = "https://github.com/Cimpress-MCP/vagrant-winrm-s"
14
+ spec.license = "Apache 2.0"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "winrm-s", "~>0.1.0"
22
+ spec.add_dependency "httpclient", "~>2.4.0"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 2.99"
27
+ spec.add_development_dependency "rubocop", "~> 0.28"
28
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-winrm-s
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Norm MacLennan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-01-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: winrm-s
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.1.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: httpclient
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 2.4.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.4.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.7'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '10.0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '10.0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '2.99'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '2.99'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rubocop
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '0.28'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '0.28'
110
+ description: A Vagrant plugin that allows for secure communication over WinRM
111
+ email:
112
+ - nmaclennan@cimpress.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
118
+ - .rspec
119
+ - .rubocop.yml
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - lib/vagrant-winrm-s.rb
125
+ - lib/vagrant-winrm-s/communicator.rb
126
+ - lib/vagrant-winrm-s/config.rb
127
+ - lib/vagrant-winrm-s/plugin.rb
128
+ - lib/vagrant-winrm-s/shell.rb
129
+ - lib/vagrant-winrm-s/version.rb
130
+ - vagrant-winrm-s.gemspec
131
+ homepage: https://github.com/Cimpress-MCP/vagrant-winrm-s
132
+ licenses:
133
+ - Apache 2.0
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ requirements: []
151
+ rubyforge_project:
152
+ rubygems_version: 1.8.23
153
+ signing_key:
154
+ specification_version: 3
155
+ summary: Secure WinRM vagrant communicator
156
+ test_files: []