Knife ESX

DESCRIPTION:

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.

You’ll need an ESX(i)4/5 host with SSH enabled and a privileged user account to connect to it via SSH:

You’ll also need a base VM template (a VMDK in fact) with CentOS/Ubuntu/Fedora and vmware-tools installed.

github.com/rubiojr/knife-esx

INSTALLATION:

Be sure you are running the latest version Chef. Versions earlier than 0.10.0 don’t support plugins:

gem install chef

This plugin is distributed as a Ruby Gem. To install it, run:

gem install knife-esx

Depending on your system’s configuration, you may need to run this command with root privileges.

CONFIGURATION:

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:

knife[:esx_host] = "Your ESX host address"
knife[:esx_username]  = "root"
knife[:esx_password]  = "secret"

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

# provision a new Ubuntu 11.10 VM
knife esx vm create --template-file ~/.chef/bootstrap/ubuntu11.10-gems.erb \
                    --vm-disk /path-to/ubuntu1110-x64-vmware-tools.vmdk \
                    --vm-name knife-esx-test-ubuntu \
                    --datastore datastore1
                    --esx-host my-test-host \
                    --esx-password secret

SUBCOMMANDS:

This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a --help flag

knife esx vm create

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.

knife esx vm delete

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.

knife esx vm list

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.

LICENSE:

Author

Sergio Rubio (<[email protected]>)

Copyright

Copyright © 2011 Sergio Rubio

License

Apache License, Version 2.0

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.