GithubHelp home page GithubHelp logo

knife-kvm's Introduction

NO LONGER MAINTAINED

See github.com/chef/knife-kvm for a better and actively maintained gem.

Knife KVM

github.com/rubiojr/knife-kvm

DESCRIPTION:

This is the unofficial Opscode Knife plugin for KVM. This plugin gives knife the ability to create, bootstrap, and manage virtual machines in a Linux KVM host.

PRE-REQUISITES

  • You’ll need an KVM host with SSH enabled and a privileged user account to connect to it via SSH

  • libguestfs-tools (virt-cat in particular) installed in the hypervisor host

  • A special VM template (in QCOW2/RAW) with CentOS/Ubuntu/Fedora and installed. I’ve got a couple of them to share:

    - http://download.frameos.org/appliances/centos5-jeos-ip-info.qcow2
    - http://download.frameos.org/appliances/centos6-jeos-with-ip-info.qcow2

    These templates have a script (ip-info) that is executed when the OS boots and writes all the ip addresses available in the guest to the /tmp/ip-info file (gist.github.com/1405266). This information is used to retrieve the VM ip addresses so that knife-kvm can bootstrap the Chef client.

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-kvm

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

CONFIGURATION:

In order to communicate with the KVM 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[:kvm_host] = "Your KVM host address"
knife[:kvm_username]  = "root"
knife[:kvm_password]  = "secret"

You also have the option of passing your KVM Host/Username/Password into the individual knife subcommands using the --kvm-host --kvm-username and --kvm-password command options

# provision a new Ubuntu 11.10 VM
knife kvm vm create --template-file ~/.chef/bootstrap/ubuntu11.10-gems.erb \
                    --vm-disk /path-to/ubuntu1110-x64.qcow2 \
                    --vm-name knife-kvm-test-ubuntu \
                    --ssh-user ubuntu \
                    --ssh-password ubuntu \
                    --pool default \
                    --kvm-host my-test-host \
                    --kvm-user root \
                    --kvm-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 kvm vm create

Provisions a new virtual machine in the KVM 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 kvm vm delete

Deletes an existing virtual machine in the currently configured KVM host by the virtual machine name. You can find the instance id by entering ‘knife kvm vm list’. Please note - this does not delete the associated node and client objects from the Chef server.

knife kvm vm list

Outputs a list of all virtual machines in the currently configured KVM host. Please note - this shows all the virtual machines available in the KVM 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.

knife-kvm's People

Contributors

rubiojr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

knife-kvm's Issues

libvirt: nokogiri conflict

Hola Rubio - I'd love to use your knife-kvm gem, but when running it, it comes up with a nokogiri conlict:

ERROR: Gem::LoadError: Unable to activate libvirt-0.2.0, because nokogiri-1.5.2 conflicts with nokogiri (~> 1.4.3)

Reverting nokogiri to 1.4.3 leads many broken dependencies when running knife. What could be the resolution for this?
Many thanks in advance.

Adios,
Levente

Feature request - ssh keys

Using ssh with passwords is very bad habit, especially with root account. Direct root login should be disabled, or with exceptions, only allow root login with ssh keys.

feature request: an option to run a host-side command to get a vm's ip from hostname

It's easy to use virsh dumpxml and xpath to get the mac of a running vm, and it's easy to grep the dnsmasq leases file for that mac to get its ip after booting. I've a script on the host side that does all of this for me.

It'd be a convenient feature to be able to specify a host-side command to fetch the IP so that custom root images aren't required for knife-kvm.

I'll scratch this itch myself and send a PR if I end up having time this weekend, but it may be faster for you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.