chef-provisioning-vsphere 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -2
- data/CHANGELOG.md +10 -1
- data/Gemfile +1 -1
- data/Rakefile +53 -19
- data/chef-provisioning-vsphere.gemspec +26 -26
- data/examples/ubuntu-provision.rb +21 -20
- data/examples/win-provision.rb +25 -26
- data/lib/chef/provisioning/driver_init/vsphere.rb +2 -2
- data/lib/chef/provisioning/vsphere_driver.rb +2 -2
- data/lib/chef/provisioning/vsphere_driver/clone_spec_builder.rb +12 -12
- data/lib/chef/provisioning/vsphere_driver/driver.rb +89 -88
- data/lib/chef/provisioning/vsphere_driver/version.rb +1 -1
- data/lib/chef/provisioning/vsphere_driver/vm_helper.rb +4 -4
- data/lib/chef/provisioning/vsphere_driver/vsphere_helpers.rb +37 -37
- data/lib/chef/provisioning/vsphere_driver/vsphere_url.rb +13 -13
- data/lib/kitchen/driver/vsphere.rb +13 -13
- data/spec/integration_tests/vsphere_driver_spec.rb +46 -46
- data/spec/spec_helper.rb +3 -2
- data/spec/unit_tests/VsphereDriver_spec.rb +98 -60
- data/spec/unit_tests/VsphereUrl_spec.rb +24 -24
- data/spec/unit_tests/clone_spec_builder_spec.rb +48 -48
- data/spec/unit_tests/support/vsphere_helper_stub.rb +4 -4
- data/spec/unit_tests/vsphere_helpers_spec.rb +46 -46
- metadata +2 -5
- data/.rubocop.yml +0 -10
- data/.rubocop_todo.yml +0 -135
- data/Jenkinsfile +0 -82
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fee187b088f7b218b9e783f294da04188b0e38ba
|
4
|
+
data.tar.gz: 1fcb11378516dc70fc0a1acd9b2381cc58c219ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e8545b0d2035c652ff75d6d661938f8fb2b7a866e2393c2084120672b923d32bd65da35bd6c0a1cf4364e5b81093cbfb485c7a779eefc55ae8451c13ed702b8
|
7
|
+
data.tar.gz: 9b1d22263be24c51ef3392b32e17e9d836827b55ee3a4fa7a3b2836519faef09df295951673bb0ca33de6c55173d2d9d67685f78b8b6219d2cc61ccaa96cb301
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [v2.
|
3
|
+
## [v2.3.0](https://github.com/chef-partners/chef-provisioning-vsphere/tree/v2.3.0)
|
4
4
|
|
5
|
+
[Full Changelog](https://github.com/chef-partners/chef-provisioning-vsphere/compare/v2.2.2...v2.3.0)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Fix missing\_method deprecation from Cheffish::MergedConfig [\#88](https://github.com/chef-partners/chef-provisioning-vsphere/pull/88) ([josh-barker](https://github.com/josh-barker))
|
10
|
+
- Trying to make travis happy [\#87](https://github.com/chef-partners/chef-provisioning-vsphere/pull/87) ([jjasghar](https://github.com/jjasghar))
|
11
|
+
- Trying to get back to standards [\#86](https://github.com/chef-partners/chef-provisioning-vsphere/pull/86) ([jjasghar](https://github.com/jjasghar))
|
12
|
+
|
13
|
+
## [v2.2.2](https://github.com/chef-partners/chef-provisioning-vsphere/tree/v2.2.2) (2018-06-05)
|
5
14
|
[Full Changelog](https://github.com/chef-partners/chef-provisioning-vsphere/compare/v2.2.1...v2.2.2)
|
6
15
|
|
7
16
|
**Merged pull requests:**
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,41 +1,75 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "chef/provisioning/vsphere_driver/version"
|
5
|
+
require "rspec/core/rake_task"
|
6
|
+
require "rubocop/rake_task"
|
7
|
+
require "yard"
|
8
8
|
|
9
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) +
|
10
|
-
|
11
|
-
RuboCop::RakeTask.new(:style) do |task|
|
12
|
-
task.options << '--display-cop-names'
|
13
|
-
end
|
9
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + "/lib")
|
14
10
|
|
15
11
|
RSpec::Core::RakeTask.new(:unit) do |task|
|
16
|
-
task.pattern =
|
17
|
-
task.rspec_opts = [
|
12
|
+
task.pattern = "spec/unit_tests/*_spec.rb"
|
13
|
+
task.rspec_opts = ["--color", "-f documentation"]
|
18
14
|
end
|
19
15
|
|
20
16
|
RSpec::Core::RakeTask.new(:integration) do |task|
|
21
|
-
task.pattern =
|
22
|
-
task.rspec_opts = [
|
17
|
+
task.pattern = "spec/integration_tests/*_spec.rb"
|
18
|
+
task.rspec_opts = ["--color", "-f documentation", "--out rspec.txt"]
|
23
19
|
end
|
24
20
|
|
25
21
|
begin
|
26
|
-
require
|
22
|
+
require "github_changelog_generator/task"
|
27
23
|
|
28
24
|
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
29
25
|
config.future_release = ChefProvisioningVsphere::VERSION
|
30
26
|
config.issues = true
|
31
27
|
end
|
32
28
|
rescue LoadError
|
33
|
-
puts
|
29
|
+
puts "github_changelog_generator is not available. gem install github_changelog_generator to generate changelogs"
|
34
30
|
end
|
35
31
|
|
36
32
|
YARD::Rake::YardocTask.new do |t|
|
37
|
-
t.files = [
|
38
|
-
t.stats_options = [
|
33
|
+
t.files = ["lib/**/*.rb"] # optional
|
34
|
+
t.stats_options = ["--list-undoc"] # optional
|
39
35
|
end
|
40
36
|
|
41
|
-
task default: %i
|
37
|
+
task default: %i{style unit}
|
38
|
+
|
39
|
+
namespace :style do
|
40
|
+
begin
|
41
|
+
require "rubocop/rake_task"
|
42
|
+
|
43
|
+
desc "Run Cookbook Ruby style checks"
|
44
|
+
RuboCop::RakeTask.new(:cookstyle) do |t|
|
45
|
+
t.requires = ["cookstyle"]
|
46
|
+
t.patterns = ["lib/chef-dk/skeletons/code_generator"]
|
47
|
+
t.options = ["--display-cop-names"]
|
48
|
+
end
|
49
|
+
rescue LoadError => e
|
50
|
+
puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV["CI"]
|
51
|
+
end
|
52
|
+
|
53
|
+
begin
|
54
|
+
require "rubocop/rake_task"
|
55
|
+
|
56
|
+
ignore_dirs = Regexp.union(%w{
|
57
|
+
lib/chef-dk/skeletons/code_generator
|
58
|
+
spec/unit/fixtures/chef-runner-cookbooks
|
59
|
+
spec/unit/fixtures/cookbook_cache
|
60
|
+
spec/unit/fixtures/example_cookbook
|
61
|
+
spec/unit/fixtures/example_cookbook_metadata_json_only
|
62
|
+
spec/unit/fixtures/example_cookbook_no_metadata
|
63
|
+
spec/unit/fixtures/local_path_cookbooks
|
64
|
+
})
|
65
|
+
|
66
|
+
desc "Run Chef Ruby style checks"
|
67
|
+
RuboCop::RakeTask.new(:chefstyle) do |t|
|
68
|
+
t.requires = ["chefstyle"]
|
69
|
+
t.patterns = `rubocop --list-target-files`.split("\n").reject { |f| f =~ ignore_dirs }
|
70
|
+
t.options = ["--display-cop-names"]
|
71
|
+
end
|
72
|
+
rescue LoadError => e
|
73
|
+
puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV["CI"]
|
74
|
+
end
|
75
|
+
end
|
@@ -1,39 +1,39 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) +
|
4
|
-
require
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + "/lib")
|
4
|
+
require "chef/provisioning/vsphere_driver/version"
|
5
5
|
|
6
6
|
# rubocop Metrics/ModuleLength
|
7
7
|
Gem::Specification.new do |s|
|
8
|
-
s.name =
|
8
|
+
s.name = "chef-provisioning-vsphere"
|
9
9
|
s.version = ChefProvisioningVsphere::VERSION
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
|
-
s.extra_rdoc_files = [
|
12
|
-
s.summary =
|
11
|
+
s.extra_rdoc_files = ["README.md"]
|
12
|
+
s.summary = "Provisioner for creating vSphere VM instances in Chef Provisioning."
|
13
13
|
s.description = s.summary
|
14
|
-
s.authors = [
|
15
|
-
s.email =
|
16
|
-
s.homepage =
|
17
|
-
s.license =
|
18
|
-
s.bindir =
|
19
|
-
s.executables = %w
|
20
|
-
s.require_path =
|
14
|
+
s.authors = ["CenturyLink Cloud", "JJ Asghar"]
|
15
|
+
s.email = "jj@chef.io"
|
16
|
+
s.homepage = "https://github.com/chef-partners/chef-provisioning-vsphere"
|
17
|
+
s.license = "MIT"
|
18
|
+
s.bindir = "bin"
|
19
|
+
s.executables = %w{}
|
20
|
+
s.require_path = "lib"
|
21
21
|
s.files = `git ls-files -z`.split("\x0")
|
22
22
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
23
23
|
|
24
|
-
s.add_dependency
|
25
|
-
s.add_dependency
|
26
|
-
s.add_dependency
|
27
|
-
s.add_dependency
|
24
|
+
s.add_dependency "chef", ">= 12.0"
|
25
|
+
s.add_dependency "chef-provisioning", "~> 2.0"
|
26
|
+
s.add_dependency "cheffish", ">= 4.0"
|
27
|
+
s.add_dependency "rbvmomi", "~> 1.10"
|
28
28
|
|
29
|
-
s.add_development_dependency
|
30
|
-
s.add_development_dependency
|
31
|
-
s.add_development_dependency
|
32
|
-
s.add_development_dependency
|
33
|
-
s.add_development_dependency
|
34
|
-
s.add_development_dependency
|
35
|
-
s.add_development_dependency
|
36
|
-
s.add_development_dependency
|
37
|
-
s.add_development_dependency
|
38
|
-
s.add_development_dependency
|
29
|
+
s.add_development_dependency "chefstyle"
|
30
|
+
s.add_development_dependency "github_changelog_generator"
|
31
|
+
s.add_development_dependency "pry"
|
32
|
+
s.add_development_dependency "pry-byebug"
|
33
|
+
s.add_development_dependency "pry-stack_explorer"
|
34
|
+
s.add_development_dependency "rake"
|
35
|
+
s.add_development_dependency "rb-readline"
|
36
|
+
s.add_development_dependency "rspec"
|
37
|
+
s.add_development_dependency "simplecov"
|
38
|
+
s.add_development_dependency "yard"
|
39
39
|
end
|
@@ -1,31 +1,32 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "chef/provisioning"
|
3
|
+
require "chef/provisioning/vsphere_driver"
|
3
4
|
|
4
5
|
#
|
5
6
|
# This is the main way to connect to vSphere
|
6
7
|
#
|
7
|
-
with_vsphere_driver host:
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
with_vsphere_driver host: "172.16.20.2",
|
9
|
+
insecure: true,
|
10
|
+
user: "administrator@vsphere.local",
|
11
|
+
password: "PASSWORD"
|
11
12
|
|
12
13
|
#
|
13
14
|
# These are the machine_options that you need to declare
|
14
15
|
#
|
15
|
-
with_machine_options :
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
16
|
+
with_machine_options bootstrap_options: {
|
17
|
+
num_cpus: 2,
|
18
|
+
memory_mb: 4096,
|
19
|
+
datacenter: "Datacenter",
|
20
|
+
resource_pool: "Cluster",
|
21
|
+
template_folder: "Linux",
|
22
|
+
template_name: "ubuntu16",
|
23
|
+
ssh: {
|
24
|
+
user: "admini",
|
25
|
+
password: "PASSWORD",
|
26
|
+
paranoid: false,
|
27
|
+
},
|
28
|
+
},
|
29
|
+
sudo: true
|
29
30
|
|
30
31
|
#
|
31
32
|
# This is where you can declare the machine
|
data/examples/win-provision.rb
CHANGED
@@ -1,42 +1,41 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "chef/provisioning"
|
3
|
+
require "chef/provisioning/vsphere_driver"
|
4
4
|
|
5
5
|
#
|
6
6
|
# This is the main way to connect to vSphere
|
7
7
|
#
|
8
|
-
with_vsphere_driver host:
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
with_vsphere_driver host: "172.16.20.2",
|
9
|
+
insecure: true,
|
10
|
+
user: "administrator@vsphere.local",
|
11
|
+
password: "PASSWORD"
|
12
12
|
|
13
13
|
#
|
14
14
|
# These are the machine_options that you need to declare
|
15
15
|
#
|
16
|
-
win_bootstrap_options = { :
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
ssh_options: { :
|
31
|
-
ready_timeout:
|
32
|
-
}
|
16
|
+
win_bootstrap_options = { bootstrap_options: {
|
17
|
+
num_cpus: 2,
|
18
|
+
memory_mb: 8096,
|
19
|
+
datacenter: "Datacenter",
|
20
|
+
resource_pool: "Cluster",
|
21
|
+
template_folder: "Windows",
|
22
|
+
template_name: "windows2012R2",
|
23
|
+
ssh: {
|
24
|
+
user: "Administrator",
|
25
|
+
password: "P@ssw0rd!!!",
|
26
|
+
paranoid: false,
|
27
|
+
port: "5985",
|
28
|
+
},
|
29
|
+
},
|
30
|
+
ssh_options: { keepalive: true, keepalive_interval: 50, user_known_hosts_file: "/dev/null" },
|
31
|
+
ready_timeout: "30" }
|
33
32
|
|
34
33
|
#
|
35
34
|
# WinRM requires a Chef server (not sure why) so you need to declare it here
|
36
35
|
#
|
37
36
|
with_chef_server "https://api.chef.io/organizations/ORG",
|
38
|
-
:
|
39
|
-
:
|
37
|
+
client_name: Chef::Config[:node_name],
|
38
|
+
signing_key_filename: Chef::Config[:client_key]
|
40
39
|
|
41
40
|
#
|
42
41
|
# This is where you can declare the machine
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "chef/provisioning/vsphere_driver"
|
4
4
|
|
5
|
-
Chef::Provisioning.register_driver_class(
|
5
|
+
Chef::Provisioning.register_driver_class("vsphere", ChefProvisioningVsphere::VsphereDriver)
|
@@ -43,7 +43,7 @@ module ChefProvisioningVsphere
|
|
43
43
|
end
|
44
44
|
|
45
45
|
unless options[:network_name].nil?
|
46
|
-
deviceAdditions, changes = vsphere_helper.network_device_changes(
|
46
|
+
deviceAdditions, changes = vsphere_helper.network_device_changes( # rubocop:disable Naming/VariableName, Lint/UselessAssignment
|
47
47
|
action_handler,
|
48
48
|
vm_template,
|
49
49
|
options
|
@@ -78,12 +78,12 @@ module ChefProvisioningVsphere
|
|
78
78
|
elsif vm_template.config.template && !host.nil?
|
79
79
|
rspec.pool = host.parent.resourcePool # assign to the "invisible" pool root
|
80
80
|
elsif vm_template.config.template
|
81
|
-
raise
|
81
|
+
raise "either :host or :resource_pool must be specified when cloning from a VM Template"
|
82
82
|
end
|
83
83
|
|
84
84
|
if options[:use_linked_clone]
|
85
85
|
if vm_template.config.template
|
86
|
-
Chef::Log.warn(
|
86
|
+
Chef::Log.warn("Using a VM Template, ignoring use_linked_clone.")
|
87
87
|
else
|
88
88
|
vsphere_helper.create_delta_disk(vm_template)
|
89
89
|
rspec.diskMoveType = :moveChildMostDiskBacking
|
@@ -105,16 +105,16 @@ module ChefProvisioningVsphere
|
|
105
105
|
def customization_options_from(vm_template, vm_name, options)
|
106
106
|
if options.key?(:customization_spec)
|
107
107
|
if options[:customization_spec].is_a?(Hash) ||
|
108
|
-
|
108
|
+
options[:customization_spec].is_a?(Cheffish::MergedConfig)
|
109
109
|
cust_options = options[:customization_spec]
|
110
110
|
ip_settings = cust_options[:ipsettings]
|
111
111
|
cust_domain = cust_options[:domain]
|
112
112
|
|
113
|
-
raise ArgumentError,
|
113
|
+
raise ArgumentError, "domain is required" unless cust_domain
|
114
114
|
cust_ip_settings = nil
|
115
115
|
if ip_settings && ip_settings.key?(:ip)
|
116
116
|
unless cust_options[:ipsettings].key?(:subnetMask)
|
117
|
-
raise ArgumentError,
|
117
|
+
raise ArgumentError, "subnetMask is required for static ip"
|
118
118
|
end
|
119
119
|
cust_ip_settings = RbVmomi::VIM::CustomizationIPSettings.new(
|
120
120
|
ip_settings
|
@@ -145,7 +145,7 @@ module ChefProvisioningVsphere
|
|
145
145
|
cust_hwclockutc = cust_options[:hw_clock_utc]
|
146
146
|
cust_timezone = cust_options[:time_zone]
|
147
147
|
|
148
|
-
cust_prep = if vm_template.config.guestId.start_with?(
|
148
|
+
cust_prep = if vm_template.config.guestId.start_with?("win")
|
149
149
|
windows_prep_for(options, vm_name)
|
150
150
|
else
|
151
151
|
RbVmomi::VIM::CustomizationLinuxPrep.new(
|
@@ -158,7 +158,7 @@ module ChefProvisioningVsphere
|
|
158
158
|
cust_adapter_mapping = [
|
159
159
|
RbVmomi::VIM::CustomizationAdapterMapping.new(
|
160
160
|
adapter: cust_ip_settings
|
161
|
-
)
|
161
|
+
),
|
162
162
|
]
|
163
163
|
RbVmomi::VIM::CustomizationSpec.new(
|
164
164
|
identity: cust_prep,
|
@@ -179,7 +179,7 @@ module ChefProvisioningVsphere
|
|
179
179
|
hostname = options[:hostname] || vm_name
|
180
180
|
test = /^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])$/
|
181
181
|
unless hostname.match?(test)
|
182
|
-
raise
|
182
|
+
raise "Only letters, numbers or hyphens in hostnames allowed"
|
183
183
|
end
|
184
184
|
RbVmomi::VIM::CustomizationFixedName.new(name: hostname)
|
185
185
|
end
|
@@ -200,10 +200,10 @@ module ChefProvisioningVsphere
|
|
200
200
|
plainText: true,
|
201
201
|
value: options[:ssh][:password]
|
202
202
|
)
|
203
|
-
if cust_options.key?(:domain) && (cust_options[:domain] !=
|
203
|
+
if cust_options.key?(:domain) && (cust_options[:domain] != "local")
|
204
204
|
cust_domain_password = RbVmomi::VIM::CustomizationPassword(
|
205
205
|
plainText: true,
|
206
|
-
value: ENV[
|
206
|
+
value: ENV["domainAdminPassword"] || cust_options[:domainAdminPassword]
|
207
207
|
)
|
208
208
|
cust_id = RbVmomi::VIM::CustomizationIdentification.new(
|
209
209
|
joinDomain: cust_options[:domain],
|
@@ -214,7 +214,7 @@ module ChefProvisioningVsphere
|
|
214
214
|
with user: #{cust_options[:domainAdmin]}"
|
215
215
|
else
|
216
216
|
cust_id = RbVmomi::VIM::CustomizationIdentification.new(
|
217
|
-
joinWorkgroup:
|
217
|
+
joinWorkgroup: "WORKGROUP"
|
218
218
|
)
|
219
219
|
end
|
220
220
|
cust_gui_unattended = RbVmomi::VIM::CustomizationGuiUnattended.new(
|