chef-provisioning-vsphere 0.8.2 → 0.8.3.dev
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/Gemfile +5 -5
- data/LICENSE +19 -19
- data/LICENSE-Rally +20 -20
- data/README.md +269 -269
- data/Rakefile +22 -22
- data/chef-provisioning-vsphere.gemspec +28 -28
- data/contribution-notice +7 -7
- data/lib/chef/provisioning/driver_init/vsphere.rb +2 -2
- data/lib/chef/provisioning/vsphere_driver/clone_spec_builder.rb +205 -205
- data/lib/chef/provisioning/vsphere_driver/driver.rb +679 -671
- data/lib/chef/provisioning/vsphere_driver/version.rb +3 -3
- data/lib/chef/provisioning/vsphere_driver/vsphere_helpers.rb +341 -341
- data/lib/chef/provisioning/vsphere_driver/vsphere_url.rb +45 -45
- data/lib/chef/provisioning/vsphere_driver.rb +14 -14
- data/lib/kitchen/driver/vsphere.rb +104 -104
- data/spec/integration_tests/.gitignore +1 -1
- data/spec/integration_tests/vsphere_driver_spec.rb +158 -158
- data/spec/unit_tests/VsphereDriver_spec.rb +132 -132
- data/spec/unit_tests/VsphereUrl_spec.rb +65 -65
- data/spec/unit_tests/clone_spec_builder_spec.rb +161 -161
- data/spec/unit_tests/support/fake_action_handler.rb +7 -7
- data/spec/unit_tests/support/vsphere_helper_stub.rb +52 -52
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 205c191d6d4a47b7a8361044f025c4052575acbf
|
4
|
+
data.tar.gz: ba941015bab978b4a23d1c49207779a4ade04941
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3e99c1ee9f2c9b25ef8bb2cd0e443365b932e84c25cc9802f75f6339272b337632e03515defde6e054fbd9937b133d2e97beabb96341d543fd9d63e081a65ed
|
7
|
+
data.tar.gz: 8c9dff35325ae5329ac0a23d28eaa9ce63d9f292f23436faeebe21d8a50122e5157d43d640efd51f432f639283aa5def49838b745cf9d0e7acc32aec889ab510
|
data/.gitignore
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
pkg/
|
2
|
-
Gemfile.lock
|
1
|
+
pkg/
|
2
|
+
Gemfile.lock
|
3
3
|
*.gem
|
data/Gemfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
source "https://rubygems.org"
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
gem "chef", "~> 12.3"
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
source "https://rubygems.org"
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem "chef", "~> 12.3"
|
data/LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2015 CenturyLink
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
1
|
+
Copyright (c) 2015 CenturyLink
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/LICENSE-Rally
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2014 Rally Software Development Corp
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2014 Rally Software Development Corp
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,269 +1,269 @@
|
|
1
|
-
chef-provisioning-vsphere
|
2
|
-
==================
|
3
|
-
|
4
|
-
This is a [chef-provisioning](https://github.com/opscode/chef-provisioning) provisioner for [VMware vSphere](http://www.vmware.com/products/vsphere).
|
5
|
-
|
6
|
-
chef-provisioning-vsphere supports provisioning Unix/ssh and Windows/winrm guest VMs.
|
7
|
-
|
8
|
-
## Prerequisites
|
9
|
-
|
10
|
-
### Vsphere infrastructure
|
11
|
-
|
12
|
-
A vcenter and valid login credentials.
|
13
|
-
|
14
|
-
### VM Template
|
15
|
-
|
16
|
-
A VM template capable of installing Chef 11.8 or newer. This can be either windows or linux flavored.
|
17
|
-
|
18
|
-
### A provisioning node (can be local)
|
19
|
-
|
20
|
-
An environment equipped with the chef client and the chef-provisioning-vsphere gem.
|
21
|
-
|
22
|
-
## A basic provisioning recipe
|
23
|
-
|
24
|
-
This is a minimal machine definition that will use a dhcp assigned ip (it assumes the presense of a dhcp server). For test purposes this uses a linked clone for a faster provisioning time. This recipe should be used with a linux template. Windows provisioned servers need to point to a chef server for the cookbooks since winrm does not support port forwarding and there fore cannot reach back on the chef-zero port to get the local cookbooks. See examples below.
|
25
|
-
|
26
|
-
```
|
27
|
-
chef_gem 'chef-provisioning-vsphere' do
|
28
|
-
action :install
|
29
|
-
compile_time true
|
30
|
-
end
|
31
|
-
|
32
|
-
require 'chef/provisioning/vsphere_driver'
|
33
|
-
|
34
|
-
with_vsphere_driver host: 'vcenter-host-name',
|
35
|
-
insecure: true,
|
36
|
-
user: 'you_user_name',
|
37
|
-
password: 'your_mothers_maiden_name'
|
38
|
-
|
39
|
-
with_machine_options :bootstrap_options => {
|
40
|
-
use_linked_clone: true,
|
41
|
-
num_cpus: 2,
|
42
|
-
memory_mb: 4096,
|
43
|
-
network_name: ["vlan_20_172.21.20"],
|
44
|
-
datacenter: 'datacenter_name',
|
45
|
-
resource_pool: 'cluster',
|
46
|
-
template_name: 'path to template',
|
47
|
-
customization_spec: {
|
48
|
-
ipsettings: {
|
49
|
-
dnsServerList: ['1.2.3.31','1.2.3.41']
|
50
|
-
},
|
51
|
-
:domain => 'local'
|
52
|
-
}
|
53
|
-
:ssh => {
|
54
|
-
:user => 'root',
|
55
|
-
:password => 'password',
|
56
|
-
:paranoid => false,
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
machine "my_machine_name" do
|
61
|
-
run_list ['my_cookbook::default']
|
62
|
-
end
|
63
|
-
|
64
|
-
```
|
65
|
-
|
66
|
-
## Provision!
|
67
|
-
|
68
|
-
```
|
69
|
-
chef-client -z -o 'my_cookbook::provision'
|
70
|
-
```
|
71
|
-
|
72
|
-
This will use chef-zero and needs no chef server (only works for ssh). Note that chef-zero does not support berkshelf style cookbook dependency resolution. So this works if the cookbook in the machine's runlist has no external dependencies. If it needs to reach out to supermarket or another berkshelf API server, perform a `berks vendor` to pull down the dependencies first.
|
73
|
-
|
74
|
-
## Supported machine bootstrapping options
|
75
|
-
|
76
|
-
- `[:use_linked_clone]` - (true/false) great for testing but not recommended for production.
|
77
|
-
- `[:datacenter]` - Name of vsphere datacenter (*required*)
|
78
|
-
- `[:template_name]` - path to vmware template (can be template or a shutown vm) (*required*)
|
79
|
-
- `[:template_folder]` - path to a folder containing the template (do not use if template is in the root vm folder)
|
80
|
-
- `[:vm_folder]` - path to a folder where the machine will be created.
|
81
|
-
- `[:datastore]` - name of datastore to use
|
82
|
-
- `[:num_cpus]` - number of cpus to allocate to machine
|
83
|
-
- `[:network_name]` - array of network names to use. A NIC will be added for each
|
84
|
-
- `[:memory_mb]` - number of megabytes to allocate for machine
|
85
|
-
- `[:host]` - `{cluster}`/`{host}` to use during provisioning
|
86
|
-
- `[:resource_pool]` - `{cluster}`/`{resource pool}` to use during provisioning
|
87
|
-
- `[:additional_disk_size_gb]` - an array of numbers, each signifying the number of gigabytes to assign to an additional disk (*his requires a datastore to be specified*)
|
88
|
-
- `[:ssh][:user]` user to use for ssh/winrm (defaults to root on linux/administrator on windows)
|
89
|
-
- `[:ssh][:password]` - password to use for ssh/winrm
|
90
|
-
- `[:ssh][:paranoid]` - specifies the strictness of the host key verification checking
|
91
|
-
- `[:ssh][:port]` port to use for ssh/winrm (defaults to 22 for ssh or 5985 for winrm)
|
92
|
-
- `[:convergence_options][:install_msi_url]` - url to chef client msi to use (defaults to latest)
|
93
|
-
- `[:convergence_options][:install_sh_url]` - the bach script to install chef client on linux (defaults to latest)
|
94
|
-
- `[:customization_spec][:ipsettings][:ip]` static ip to assign to machine
|
95
|
-
- `[:customization_spec][:ipsettings][:subnetMask]` - subnet to use
|
96
|
-
- `[:customization_spec][:ipsettings][:gateway]` - array of possible gateways to use (this will most often be an array of 1)
|
97
|
-
- `[:customization_spec][:ipsettings][:dnsServerList]` - array of DNS servers to use
|
98
|
-
- `[:customization_spec][:domain]` - domain to use (if not 'local' on a windows machine it will attempt to domain join)
|
99
|
-
- `[:customization_spec][:domainAdmin]` - domain admin account to use for domain join on windows (should be `{user name}`@`{domain}`)
|
100
|
-
- `[:customization_spec][:domainAdminPassword]` - domain administrator password
|
101
|
-
- `[:customization_spec][:hostname]` - hostname to use. Defaults to machine resource name if not provided
|
102
|
-
- `[:customization_spec][:org_name]` - org name used in sysprep on windows
|
103
|
-
- `[:customization_spec][:product_id]` - windows product key
|
104
|
-
- `[:customization_spec][:time_zone]` - The case-sensitive timezone, such as Europe/Sofia based on the tz (timezone) database used by Linux and other Unix systems
|
105
|
-
- `[:customization_spec][:win_time_zone]` - numeric time zone for windows
|
106
|
-
|
107
|
-
## Timeout options
|
108
|
-
These are settings set at the root of `machine_options`. Chances are the defaults for these settings do not need to be changed:
|
109
|
-
|
110
|
-
- `start_timeout` - number of seconds to wait for a machine to be accessible after a restart (default 10 minutes)
|
111
|
-
- `create_timeout` - number of seconds to wait for a machine to be accessible after initiating provisioning (default 10 minutes)
|
112
|
-
- `ready_timeout` - number of seconds to wait for customization to complete and vmware tools to come on line (default 5 minutes)
|
113
|
-
|
114
|
-
## More config examples
|
115
|
-
|
116
|
-
### Static IP and two additional disks of 20 and 50GB
|
117
|
-
|
118
|
-
```
|
119
|
-
with_machine_options :bootstrap_options => {
|
120
|
-
use_linked_clone: true,
|
121
|
-
num_cpus: 2,
|
122
|
-
memory_mb: 4096,
|
123
|
-
network_name: ["vlan_20_172.21.20"],
|
124
|
-
datacenter: 'datacenter_name',
|
125
|
-
resource_pool: 'cluster',
|
126
|
-
template_name: 'path to template',
|
127
|
-
datastore: "my_data_store",
|
128
|
-
additional_disk_size_gb: [50,20],
|
129
|
-
customization_spec: {
|
130
|
-
ipsettings: {
|
131
|
-
ip: '192.168.3.4',
|
132
|
-
subnetMask: '255.255.255.0',
|
133
|
-
gateway: ["192.168.3.1"],
|
134
|
-
dnsServerList: ['1.2.3.31','1.2.3.41']
|
135
|
-
},
|
136
|
-
:domain => 'local'
|
137
|
-
}
|
138
|
-
:ssh => {
|
139
|
-
:user => 'root',
|
140
|
-
:password => 'password',
|
141
|
-
:paranoid => false,
|
142
|
-
}
|
143
|
-
}
|
144
|
-
```
|
145
|
-
|
146
|
-
### Domain joined windows machine
|
147
|
-
|
148
|
-
```
|
149
|
-
with_machine_options :bootstrap_options => {
|
150
|
-
use_linked_clone: true,
|
151
|
-
num_cpus: 2,
|
152
|
-
memory_mb: 4096,
|
153
|
-
network_name: ['vlan_20_172.21.20'],
|
154
|
-
datacenter: 'datacenter_name',
|
155
|
-
resource_pool: 'cluster',
|
156
|
-
template_name: 'path to template',
|
157
|
-
customization_spec: {
|
158
|
-
ipsettings: {
|
159
|
-
dnsServerList: ['1.2.3.31','1.2.3.41']
|
160
|
-
},
|
161
|
-
domain: 'blah.com',
|
162
|
-
domainAdmin: 'administrator@blah.com',
|
163
|
-
domainAdminPassword: 'Passwordyoyoyo',
|
164
|
-
org_name: 'acme',
|
165
|
-
product_id: 'CDAA-87DC-3455-FF77-2AAC',
|
166
|
-
win_time_zone: 4
|
167
|
-
}
|
168
|
-
ssh: {
|
169
|
-
user: 'administrator',
|
170
|
-
password: 'password',
|
171
|
-
paranoid: false,
|
172
|
-
}
|
173
|
-
},
|
174
|
-
:convergence_options => {
|
175
|
-
:ssl_verify_mode => :verify_none
|
176
|
-
}
|
177
|
-
```
|
178
|
-
Note: You must run chef-client against a server for a windows box. You can do this locally since the provisioning recipe should not change the state of the provisioner. You will need to upload the cookbook (both the one doing the provisioning and the one used in the provisioned machine's runlist) before running `chef-client`.
|
179
|
-
|
180
|
-
```
|
181
|
-
knife cookbook upload my_cookbook
|
182
|
-
chef-client -o 'my_cookbook::provision' -c .chef/knife.rb
|
183
|
-
```
|
184
|
-
|
185
|
-
### Prefix all SSH commands with 'sudo ', for installing on hosts where options[:bootstrap_options][:ssh][:user] is not 'root'. The user must have 'NOPASSWD:ALL' in /etc/sudoers. This is compatible with chef-provisioning-fog functionality
|
186
|
-
|
187
|
-
```
|
188
|
-
chef_gem 'chef-provisioning-vsphere' do
|
189
|
-
action :install
|
190
|
-
compile_time true
|
191
|
-
end
|
192
|
-
|
193
|
-
require 'chef/provisioning/vsphere_driver'
|
194
|
-
|
195
|
-
with_vsphere_driver host: 'vcenter-host-name',
|
196
|
-
insecure: true,
|
197
|
-
user: 'you_user_name',
|
198
|
-
password: 'your_mothers_maiden_name'
|
199
|
-
|
200
|
-
with_machine_options :bootstrap_options => {
|
201
|
-
use_linked_clone: true,
|
202
|
-
num_cpus: 2,
|
203
|
-
memory_mb: 4096,
|
204
|
-
network_name: ["vlan_20_172.21.20"],
|
205
|
-
datacenter: 'datacenter_name',
|
206
|
-
resource_pool: 'cluster',
|
207
|
-
template_name: 'path to template',
|
208
|
-
customization_spec: {
|
209
|
-
ipsettings: {
|
210
|
-
dnsServerList: ['1.2.3.31','1.2.3.41']
|
211
|
-
},
|
212
|
-
:domain => 'local'
|
213
|
-
}
|
214
|
-
:ssh => {
|
215
|
-
:user => 'root',
|
216
|
-
:password => 'password',
|
217
|
-
:paranoid => false,
|
218
|
-
}
|
219
|
-
},
|
220
|
-
:sudo => true
|
221
|
-
|
222
|
-
machine "my_machine_name" do
|
223
|
-
run_list ['my_cookbook::default']
|
224
|
-
end
|
225
|
-
|
226
|
-
```
|
227
|
-
## Kitchen Driver
|
228
|
-
|
229
|
-
This chef-provisioning-driver comes with a test-kitchen driver. Here are example driver options you can add to your `kitchen.yml`.
|
230
|
-
|
231
|
-
```
|
232
|
-
driver_plugin: vsphere
|
233
|
-
driver_config:
|
234
|
-
driver_options:
|
235
|
-
host: '1.2.3.5'
|
236
|
-
user: 'user'
|
237
|
-
password: 'pass'
|
238
|
-
insecure: true
|
239
|
-
machine_options:
|
240
|
-
start_timeout: 600
|
241
|
-
create_timeout: 600
|
242
|
-
ready_timeout: 90
|
243
|
-
bootstrap_options:
|
244
|
-
use_linked_clone: true
|
245
|
-
datacenter: 'DC'
|
246
|
-
template_name: 'UBUNTU1264'
|
247
|
-
vm_folder: 'TEST'
|
248
|
-
num_cpus: 2,
|
249
|
-
network_name:
|
250
|
-
- vlan_20_1.2.3.4
|
251
|
-
memory_mb: 4096
|
252
|
-
resource_pool: 'CLSTR/TEST'
|
253
|
-
ssh:
|
254
|
-
user: root
|
255
|
-
paranoid: false
|
256
|
-
password: password
|
257
|
-
port: 22
|
258
|
-
convergence_options:
|
259
|
-
customization_spec:
|
260
|
-
domain: local
|
261
|
-
ipsettings:
|
262
|
-
dnsServerList:
|
263
|
-
- 8.8.8.8
|
264
|
-
- 8.8.4.4
|
265
|
-
```
|
266
|
-
|
267
|
-
## Contributions are welcome!
|
268
|
-
|
269
|
-
We took care to make this driver as generic as possible but there wll certainly be implementation nuances that may not work for everyone. We are happy to accept contributions to improve the driver and make it more accessible to a broader set of use cases.
|
1
|
+
chef-provisioning-vsphere
|
2
|
+
==================
|
3
|
+
|
4
|
+
This is a [chef-provisioning](https://github.com/opscode/chef-provisioning) provisioner for [VMware vSphere](http://www.vmware.com/products/vsphere).
|
5
|
+
|
6
|
+
chef-provisioning-vsphere supports provisioning Unix/ssh and Windows/winrm guest VMs.
|
7
|
+
|
8
|
+
## Prerequisites
|
9
|
+
|
10
|
+
### Vsphere infrastructure
|
11
|
+
|
12
|
+
A vcenter and valid login credentials.
|
13
|
+
|
14
|
+
### VM Template
|
15
|
+
|
16
|
+
A VM template capable of installing Chef 11.8 or newer. This can be either windows or linux flavored.
|
17
|
+
|
18
|
+
### A provisioning node (can be local)
|
19
|
+
|
20
|
+
An environment equipped with the chef client and the chef-provisioning-vsphere gem.
|
21
|
+
|
22
|
+
## A basic provisioning recipe
|
23
|
+
|
24
|
+
This is a minimal machine definition that will use a dhcp assigned ip (it assumes the presense of a dhcp server). For test purposes this uses a linked clone for a faster provisioning time. This recipe should be used with a linux template. Windows provisioned servers need to point to a chef server for the cookbooks since winrm does not support port forwarding and there fore cannot reach back on the chef-zero port to get the local cookbooks. See examples below.
|
25
|
+
|
26
|
+
```
|
27
|
+
chef_gem 'chef-provisioning-vsphere' do
|
28
|
+
action :install
|
29
|
+
compile_time true
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'chef/provisioning/vsphere_driver'
|
33
|
+
|
34
|
+
with_vsphere_driver host: 'vcenter-host-name',
|
35
|
+
insecure: true,
|
36
|
+
user: 'you_user_name',
|
37
|
+
password: 'your_mothers_maiden_name'
|
38
|
+
|
39
|
+
with_machine_options :bootstrap_options => {
|
40
|
+
use_linked_clone: true,
|
41
|
+
num_cpus: 2,
|
42
|
+
memory_mb: 4096,
|
43
|
+
network_name: ["vlan_20_172.21.20"],
|
44
|
+
datacenter: 'datacenter_name',
|
45
|
+
resource_pool: 'cluster',
|
46
|
+
template_name: 'path to template',
|
47
|
+
customization_spec: {
|
48
|
+
ipsettings: {
|
49
|
+
dnsServerList: ['1.2.3.31','1.2.3.41']
|
50
|
+
},
|
51
|
+
:domain => 'local'
|
52
|
+
}
|
53
|
+
:ssh => {
|
54
|
+
:user => 'root',
|
55
|
+
:password => 'password',
|
56
|
+
:paranoid => false,
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
machine "my_machine_name" do
|
61
|
+
run_list ['my_cookbook::default']
|
62
|
+
end
|
63
|
+
|
64
|
+
```
|
65
|
+
|
66
|
+
## Provision!
|
67
|
+
|
68
|
+
```
|
69
|
+
chef-client -z -o 'my_cookbook::provision'
|
70
|
+
```
|
71
|
+
|
72
|
+
This will use chef-zero and needs no chef server (only works for ssh). Note that chef-zero does not support berkshelf style cookbook dependency resolution. So this works if the cookbook in the machine's runlist has no external dependencies. If it needs to reach out to supermarket or another berkshelf API server, perform a `berks vendor` to pull down the dependencies first.
|
73
|
+
|
74
|
+
## Supported machine bootstrapping options
|
75
|
+
|
76
|
+
- `[:use_linked_clone]` - (true/false) great for testing but not recommended for production.
|
77
|
+
- `[:datacenter]` - Name of vsphere datacenter (*required*)
|
78
|
+
- `[:template_name]` - path to vmware template (can be template or a shutown vm) (*required*)
|
79
|
+
- `[:template_folder]` - path to a folder containing the template (do not use if template is in the root vm folder)
|
80
|
+
- `[:vm_folder]` - path to a folder where the machine will be created.
|
81
|
+
- `[:datastore]` - name of datastore to use
|
82
|
+
- `[:num_cpus]` - number of cpus to allocate to machine
|
83
|
+
- `[:network_name]` - array of network names to use. A NIC will be added for each
|
84
|
+
- `[:memory_mb]` - number of megabytes to allocate for machine
|
85
|
+
- `[:host]` - `{cluster}`/`{host}` to use during provisioning
|
86
|
+
- `[:resource_pool]` - `{cluster}`/`{resource pool}` to use during provisioning
|
87
|
+
- `[:additional_disk_size_gb]` - an array of numbers, each signifying the number of gigabytes to assign to an additional disk (*his requires a datastore to be specified*)
|
88
|
+
- `[:ssh][:user]` user to use for ssh/winrm (defaults to root on linux/administrator on windows)
|
89
|
+
- `[:ssh][:password]` - password to use for ssh/winrm
|
90
|
+
- `[:ssh][:paranoid]` - specifies the strictness of the host key verification checking
|
91
|
+
- `[:ssh][:port]` port to use for ssh/winrm (defaults to 22 for ssh or 5985 for winrm)
|
92
|
+
- `[:convergence_options][:install_msi_url]` - url to chef client msi to use (defaults to latest)
|
93
|
+
- `[:convergence_options][:install_sh_url]` - the bach script to install chef client on linux (defaults to latest)
|
94
|
+
- `[:customization_spec][:ipsettings][:ip]` static ip to assign to machine
|
95
|
+
- `[:customization_spec][:ipsettings][:subnetMask]` - subnet to use
|
96
|
+
- `[:customization_spec][:ipsettings][:gateway]` - array of possible gateways to use (this will most often be an array of 1)
|
97
|
+
- `[:customization_spec][:ipsettings][:dnsServerList]` - array of DNS servers to use
|
98
|
+
- `[:customization_spec][:domain]` - domain to use (if not 'local' on a windows machine it will attempt to domain join)
|
99
|
+
- `[:customization_spec][:domainAdmin]` - domain admin account to use for domain join on windows (should be `{user name}`@`{domain}`)
|
100
|
+
- `[:customization_spec][:domainAdminPassword]` - domain administrator password
|
101
|
+
- `[:customization_spec][:hostname]` - hostname to use. Defaults to machine resource name if not provided
|
102
|
+
- `[:customization_spec][:org_name]` - org name used in sysprep on windows
|
103
|
+
- `[:customization_spec][:product_id]` - windows product key
|
104
|
+
- `[:customization_spec][:time_zone]` - The case-sensitive timezone, such as Europe/Sofia based on the tz (timezone) database used by Linux and other Unix systems
|
105
|
+
- `[:customization_spec][:win_time_zone]` - numeric time zone for windows
|
106
|
+
|
107
|
+
## Timeout options
|
108
|
+
These are settings set at the root of `machine_options`. Chances are the defaults for these settings do not need to be changed:
|
109
|
+
|
110
|
+
- `start_timeout` - number of seconds to wait for a machine to be accessible after a restart (default 10 minutes)
|
111
|
+
- `create_timeout` - number of seconds to wait for a machine to be accessible after initiating provisioning (default 10 minutes)
|
112
|
+
- `ready_timeout` - number of seconds to wait for customization to complete and vmware tools to come on line (default 5 minutes)
|
113
|
+
|
114
|
+
## More config examples
|
115
|
+
|
116
|
+
### Static IP and two additional disks of 20 and 50GB
|
117
|
+
|
118
|
+
```
|
119
|
+
with_machine_options :bootstrap_options => {
|
120
|
+
use_linked_clone: true,
|
121
|
+
num_cpus: 2,
|
122
|
+
memory_mb: 4096,
|
123
|
+
network_name: ["vlan_20_172.21.20"],
|
124
|
+
datacenter: 'datacenter_name',
|
125
|
+
resource_pool: 'cluster',
|
126
|
+
template_name: 'path to template',
|
127
|
+
datastore: "my_data_store",
|
128
|
+
additional_disk_size_gb: [50,20],
|
129
|
+
customization_spec: {
|
130
|
+
ipsettings: {
|
131
|
+
ip: '192.168.3.4',
|
132
|
+
subnetMask: '255.255.255.0',
|
133
|
+
gateway: ["192.168.3.1"],
|
134
|
+
dnsServerList: ['1.2.3.31','1.2.3.41']
|
135
|
+
},
|
136
|
+
:domain => 'local'
|
137
|
+
}
|
138
|
+
:ssh => {
|
139
|
+
:user => 'root',
|
140
|
+
:password => 'password',
|
141
|
+
:paranoid => false,
|
142
|
+
}
|
143
|
+
}
|
144
|
+
```
|
145
|
+
|
146
|
+
### Domain joined windows machine
|
147
|
+
|
148
|
+
```
|
149
|
+
with_machine_options :bootstrap_options => {
|
150
|
+
use_linked_clone: true,
|
151
|
+
num_cpus: 2,
|
152
|
+
memory_mb: 4096,
|
153
|
+
network_name: ['vlan_20_172.21.20'],
|
154
|
+
datacenter: 'datacenter_name',
|
155
|
+
resource_pool: 'cluster',
|
156
|
+
template_name: 'path to template',
|
157
|
+
customization_spec: {
|
158
|
+
ipsettings: {
|
159
|
+
dnsServerList: ['1.2.3.31','1.2.3.41']
|
160
|
+
},
|
161
|
+
domain: 'blah.com',
|
162
|
+
domainAdmin: 'administrator@blah.com',
|
163
|
+
domainAdminPassword: 'Passwordyoyoyo',
|
164
|
+
org_name: 'acme',
|
165
|
+
product_id: 'CDAA-87DC-3455-FF77-2AAC',
|
166
|
+
win_time_zone: 4
|
167
|
+
}
|
168
|
+
ssh: {
|
169
|
+
user: 'administrator',
|
170
|
+
password: 'password',
|
171
|
+
paranoid: false,
|
172
|
+
}
|
173
|
+
},
|
174
|
+
:convergence_options => {
|
175
|
+
:ssl_verify_mode => :verify_none
|
176
|
+
}
|
177
|
+
```
|
178
|
+
Note: You must run chef-client against a server for a windows box. You can do this locally since the provisioning recipe should not change the state of the provisioner. You will need to upload the cookbook (both the one doing the provisioning and the one used in the provisioned machine's runlist) before running `chef-client`.
|
179
|
+
|
180
|
+
```
|
181
|
+
knife cookbook upload my_cookbook
|
182
|
+
chef-client -o 'my_cookbook::provision' -c .chef/knife.rb
|
183
|
+
```
|
184
|
+
|
185
|
+
### Prefix all SSH commands with 'sudo ', for installing on hosts where options[:bootstrap_options][:ssh][:user] is not 'root'. The user must have 'NOPASSWD:ALL' in /etc/sudoers. This is compatible with chef-provisioning-fog functionality
|
186
|
+
|
187
|
+
```
|
188
|
+
chef_gem 'chef-provisioning-vsphere' do
|
189
|
+
action :install
|
190
|
+
compile_time true
|
191
|
+
end
|
192
|
+
|
193
|
+
require 'chef/provisioning/vsphere_driver'
|
194
|
+
|
195
|
+
with_vsphere_driver host: 'vcenter-host-name',
|
196
|
+
insecure: true,
|
197
|
+
user: 'you_user_name',
|
198
|
+
password: 'your_mothers_maiden_name'
|
199
|
+
|
200
|
+
with_machine_options :bootstrap_options => {
|
201
|
+
use_linked_clone: true,
|
202
|
+
num_cpus: 2,
|
203
|
+
memory_mb: 4096,
|
204
|
+
network_name: ["vlan_20_172.21.20"],
|
205
|
+
datacenter: 'datacenter_name',
|
206
|
+
resource_pool: 'cluster',
|
207
|
+
template_name: 'path to template',
|
208
|
+
customization_spec: {
|
209
|
+
ipsettings: {
|
210
|
+
dnsServerList: ['1.2.3.31','1.2.3.41']
|
211
|
+
},
|
212
|
+
:domain => 'local'
|
213
|
+
}
|
214
|
+
:ssh => {
|
215
|
+
:user => 'root',
|
216
|
+
:password => 'password',
|
217
|
+
:paranoid => false,
|
218
|
+
}
|
219
|
+
},
|
220
|
+
:sudo => true
|
221
|
+
|
222
|
+
machine "my_machine_name" do
|
223
|
+
run_list ['my_cookbook::default']
|
224
|
+
end
|
225
|
+
|
226
|
+
```
|
227
|
+
## Kitchen Driver
|
228
|
+
|
229
|
+
This chef-provisioning-driver comes with a test-kitchen driver. Here are example driver options you can add to your `kitchen.yml`.
|
230
|
+
|
231
|
+
```
|
232
|
+
driver_plugin: vsphere
|
233
|
+
driver_config:
|
234
|
+
driver_options:
|
235
|
+
host: '1.2.3.5'
|
236
|
+
user: 'user'
|
237
|
+
password: 'pass'
|
238
|
+
insecure: true
|
239
|
+
machine_options:
|
240
|
+
start_timeout: 600
|
241
|
+
create_timeout: 600
|
242
|
+
ready_timeout: 90
|
243
|
+
bootstrap_options:
|
244
|
+
use_linked_clone: true
|
245
|
+
datacenter: 'DC'
|
246
|
+
template_name: 'UBUNTU1264'
|
247
|
+
vm_folder: 'TEST'
|
248
|
+
num_cpus: 2,
|
249
|
+
network_name:
|
250
|
+
- vlan_20_1.2.3.4
|
251
|
+
memory_mb: 4096
|
252
|
+
resource_pool: 'CLSTR/TEST'
|
253
|
+
ssh:
|
254
|
+
user: root
|
255
|
+
paranoid: false
|
256
|
+
password: password
|
257
|
+
port: 22
|
258
|
+
convergence_options:
|
259
|
+
customization_spec:
|
260
|
+
domain: local
|
261
|
+
ipsettings:
|
262
|
+
dnsServerList:
|
263
|
+
- 8.8.8.8
|
264
|
+
- 8.8.4.4
|
265
|
+
```
|
266
|
+
|
267
|
+
## Contributions are welcome!
|
268
|
+
|
269
|
+
We took care to make this driver as generic as possible but there wll certainly be implementation nuances that may not work for everyone. We are happy to accept contributions to improve the driver and make it more accessible to a broader set of use cases.
|