knife-esx 0.3.3 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +19 -19
- data/README.md +167 -0
- data/features/esx.feature +14 -14
- data/knife-esx.gemspec +4 -5
- data/lib/chef/knife/esx_base.rb +4 -4
- data/lib/chef/knife/esx_template_delete.rb +2 -2
- data/lib/chef/knife/esx_template_import.rb +2 -2
- data/lib/chef/knife/esx_template_list.rb +2 -2
- data/lib/chef/knife/esx_vm_create.rb +63 -63
- data/lib/chef/knife/esx_vm_delete.rb +2 -2
- data/lib/chef/knife/esx_vm_list.rb +2 -2
- data/lib/knife-esx/version.rb +2 -2
- metadata +23 -53
- data/README.rdoc +0 -85
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 07692fab1cbe917363aa1eaa8ccd680e1f653604
|
4
|
+
data.tar.gz: d13e0a6c19719120c7a7d9294120d29067455de0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 885e8348b70109767be7436a7d601f00c769e148a193062b9c3b42758a8d8efb24d4969453018c21f42c1bba4a9c83ba42ed4a21b15210fcbe98131a05311435
|
7
|
+
data.tar.gz: cce8cc969042060ded5a6c6b1d3d2fdf0d836d4c6ca4f878b6d4b9930a3c218f1c32564f05c356d412594c922f0290e0e6c47e37e936c1dbf42cb0129650d584
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/CHANGELOG.md
CHANGED
@@ -10,9 +10,9 @@ Added template commands
|
|
10
10
|
knife esx template import --esx-password password \
|
11
11
|
--esx-host esx-test-host \
|
12
12
|
/path/to/template.vmdk
|
13
|
-
|
13
|
+
|
14
14
|
knife esx template list --esx-password password \
|
15
|
-
--esx-host esx-test-host
|
15
|
+
--esx-host esx-test-host
|
16
16
|
|
17
17
|
knife esx template delete --esx-password password \
|
18
18
|
--esx-host esx-test-host \
|
@@ -64,7 +64,7 @@ Sample batch config for "knife esx vm create":
|
|
64
64
|
---
|
65
65
|
:tc01:
|
66
66
|
'use-template': template.vmdk
|
67
|
-
'extra-args': --no-host-key-verify
|
67
|
+
'extra-args': --no-host-key-verify
|
68
68
|
'vm-memory': 128
|
69
69
|
'esx-host': esx-test-host
|
70
70
|
'esx-password': password
|
@@ -73,7 +73,7 @@ Sample batch config for "knife esx vm create":
|
|
73
73
|
'datastore': datastore1
|
74
74
|
:tc02:
|
75
75
|
'use-template': template.vmdk
|
76
|
-
'extra-args': --no-host-key-verify
|
76
|
+
'extra-args': --no-host-key-verify
|
77
77
|
'vm-memory': 128
|
78
78
|
'esx-host': esx-test-host
|
79
79
|
'esx-password': password
|
@@ -91,8 +91,8 @@ Sample batch config for "knife esx vm create":
|
|
91
91
|
* **Added --batch and --async options**
|
92
92
|
|
93
93
|
Inspired by spiceweasel from Matt Ray (https://github.com/mattray/spiceweasel), I've added a batch mode where a YAML file describes the VMs you want to bootstrap and where (you can deploy to multiple hypervisors).
|
94
|
-
|
95
|
-
knife esx vm create --batch batch.yml
|
94
|
+
|
95
|
+
knife esx vm create --batch batch.yml
|
96
96
|
|
97
97
|
Sample batch.yml file:
|
98
98
|
|
@@ -100,29 +100,29 @@ Sample batch.yml file:
|
|
100
100
|
:test1:
|
101
101
|
'extra-args': --no-host-key-verify
|
102
102
|
'vm-memory': 128
|
103
|
-
'esx-host': esx-server-1
|
104
|
-
'esx-password': secret
|
103
|
+
'esx-host': esx-server-1
|
104
|
+
'esx-password': secret
|
105
105
|
'ssh-user': ubuntu
|
106
106
|
'ssh-password': ubuntu
|
107
|
-
'vm-disk': /home/
|
107
|
+
'vm-disk': /home/maintux/mnt/mirror/virtual_appliances/ubuntu1110-x64-vmware-tools.vmdk
|
108
108
|
'datastore': datastore2
|
109
109
|
:test2:
|
110
|
-
'extra-args': --no-host-key-verify
|
110
|
+
'extra-args': --no-host-key-verify
|
111
111
|
'vm-memory': 128
|
112
|
-
'esx-host': esx-server-1
|
112
|
+
'esx-host': esx-server-1
|
113
113
|
'esx-password': secret
|
114
114
|
'ssh-user': ubuntu
|
115
115
|
'ssh-password': ubuntu
|
116
|
-
'vm-disk': /home/
|
116
|
+
'vm-disk': /home/maintux/mnt/mirror/virtual_appliances/ubuntu1110-x64-vmware-tools.vmdk
|
117
117
|
'datastore': datastore2
|
118
118
|
:test3:
|
119
|
-
'extra-args': --no-host-key-verify
|
119
|
+
'extra-args': --no-host-key-verify
|
120
120
|
'vm-memory': 256
|
121
|
-
'esx-host': esx-server-1
|
121
|
+
'esx-host': esx-server-1
|
122
122
|
'esx-password': secret
|
123
123
|
'ssh-user': ubuntu
|
124
124
|
'ssh-password': ubuntu
|
125
|
-
'vm-disk': /home/
|
125
|
+
'vm-disk': /home/maintux/mnt/mirror/virtual_appliances/ubuntu1110-x64-vmware-tools.vmdk
|
126
126
|
'datastore': datastore2
|
127
127
|
|
128
128
|
This will try to create three VMs (testvm1, testvm2 and testvm3) sequentially. VM definitions inside the batch file accept all the parameters that can be used with knife-esx.
|
@@ -139,14 +139,14 @@ When using batch mode, standard output and error is redirected to /tmp/knife_esx
|
|
139
139
|
|
140
140
|
* **Added --skip-bootstrap flag**
|
141
141
|
|
142
|
-
If the flag is used the VM will be created but
|
142
|
+
If the flag is used the VM will be created but
|
143
143
|
the bootstrap template/script won't be executed (it also means that Chef won't be installed).
|
144
144
|
|
145
145
|
* **Fixed bug preventing knife-esx to create a VM when the hypervisor has an empty root password.**
|
146
146
|
|
147
147
|
**KNOWN ISSUES**
|
148
148
|
|
149
|
-
* To use --batch without --skip-bootstrap, the ssh user (--ssh-user) needs to be able to sudo without asking for a password (i.e. adding something like 'ubuntu ALL=(ALL) NOPASSWD: ALL' to /etc/sudoers in the appliance template) otherwise the bootstraping process won't work if more than one VM is being deployed.
|
149
|
+
* To use --batch without --skip-bootstrap, the ssh user (--ssh-user) needs to be able to sudo without asking for a password (i.e. adding something like 'ubuntu ALL=(ALL) NOPASSWD: ALL' to /etc/sudoers in the appliance template) otherwise the bootstraping process won't work if more than one VM is being deployed.
|
150
150
|
|
151
151
|
# 0.1.5 - 2012/02/25
|
152
152
|
|
@@ -161,7 +161,7 @@ If the flag is used the VM will be created but
|
|
161
161
|
This will create a VM with two NICs, attaching them to the VLAN-Integration and VLAN-Test networks respectively.
|
162
162
|
|
163
163
|
Fixed MAC addresses can also be assigned to each NIC using the --mac-address parameter:
|
164
|
-
|
164
|
+
|
165
165
|
knife esx vm create --vm-disk ubuntu-oneiric.vmdk \
|
166
166
|
--vm-name testvm --datastore datastore1 \
|
167
167
|
--esx-host 192.168.88.1 --ssh-user ubuntu \
|
@@ -172,7 +172,7 @@ Fixed MAC addresses can also be assigned to each NIC using the --mac-address par
|
|
172
172
|
MAC address 00:01:02:03:04:05 will be assigned to VLAN-Integration NIC and 00:01:02:03:04:06 to the VLAN-Test NIC.
|
173
173
|
|
174
174
|
If a MAC address is omitted it will be dynamically generated:
|
175
|
-
|
175
|
+
|
176
176
|
knife esx vm create --vm-disk ubuntu-oneiric.vmdk \
|
177
177
|
--vm-name testvm --datastore datastore1 \
|
178
178
|
--esx-host 192.168.88.1 --ssh-user ubuntu \
|
data/README.md
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
# Knife ESX
|
2
|
+
|
3
|
+
## DESCRIPTION:
|
4
|
+
|
5
|
+
This is the unofficial Opscode Knife plugin for ESX. This plugin gives knife the ability to create, bootstrap, and manage virtual machines in a VMWare ESX/ESXi host.
|
6
|
+
|
7
|
+
You'll need an ESX(i)4/5 host with SSH enabled and a privileged user account to connect to it via SSH.
|
8
|
+
|
9
|
+
You'll also need a base VM template (a VMDK in fact) with CentOS/Ubuntu/Fedora and vmware-tools installed.
|
10
|
+
|
11
|
+
If you're using VMWare ESXi with a free license, don't forget the `--free-license` option or you'll get the following error:
|
12
|
+
|
13
|
+
ERROR: RbVmomi::Fault: RestrictedVersion: Current license or ESXi version prohibits execution of the requested operation
|
14
|
+
|
15
|
+
Home page: http://github.com/maintux/knife-esx
|
16
|
+
|
17
|
+
## INSTALLATION:
|
18
|
+
|
19
|
+
Be sure you are running the latest version Chef. Versions earlier than 0.10.0 don't support plugins:
|
20
|
+
|
21
|
+
gem install chef
|
22
|
+
|
23
|
+
This plugin is distributed as a Ruby Gem. To install it, run:
|
24
|
+
|
25
|
+
gem install knife-esx
|
26
|
+
|
27
|
+
Depending on your system's configuration, you may need to run this command with root privileges.
|
28
|
+
|
29
|
+
## CONFIGURATION:
|
30
|
+
|
31
|
+
In order to communicate with the ESX Cloud API you will have to tell Knife about your Username and API Key. The easiest way to accomplish this is to create some entries in your `knife.rb` file:
|
32
|
+
|
33
|
+
knife[:esx_host] = "Your ESX host address"
|
34
|
+
knife[:esx_username] = "root"
|
35
|
+
knife[:esx_password] = "secret"
|
36
|
+
|
37
|
+
You also have the option of passing your ESX Host/Username/Password into the individual knife subcommands using the `--esx-host` `--esx-username` and `--esx-password` command options
|
38
|
+
|
39
|
+
## COMMAND LINE BASIC OPTIONS
|
40
|
+
|
41
|
+
<pre>
|
42
|
+
<code>
|
43
|
+
--esx-host HOST The ESX host to connect to (default: 127.0.0.1)
|
44
|
+
--esx-username USERNAME The ESX username used to connect to the host (default: root)
|
45
|
+
--esx-password PASSWORD The ESX user password
|
46
|
+
--esx-templates-dir TEMPLATES_DIRECTORY The folder where the VM template is stored
|
47
|
+
--free-license If the ESX(i) host has a free license (default: false)
|
48
|
+
--insecure Use an insecure connection (default: true)
|
49
|
+
</code>
|
50
|
+
</pre>
|
51
|
+
|
52
|
+
For subcommand specific options, refer to the related subcommand
|
53
|
+
|
54
|
+
## SUBCOMMANDS:
|
55
|
+
|
56
|
+
This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a `--help` flag
|
57
|
+
|
58
|
+
### knife esx vm create
|
59
|
+
|
60
|
+
Provisions a new virtual machine in the ESX host and then perform a Chef bootstrap (using the SSH protocol). The goal of the bootstrap is to get Chef installed on the target system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists (provided by the provisioning). It is primarily intended for Chef Client systems that talk to a Chef server. By default the virtual machine is bootstrapped using the ubuntu10.04-gems template. This can be overridden using the `-d` or `--template-file` command options.
|
61
|
+
|
62
|
+
#### _Command line options_
|
63
|
+
|
64
|
+
<pre>
|
65
|
+
<code>
|
66
|
+
--vm-disk FILE The path to the VMDK disk file
|
67
|
+
--vm-name NAME The Virtual Machine name
|
68
|
+
--vm-cpus CPUS The Virtual Machine total number of virtual cpus (for the calculation see below) (default: 1)
|
69
|
+
--vm-cpu-cores CPU_CORES The number of cores per CPU socket. The number of sockets is calculated as <CPUS>=<SOCKETS>*<CPU_CORES> (default: 1)
|
70
|
+
--datastore NAME The Datastore to use for the VM files (default: datastore1)
|
71
|
+
--guest-id NAME The VM GuestID (default: otherGuest)
|
72
|
+
--vm-memory MEM The VM memory in MB (default: 512)
|
73
|
+
-N NAME | --node-name NAME The Chef node name for your new node
|
74
|
+
--prerelease Install the pre-release chef gems
|
75
|
+
--bootstrap-version VERSION The version of Chef to install
|
76
|
+
-d DISTRO | --distro DISTRO Bootstrap a distro using a template (default: ubuntu10.04-gems)
|
77
|
+
--template-file TEMPLATE Full path to location of template to use
|
78
|
+
--use-template NAME Try to use an existing template instead of importing disk
|
79
|
+
-r RUN_LIST | --run-list RUN_LIST Comma separated list of roles/recipes to apply
|
80
|
+
-j JSON_ATTRIBUTES | --json-attributes JSON_ATTRIBUTES A JSON string to be added to the first run of chef-client
|
81
|
+
-x USERNAME | --ssh-user USERNAME The ssh username (default: root)
|
82
|
+
-P PASSWORD | --ssh-password PASSWORD The ssh password
|
83
|
+
-G GATEWAY | --ssh-gateway GATEWAY The ssh password
|
84
|
+
-i IDENTITY_FILE | --identity-file IDENTITY_FILE The SSH identity file used for authentication
|
85
|
+
--no-host-key-verify Disable host key verification
|
86
|
+
--vm-network network[,network..] Network where nic is attached to (default: 'VM Network')
|
87
|
+
-M mac[,mac..] | --mac-address mac[,mac..] Mac address list
|
88
|
+
--skip-bootstrap Skip bootstrap process (Deploy only mode)
|
89
|
+
--async Deploy the VMs asynchronously (Ignored unless combined with --batch)
|
90
|
+
--batch script.yml Use a batch file to deploy multiple VMs
|
91
|
+
</code>
|
92
|
+
</pre>
|
93
|
+
|
94
|
+
### knife esx vm delete
|
95
|
+
|
96
|
+
Deletes an existing virtual machine in the currently configured ESX host by the virtual machine name. You can find the instance id by entering 'knife esx vm list'. Please note - this does not delete the associated node and client objects from the Chef server.
|
97
|
+
|
98
|
+
#### _Command line options_
|
99
|
+
|
100
|
+
--force-delete YES|NO Don't confirm the deletion if yes (default: no)
|
101
|
+
|
102
|
+
### knife esx vm list
|
103
|
+
|
104
|
+
Outputs a list of all virtual machines in the currently configured ESX host. Please note - this shows all the virtual machines available in the ESX host, some of which may not be currently managed by the Chef server.
|
105
|
+
|
106
|
+
### knife esx template list
|
107
|
+
|
108
|
+
Outputs a list of all templates in the currently configured ESX host.
|
109
|
+
|
110
|
+
### knife esx template delete TEMPLATE_NAME
|
111
|
+
|
112
|
+
Deletes a template
|
113
|
+
|
114
|
+
#### _Command line options_
|
115
|
+
|
116
|
+
--force-delete YES|NO Don't confirm the deletion if yes (default: no)
|
117
|
+
|
118
|
+
## EXAMPLES
|
119
|
+
|
120
|
+
### Provision a new Ubuntu 11.10 VM using --vm-disk to import a local vmdk file.
|
121
|
+
|
122
|
+
knife esx vm create --template-file ~/.chef/bootstrap/ubuntu11.10-gems.erb \
|
123
|
+
--vm-disk /path-to/ubuntu1110-x64-vmware-tools.vmdk \
|
124
|
+
--vm-name knife-esx-test-ubuntu \
|
125
|
+
--datastore datastore1
|
126
|
+
--esx-host my-test-host \
|
127
|
+
--esx-password secret
|
128
|
+
|
129
|
+
### Provision a new ubuntu 12.04 VM using --use-template to specify a template on the ESXi Host.
|
130
|
+
|
131
|
+
The command assumes that you have an ubuntu template located at /vmfs/volumes/datastore1/esx-gem/templates/ubuntu12.04-template-x64.vmdk.
|
132
|
+
In this example we also changed the location of the datastore from the default datastore1 to datastore2.
|
133
|
+
|
134
|
+
knife esx vm create --esx-username root \
|
135
|
+
--vm-name ubuntu-12.04-vm \
|
136
|
+
--datastore datastore2 \
|
137
|
+
--esx-host server1 \
|
138
|
+
--esx-password secret \
|
139
|
+
--use-template ubuntu12.04-template-x64.vmdk
|
140
|
+
|
141
|
+
### Provision a new ubuntu 12.04 VM using --esx-templates-dir to specify a template directory on the ESXi host.
|
142
|
+
|
143
|
+
In this example, the template is located at /vmfs/volumes/datastore1/ubuntu12.04-template-x64/ubuntu12.04-template-x64.vmdk.
|
144
|
+
|
145
|
+
knife esx vm create --esx-username root \
|
146
|
+
--vm-name ubuntu-12.04-vm \
|
147
|
+
--datastore datastore1 \
|
148
|
+
--esx-host server1 \
|
149
|
+
--use-template ubuntu12.04-template-x64.vmdk \
|
150
|
+
--esx-templates-dir /vmfs/volumes/datastore1/ubuntu12.04-template-x64
|
151
|
+
# LICENSE:
|
152
|
+
|
153
|
+
Author:: Sergio Rubio, Massimo Maino (<maintux@gmail.com>)
|
154
|
+
Copyright:: Copyright (c) 2011 Sergio Rubio, Massimo Maino
|
155
|
+
License:: Apache License, Version 2.0
|
156
|
+
|
157
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
158
|
+
you may not use this file except in compliance with the License.
|
159
|
+
You may obtain a copy of the License at
|
160
|
+
|
161
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
162
|
+
|
163
|
+
Unless required by applicable law or agreed to in writing, software
|
164
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
165
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
166
|
+
See the License for the specific language governing permissions and
|
167
|
+
limitations under the License.
|
data/features/esx.feature
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Feature: knife esx
|
2
|
-
|
2
|
+
|
3
3
|
Scenario: Run esx create vm without arguments
|
4
4
|
When I run `knife esx vm create`
|
5
5
|
Then the output should contain:
|
@@ -13,56 +13,56 @@ Feature: knife esx
|
|
13
13
|
Scenario: Unknown esx create sub-command
|
14
14
|
When I run `knife esx create foobar`
|
15
15
|
Then the output should contain "FATAL: Cannot find sub command for:"
|
16
|
-
|
16
|
+
|
17
17
|
Scenario: Invalid VMDK file
|
18
18
|
When I run `knife esx vm create --vm-disk /tmp/foo9098jfj`
|
19
19
|
Then the output should contain "Invalid VMDK disk file (--vm-disk)"
|
20
|
-
|
20
|
+
|
21
21
|
Scenario: Missing VM name
|
22
22
|
When I run `knife esx vm create --vm-disk /tmp/test.vmdk`
|
23
23
|
Then the output should contain "ERROR: Invalid Virtual Machine name (--vm-name)"
|
24
|
-
|
24
|
+
|
25
25
|
Scenario: Missing Host option
|
26
26
|
When I run `knife esx vm create --vm-disk /tmp/test.vmdk --vm-name knife-esx-test`
|
27
27
|
Then the output should contain "ERROR: RuntimeError: host option required"
|
28
|
-
|
28
|
+
|
29
29
|
Scenario: Invalid ESX host
|
30
30
|
When I run `knife esx vm create --vm-disk /tmp/m0n0wall-stream.vmdk --vm-name knife-esx-test --esx-host localhost --esx-password temporal --datastore datastore1`
|
31
31
|
Then the output should contain "ERROR: Network Error: Connection refused"
|
32
|
-
|
32
|
+
|
33
33
|
Scenario: Invalid ESX password
|
34
34
|
When I run `knife esx vm create --vm-disk /tmp/m0n0wall-stream.vmdk --vm-name knife-esx-test --esx-host esx-test-host --esx-password oiusdf`
|
35
35
|
Then the output should contain "ERROR: RbVmomi::Fault: InvalidLogin: Cannot complete login due to an incorrect user name or password"
|
36
|
-
|
36
|
+
|
37
37
|
Scenario: Unknown host
|
38
38
|
When I run `knife esx vm create --vm-disk /tmp/m0n0wall-stream.vmdk --vm-name knife-esx-test --esx-host lllocalhost --esx-password temporal --datastore datastore1`
|
39
39
|
Then the output should contain "ERROR: Network Error: getaddrinfo: Name or service not known"
|
40
|
-
|
40
|
+
|
41
41
|
Scenario: Missing VMWare Tools in server
|
42
42
|
When I run `knife esx vm create --vm-disk /tmp/m0n0wall-stream.vmdk --vm-name knife-esx-test --esx-host esx-test-host --esx-password temporal --datastore datastore1`
|
43
43
|
Then the output should contain "Timeout trying to reach the VM. Does it have vmware-tools installed?"
|
44
|
-
|
44
|
+
|
45
45
|
Scenario: Existing VM disk in host
|
46
46
|
When I run `knife esx vm create --vm-disk /tmp/m0n0wall-stream.vmdk --vm-name knife-esx-test --esx-host esx-test-host --esx-password temporal --datastore datastore1`
|
47
47
|
Then the output should contain "ERROR: Exception: Destination file"
|
48
|
-
|
49
|
-
Scenario: Delete Existing VM
|
48
|
+
|
49
|
+
Scenario: Delete Existing VM
|
50
50
|
When I run `knife esx vm delete --force-delete yes knife-esx-test --esx-host esx-test-host --esx-password temporal`
|
51
51
|
Then the output should contain "WARNING: Deleted virtual machine knife-esx-test"
|
52
52
|
|
53
|
-
Scenario: Delete non-existent VM
|
53
|
+
Scenario: Delete non-existent VM
|
54
54
|
When I run `knife esx vm delete --force-delete yes knife-esx-test --esx-host esx-test-host --esx-password temporal`
|
55
55
|
Then the output should contain "WARNING: Virtual Machine knife-esx-test not found"
|
56
56
|
|
57
57
|
@announce
|
58
58
|
Scenario: Success bootstraping VM
|
59
|
-
When I run `knife esx vm create --template-file /home/
|
59
|
+
When I run `knife esx vm create --template-file /home/maintux/.chef/bootstrap/ubuntu11.10-gems.erb --vm-disk /home/maintux/tmp/ubuntu1110-x64-vmware-tools.vmdk --vm-name knife-esx-test-ubuntu --esx-host esx-test-host --esx-password temporal --datastore datastore1 --ssh-user ubuntu --ssh-password ubuntu --no-host-key-verify`
|
60
60
|
Then the output should contain "Done!"
|
61
61
|
|
62
62
|
Scenario: List virtual machine
|
63
63
|
When I run `knife esx vm list --esx-host esx-test-host --esx-password temporal`
|
64
64
|
Then the output should contain "knife-esx-test-ubuntu"
|
65
65
|
|
66
|
-
Scenario: Delete Existing VM
|
66
|
+
Scenario: Delete Existing VM
|
67
67
|
When I run `knife esx vm delete --force-delete yes knife-esx-test-ubuntu --esx-host esx-test-host --esx-password temporal`
|
68
68
|
Then the output should contain "WARNING: Deleted virtual machine knife-esx-test-ubuntu"
|
data/knife-esx.gemspec
CHANGED
@@ -7,19 +7,18 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Knife::ESX::VERSION
|
8
8
|
s.has_rdoc = true
|
9
9
|
s.authors = ["Sergio Rubio", "Massimo Maino"]
|
10
|
-
s.email = ["
|
11
|
-
s.homepage = "http://github.com/
|
10
|
+
s.email = ["maintux@gmail.com"]
|
11
|
+
s.homepage = "http://github.com/maintux/knife-esx"
|
12
12
|
s.summary = "ESX Support for Chef's Knife Command"
|
13
13
|
s.description = s.summary
|
14
|
-
s.extra_rdoc_files = ["README.
|
14
|
+
s.extra_rdoc_files = ["README.md", "LICENSE" ]
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.add_dependency "esx", ">= 0.4.
|
19
|
+
s.add_dependency "esx", ">= 0.4.4"
|
20
20
|
s.add_dependency "terminal-table"
|
21
21
|
s.add_dependency "chef", ">= 0.10"
|
22
|
-
s.add_dependency "celluloid", ">= 0.9"
|
23
22
|
s.add_dependency "open4"
|
24
23
|
s.require_paths = ["lib"]
|
25
24
|
|
data/lib/chef/knife/esx_base.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Sergio Rubio (<
|
3
|
-
# Copyright:: Sergio Rubio (c) 2011
|
2
|
+
# Author:: Sergio Rubio, Massimo Maino (<maintux@gmail.com>)
|
3
|
+
# Copyright:: Sergio Rubio, Massimo Maino (c) 2011
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -52,13 +52,13 @@ class Chef
|
|
52
52
|
:description => "Your ESX host address",
|
53
53
|
:default => "127.0.0.1",
|
54
54
|
:proc => Proc.new { |host| Chef::Config[:knife][:esx_host] = host }
|
55
|
-
|
55
|
+
|
56
56
|
option :free_license,
|
57
57
|
:long => "--free-license",
|
58
58
|
:description => "If your Hypervisor have a free license",
|
59
59
|
:boolean => true,
|
60
60
|
:default => false
|
61
|
-
|
61
|
+
|
62
62
|
option :insecure,
|
63
63
|
:long => "--insecure",
|
64
64
|
:description => "Insecure connection",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Sergio Rubio (<
|
3
|
-
# Copyright::
|
2
|
+
# Author:: Sergio Rubio, Massimo Maino (<maintux@gmail.com>)
|
3
|
+
# Copyright:: Sergio Rubio, Massimo Maino (c) 2011
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Sergio Rubio (<
|
3
|
-
# Copyright::
|
2
|
+
# Author:: Sergio Rubio, Massimo Maino (<maintux@gmail.com>)
|
3
|
+
# Copyright:: Sergio Rubio, Massimo Maino (c) 2011
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Sergio Rubio (<
|
3
|
-
# Copyright::
|
2
|
+
# Author:: Sergio Rubio, Massimo Maino (<maintux@gmail.com>)
|
3
|
+
# Copyright:: Sergio Rubio, Massimo Maino (c) 2011
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Sergio Rubio (<
|
3
|
-
# Copyright::
|
2
|
+
# Author:: Sergio Rubio, Massimo Maino (<maintux@gmail.com>)
|
3
|
+
# Copyright:: Sergio Rubio, Massimo Maino (c) 2011
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -18,7 +18,6 @@
|
|
18
18
|
|
19
19
|
require 'chef/knife/esx_base'
|
20
20
|
require 'open4'
|
21
|
-
require 'celluloid'
|
22
21
|
require 'singleton'
|
23
22
|
require 'yaml'
|
24
23
|
|
@@ -31,18 +30,18 @@ module KnifeESX
|
|
31
30
|
#---
|
32
31
|
#:test1:
|
33
32
|
# 'vm-memory':
|
34
|
-
# 'extra-args':
|
33
|
+
# 'extra-args':
|
35
34
|
# 'esx-host':
|
36
|
-
# 'template-file':
|
37
|
-
# 'vm-disk':
|
35
|
+
# 'template-file':
|
36
|
+
# 'vm-disk':
|
38
37
|
# 'ssh-user':
|
39
|
-
# 'ssh-password':
|
40
|
-
# 'run-list':
|
41
|
-
# 'network-interface':
|
38
|
+
# 'ssh-password':
|
39
|
+
# 'run-list':
|
40
|
+
# 'network-interface':
|
42
41
|
def initialize(batch_file)
|
43
42
|
@batch_file = batch_file
|
44
43
|
@jobs = []
|
45
|
-
@job_count = 0
|
44
|
+
@job_count = 0
|
46
45
|
(YAML.load_file batch_file).each do |i|
|
47
46
|
@jobs << DeployJob.new(i)
|
48
47
|
@job_count += 1
|
@@ -57,23 +56,8 @@ module KnifeESX
|
|
57
56
|
|
58
57
|
end
|
59
58
|
|
60
|
-
class CLogger
|
61
|
-
include Celluloid
|
62
|
-
include Singleton
|
63
|
-
|
64
|
-
def info(msg)
|
65
|
-
puts "INFO: #{msg}"
|
66
|
-
end
|
67
|
-
|
68
|
-
def error(msg)
|
69
|
-
$stderr.puts "ERROR: #{msg}"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
59
|
class DeployJob
|
74
60
|
|
75
|
-
include Celluloid
|
76
|
-
|
77
61
|
attr_reader :name
|
78
62
|
|
79
63
|
def initialize(options)
|
@@ -109,21 +93,21 @@ module KnifeESX
|
|
109
93
|
optstring << " - #{k}:".ljust(25) + "#{v}\n" unless k =~ /password/
|
110
94
|
end
|
111
95
|
log_file = "/tmp/knife_esx_vm_create_#{@name.to_s.strip.chomp.gsub(/\s/,'_')}.log"
|
112
|
-
|
113
|
-
|
96
|
+
Chef::Log.info "Bootstrapping VM #{@name} \n#{optstring.join}"
|
97
|
+
Chef::Log.info "VM #{@name} bootstrap log: #{log_file}"
|
114
98
|
@status = Open4.popen4("knife esx vm create --vm-name #{@name} #{args} #{extra_args} > #{log_file} 2>&1") do |pid, stdin, stdout, stderr|
|
115
99
|
@out << stdout.read.strip
|
116
100
|
@err << stderr.read.strip
|
117
101
|
end
|
118
102
|
if @status == 0
|
119
|
-
|
103
|
+
Chef::Log.info "[#{@name}] deployment finished OK"
|
120
104
|
else
|
121
|
-
|
105
|
+
Chef::Log.error "[#{@name}] deployment FAILED"
|
122
106
|
@err.each_line do |l|
|
123
|
-
|
107
|
+
Chef::Log.error "[#{@name}] #{l.chomp}"
|
124
108
|
end
|
125
109
|
end
|
126
|
-
return @status, @out, @err
|
110
|
+
return @status, @out, @err
|
127
111
|
end
|
128
112
|
|
129
113
|
end
|
@@ -153,17 +137,21 @@ class Chef
|
|
153
137
|
|
154
138
|
option :vm_name,
|
155
139
|
:long => "--vm-name NAME",
|
156
|
-
:description => "The Virtual Machine name"
|
140
|
+
:description => "The Virtual Machine name"
|
157
141
|
|
158
142
|
option :cpus,
|
159
143
|
:long => "--vm-cpus CPUS",
|
160
144
|
:description => "The Virtual Machine cpus (default: 1)"
|
161
145
|
|
146
|
+
option :cpu_cores,
|
147
|
+
:long => "--vm-cpu-cores CPU_CORES",
|
148
|
+
:description => "The Virtual Machine cores per cpu (default: 1)"
|
149
|
+
|
162
150
|
option :datastore,
|
163
151
|
:long => "--datastore NAME",
|
164
152
|
:default => 'datastore1',
|
165
153
|
:description => "The Datastore to use for the VM files (default: datastore1)"
|
166
|
-
|
154
|
+
|
167
155
|
option :guest_id,
|
168
156
|
:long => "--guest-id NAME",
|
169
157
|
:default => "otherGuest",
|
@@ -205,7 +193,7 @@ class Chef
|
|
205
193
|
:long => "--use-template NAME",
|
206
194
|
:description => "Try to use an existing template instead of importing disk",
|
207
195
|
:default => nil
|
208
|
-
|
196
|
+
|
209
197
|
option :run_list,
|
210
198
|
:short => "-r RUN_LIST",
|
211
199
|
:long => "--run-list RUN_LIST",
|
@@ -225,17 +213,22 @@ class Chef
|
|
225
213
|
:long => "--ssh-user USERNAME",
|
226
214
|
:description => "The ssh username; default is 'root'",
|
227
215
|
:default => "root"
|
228
|
-
|
216
|
+
|
229
217
|
option :ssh_password,
|
230
218
|
:short => "-P PASSWORD",
|
231
219
|
:long => "--ssh-password PASSWORD",
|
232
220
|
:description => "The ssh password"
|
233
221
|
|
222
|
+
option :ssh_gateway,
|
223
|
+
:short => "-G GATEWAY",
|
224
|
+
:long => "--ssh-gateway GATEWAY",
|
225
|
+
:description => "The ssh gateway"
|
226
|
+
|
234
227
|
option :identity_file,
|
235
228
|
:short => "-i IDENTITY_FILE",
|
236
229
|
:long => "--identity-file IDENTITY_FILE",
|
237
230
|
:description => "The SSH identity file used for authentication"
|
238
|
-
|
231
|
+
|
239
232
|
option :no_host_key_verify,
|
240
233
|
:long => "--no-host-key-verify",
|
241
234
|
:description => "Disable host key verification",
|
@@ -244,8 +237,7 @@ class Chef
|
|
244
237
|
:proc => Proc.new { true }
|
245
238
|
|
246
239
|
option :vm_network,
|
247
|
-
:
|
248
|
-
:long => "--vm-network",
|
240
|
+
:long => "--vm-network network[,network..]",
|
249
241
|
:description => "Network where nic is attached to",
|
250
242
|
:default => 'VM Network'
|
251
243
|
|
@@ -254,35 +246,40 @@ class Chef
|
|
254
246
|
:long => "--mac-address",
|
255
247
|
:description => "Mac address list",
|
256
248
|
:default => nil
|
257
|
-
|
249
|
+
|
258
250
|
option :skip_bootstrap,
|
259
251
|
:long => "--skip-bootstrap",
|
260
252
|
:description => "Skip bootstrap process (Deploy only mode)",
|
261
253
|
:boolean => true,
|
262
254
|
:default => false,
|
263
255
|
:proc => Proc.new { true }
|
264
|
-
|
256
|
+
|
265
257
|
option :async,
|
266
258
|
:long => "--async",
|
267
259
|
:description => "Deploy the VMs asynchronously (Ignored unless combined with --batch)",
|
268
260
|
:boolean => true,
|
269
261
|
:default => false,
|
270
262
|
:proc => Proc.new { true }
|
271
|
-
|
263
|
+
|
272
264
|
option :batch,
|
273
265
|
:long => "--batch script.yml",
|
274
266
|
:description => "Use a batch file to deploy multiple VMs",
|
275
267
|
:default => nil
|
276
|
-
|
268
|
+
|
277
269
|
def tcp_test_ssh(hostname)
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
Chef::Log.debug("sshd accepting connections on #{hostname}, banner is #{tcp_socket.gets}")
|
282
|
-
yield
|
283
|
-
true
|
270
|
+
if config[:ssh_gateway]
|
271
|
+
print "\n#{ui.color("Can't test connection through gateway, sleeping 10 seconds... ", :magenta)}"
|
272
|
+
sleep 10
|
284
273
|
else
|
285
|
-
|
274
|
+
tcp_socket = TCPSocket.new(hostname, 22)
|
275
|
+
readable = IO.select([tcp_socket], nil, nil, 5)
|
276
|
+
if readable
|
277
|
+
Chef::Log.debug("sshd accepting connections on #{hostname}, banner is #{tcp_socket.gets}")
|
278
|
+
yield
|
279
|
+
true
|
280
|
+
else
|
281
|
+
false
|
282
|
+
end
|
286
283
|
end
|
287
284
|
rescue Errno::ETIMEDOUT, Errno::EPERM
|
288
285
|
false
|
@@ -295,27 +292,27 @@ class Chef
|
|
295
292
|
|
296
293
|
def run
|
297
294
|
$stdout.sync = true
|
298
|
-
|
295
|
+
|
299
296
|
if config[:batch]
|
300
|
-
|
297
|
+
Chef::Log.info "Running in batch mode. Extra arguments will be ignored."
|
301
298
|
if not config[:async]
|
302
299
|
counter = 0
|
303
300
|
script = KnifeESX::DeployScript.new(config[:batch])
|
304
301
|
script.each_job do |job|
|
305
302
|
counter += 1
|
306
303
|
status, stdout, stderr = job.run
|
307
|
-
if status == 0
|
308
|
-
|
304
|
+
if status == 0
|
305
|
+
Chef::Log.info 'Ok'
|
309
306
|
else
|
310
|
-
|
307
|
+
Chef::Log.error 'Failed'
|
311
308
|
stderr.each_line do |l|
|
312
309
|
ui.error l
|
313
310
|
end
|
314
311
|
end
|
315
312
|
end
|
316
313
|
else
|
317
|
-
|
318
|
-
|
314
|
+
Chef::Log.info "Asynchronous boostrapping selected"
|
315
|
+
Chef::Log.info "Now do something productive while I finish my job ;)"
|
319
316
|
script = KnifeESX::DeployScript.new(config[:batch])
|
320
317
|
futures = []
|
321
318
|
script.each_job do |job|
|
@@ -333,23 +330,24 @@ class Chef
|
|
333
330
|
ui.error("You have not provided a valid VMDK file. (--vm-disk)")
|
334
331
|
exit 1
|
335
332
|
end
|
336
|
-
|
333
|
+
|
337
334
|
unless File.exist?(config[:vm_disk])
|
338
335
|
ui.error("Invalid VMDK disk file (--vm-disk)")
|
339
336
|
exit 1
|
340
337
|
end
|
341
338
|
end
|
342
|
-
|
339
|
+
|
343
340
|
vm_name = config[:vm_name]
|
344
341
|
if not vm_name
|
345
342
|
ui.error("Invalid Virtual Machine name (--vm-name)")
|
346
343
|
exit 1
|
347
344
|
end
|
348
345
|
|
349
|
-
|
346
|
+
|
350
347
|
datastore = config[:datastore]
|
351
348
|
memory = config[:memory]
|
352
349
|
cpus = config[:cpus]||1
|
350
|
+
cpu_cores = config[:cpu_cores]||1
|
353
351
|
vm_disk = config[:vm_disk]
|
354
352
|
guest_id =config[:guest_id]
|
355
353
|
destination_path = "/vmfs/volumes/#{datastore}/#{vm_name}"
|
@@ -375,21 +373,22 @@ class Chef
|
|
375
373
|
:disk_file => "#{vm_name}/#{vm_name}.vmdk",
|
376
374
|
:memory => memory,
|
377
375
|
:cpus => cpus,
|
376
|
+
:cpu_cores => cpu_cores,
|
378
377
|
:guest_id => guest_id,
|
379
378
|
:nics => create_nics(config[:vm_network], config[:mac_address])
|
380
379
|
vm.power_on
|
381
|
-
|
380
|
+
|
382
381
|
puts "#{ui.color("VM Created", :cyan)}"
|
383
382
|
puts "#{ui.color("VM Name", :cyan)}: #{vm.name}"
|
384
383
|
puts "#{ui.color("VM Memory", :cyan)}: #{(vm.memory_size.to_f/1024/1024).round} MB"
|
385
|
-
|
384
|
+
|
386
385
|
return if config[:skip_bootstrap]
|
387
386
|
|
388
387
|
# wait for it to be ready to do stuff
|
389
388
|
print "\n#{ui.color("Waiting server... ", :magenta)}"
|
390
389
|
timeout = 100
|
391
390
|
found = connection.virtual_machines.find { |v| v.name == vm.name }
|
392
|
-
loop do
|
391
|
+
loop do
|
393
392
|
if not vm.ip_address.nil? and not vm.ip_address.empty?
|
394
393
|
puts "\n#{ui.color("VM IP Address: #{vm.ip_address}", :cyan)}"
|
395
394
|
break
|
@@ -421,7 +420,7 @@ class Chef
|
|
421
420
|
bootstrap.config[:async] = config[:async]
|
422
421
|
bootstrap.config[:run_list] = config[:run_list]
|
423
422
|
bootstrap.config[:first_boot_attributes] = config[:json_attributes]
|
424
|
-
bootstrap.config[:ssh_user] = config[:ssh_user]
|
423
|
+
bootstrap.config[:ssh_user] = config[:ssh_user]
|
425
424
|
bootstrap.config[:identity_file] = config[:identity_file]
|
426
425
|
bootstrap.config[:chef_node_name] = config[:chef_node_name] || vm.name
|
427
426
|
bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version)
|
@@ -432,6 +431,7 @@ class Chef
|
|
432
431
|
bootstrap.config[:environment] = config[:environment]
|
433
432
|
bootstrap.config[:no_host_key_verify] = config[:no_host_key_verify]
|
434
433
|
bootstrap.config[:ssh_password] = config[:ssh_password]
|
434
|
+
bootstrap.config[:ssh_gateway] = config[:ssh_gateway]
|
435
435
|
bootstrap
|
436
436
|
end
|
437
437
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Sergio Rubio (<
|
3
|
-
# Copyright::
|
2
|
+
# Author:: Sergio Rubio, Massimo Maino (<maintux@gmail.com>)
|
3
|
+
# Copyright:: Sergio Rubio, Massimo Maino (c) 2011
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Sergio Rubio (<
|
3
|
-
# Copyright::
|
2
|
+
# Author:: Sergio Rubio, Massimo Maino (<maintux@gmail.com>)
|
3
|
+
# Copyright:: Sergio Rubio, Massimo Maino (c) 2011
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
data/lib/knife-esx/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-esx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sergio Rubio
|
@@ -10,102 +9,77 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2013-10-24 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: esx
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - '>='
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.4.
|
20
|
+
version: 0.4.4
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- -
|
25
|
+
- - '>='
|
29
26
|
- !ruby/object:Gem::Version
|
30
|
-
version: 0.4.
|
27
|
+
version: 0.4.4
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: terminal-table
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- -
|
32
|
+
- - '>='
|
37
33
|
- !ruby/object:Gem::Version
|
38
34
|
version: '0'
|
39
35
|
type: :runtime
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- -
|
39
|
+
- - '>='
|
45
40
|
- !ruby/object:Gem::Version
|
46
41
|
version: '0'
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
43
|
name: chef
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
|
-
- -
|
46
|
+
- - '>='
|
53
47
|
- !ruby/object:Gem::Version
|
54
48
|
version: '0.10'
|
55
49
|
type: :runtime
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
52
|
requirements:
|
60
|
-
- -
|
53
|
+
- - '>='
|
61
54
|
- !ruby/object:Gem::Version
|
62
55
|
version: '0.10'
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: celluloid
|
65
|
-
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
|
-
requirements:
|
68
|
-
- - ! '>='
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: '0.9'
|
71
|
-
type: :runtime
|
72
|
-
prerelease: false
|
73
|
-
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
|
-
requirements:
|
76
|
-
- - ! '>='
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: '0.9'
|
79
56
|
- !ruby/object:Gem::Dependency
|
80
57
|
name: open4
|
81
58
|
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
59
|
requirements:
|
84
|
-
- -
|
60
|
+
- - '>='
|
85
61
|
- !ruby/object:Gem::Version
|
86
62
|
version: '0'
|
87
63
|
type: :runtime
|
88
64
|
prerelease: false
|
89
65
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
66
|
requirements:
|
92
|
-
- -
|
67
|
+
- - '>='
|
93
68
|
- !ruby/object:Gem::Version
|
94
69
|
version: '0'
|
95
70
|
description: ESX Support for Chef's Knife Command
|
96
71
|
email:
|
97
|
-
- rubiojr@frameos.org
|
98
|
-
- rubiojr@frameos.org
|
99
72
|
- maintux@gmail.com
|
100
73
|
executables: []
|
101
74
|
extensions: []
|
102
75
|
extra_rdoc_files:
|
103
|
-
- README.
|
76
|
+
- README.md
|
104
77
|
- LICENSE
|
105
78
|
files:
|
79
|
+
- .gitignore
|
106
80
|
- CHANGELOG.md
|
107
81
|
- LICENSE
|
108
|
-
- README.
|
82
|
+
- README.md
|
109
83
|
- features/esx.feature
|
110
84
|
- features/foo
|
111
85
|
- features/step_definitions/steps.rb
|
@@ -119,32 +93,28 @@ files:
|
|
119
93
|
- lib/chef/knife/esx_vm_delete.rb
|
120
94
|
- lib/chef/knife/esx_vm_list.rb
|
121
95
|
- lib/knife-esx/version.rb
|
122
|
-
homepage: http://github.com/
|
96
|
+
homepage: http://github.com/maintux/knife-esx
|
123
97
|
licenses: []
|
98
|
+
metadata: {}
|
124
99
|
post_install_message:
|
125
100
|
rdoc_options: []
|
126
101
|
require_paths:
|
127
102
|
- lib
|
128
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
104
|
requirements:
|
131
|
-
- -
|
105
|
+
- - '>='
|
132
106
|
- !ruby/object:Gem::Version
|
133
107
|
version: '0'
|
134
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
-
none: false
|
136
109
|
requirements:
|
137
|
-
- -
|
110
|
+
- - '>='
|
138
111
|
- !ruby/object:Gem::Version
|
139
112
|
version: '0'
|
140
113
|
requirements: []
|
141
114
|
rubyforge_project:
|
142
|
-
rubygems_version: 1.
|
115
|
+
rubygems_version: 2.1.5
|
143
116
|
signing_key:
|
144
|
-
specification_version:
|
117
|
+
specification_version: 4
|
145
118
|
summary: ESX Support for Chef's Knife Command
|
146
|
-
test_files:
|
147
|
-
|
148
|
-
- features/foo
|
149
|
-
- features/step_definitions/steps.rb
|
150
|
-
- features/support/env.rb
|
119
|
+
test_files: []
|
120
|
+
has_rdoc: true
|
data/README.rdoc
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
= Knife ESX
|
2
|
-
|
3
|
-
= DESCRIPTION:
|
4
|
-
|
5
|
-
This is the unofficial Opscode Knife plugin for ESX. This plugin gives knife the ability to create, bootstrap, and manage virtual machines in a VMWare ESX/ESXi host.
|
6
|
-
|
7
|
-
You'll need an ESX(i)4/5 host with SSH enabled and a privileged user account to connect to it via SSH:
|
8
|
-
|
9
|
-
You'll also need a base VM template (a VMDK in fact) with CentOS/Ubuntu/Fedora and vmware-tools installed.
|
10
|
-
|
11
|
-
http://github.com/rubiojr/knife-esx
|
12
|
-
|
13
|
-
= INSTALLATION:
|
14
|
-
|
15
|
-
Be sure you are running the latest version Chef. Versions earlier than 0.10.0 don't support plugins:
|
16
|
-
|
17
|
-
gem install chef
|
18
|
-
|
19
|
-
This plugin is distributed as a Ruby Gem. To install it, run:
|
20
|
-
|
21
|
-
gem install knife-esx
|
22
|
-
|
23
|
-
Depending on your system's configuration, you may need to run this command with root privileges.
|
24
|
-
|
25
|
-
= CONFIGURATION:
|
26
|
-
|
27
|
-
In order to communicate with the ESX Cloud API you will have to tell Knife about your Username and API Key. The easiest way to accomplish this is to create some entries in your <tt>knife.rb</tt> file:
|
28
|
-
|
29
|
-
knife[:esx_host] = "Your ESX host address"
|
30
|
-
knife[:esx_username] = "root"
|
31
|
-
knife[:esx_password] = "secret"
|
32
|
-
|
33
|
-
You also have the option of passing your ESX Host/Username/Password into the individual knife subcommands using the <tt>--esx-host</tt> <tt>--esx-username</tt> and <tt>--esx-password</tt> command options
|
34
|
-
|
35
|
-
# provision a new Ubuntu 11.10 VM
|
36
|
-
knife esx vm create --template-file ~/.chef/bootstrap/ubuntu11.10-gems.erb \
|
37
|
-
--vm-disk /path-to/ubuntu1110-x64-vmware-tools.vmdk \
|
38
|
-
--vm-name knife-esx-test-ubuntu \
|
39
|
-
--datastore datastore1
|
40
|
-
--esx-host my-test-host \
|
41
|
-
--esx-password secret
|
42
|
-
|
43
|
-
#provision a new ubuntu 12.04 VM using a template on the ESXi Host with the --use-template option
|
44
|
-
#- the command assumes that you have an ubuntu template located at /vmfs/volumes/datastore1/esx-gem/templates/ubuntu12.04-template-x64.vmdk.
|
45
|
-
#In this example we also changed the location of the datastore from the default datastore1 to datastore2
|
46
|
-
knife esx vm create --esx-username root \
|
47
|
-
--vm-name ubuntu-12.04-vm \
|
48
|
-
--datastore datastore2 \
|
49
|
-
--esx-host server1 \
|
50
|
-
--esx-password secret \
|
51
|
-
--use-template ubuntu12.04-template-x64.vmdk
|
52
|
-
|
53
|
-
= SUBCOMMANDS:
|
54
|
-
|
55
|
-
This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a <tt>--help</tt> flag
|
56
|
-
|
57
|
-
== knife esx vm create
|
58
|
-
|
59
|
-
Provisions a new virtual machine in the ESX host and then perform a Chef bootstrap (using the SSH protocol). The goal of the bootstrap is to get Chef installed on the target system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists (provided by the provisioning). It is primarily intended for Chef Client systems that talk to a Chef server. By default the virtual machine is bootstrapped using the {ubuntu10.04-gems}[https://github.com/opscode/chef/blob/master/chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb] template. This can be overridden using the <tt>-d</tt> or <tt>--template-file</tt> command options.
|
60
|
-
|
61
|
-
== knife esx vm delete
|
62
|
-
|
63
|
-
Deletes an existing virtual machine in the currently configured ESX host by the virtual machine name. You can find the instance id by entering 'knife esx vm list'. Please note - this does not delete the associated node and client objects from the Chef server.
|
64
|
-
|
65
|
-
== knife esx vm list
|
66
|
-
|
67
|
-
Outputs a list of all virtual machines in the currently configured ESX host. Please note - this shows all the virtual machines available in the ESX host, some of which may not be currently managed by the Chef server.
|
68
|
-
|
69
|
-
= LICENSE:
|
70
|
-
|
71
|
-
Author:: Sergio Rubio (<rubiojr@frameos.org>)
|
72
|
-
Copyright:: Copyright (c) 2011 Sergio Rubio
|
73
|
-
License:: Apache License, Version 2.0
|
74
|
-
|
75
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
76
|
-
you may not use this file except in compliance with the License.
|
77
|
-
You may obtain a copy of the License at
|
78
|
-
|
79
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
80
|
-
|
81
|
-
Unless required by applicable law or agreed to in writing, software
|
82
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
83
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
84
|
-
See the License for the specific language governing permissions and
|
85
|
-
limitations under the License.
|