Virtual Machine Provisioning

Libvirt

As of version 0.2, Foreman provides an interface to build virtual guests using libvirtd, in order to use it, make sure you have:

Requirements

  1. The ruby libvirtd binding (the libvirt-ruby package on Ubuntu or ruby-libvirt package on RHEL)
  2. Foreman needs to be able to access libvirtd, this depends on how you communicate with libvirt, for exmaple, if you use qemu+ssh protocol, then the foreman user needs to be able to ssh to the hypervisor(the physical machine) and that user needs to be in the libvirt group.
  3. Configure the hypervisor under the settings tab. This can be a bit complicated due to the libvirt remote access access and authentication configuration complexities.
    • You can test your URI by running something like this: sudo -u foreman virsh -c '[YOUR URI]' list
    • Assuming your libvirt and foreman are on the same host, the easiest scheme to use is probably the unix domain socket, which means a URI like "qemu+unix:///system?socket=/var/run/libvirt/libvirt-sock" (you can drop the part from the question mark to the end if your socket is in the default place). Check the unix permissions on the socket to make sure the foreman user can access them.
      • If PolicyKit is configured and set up against your socket (and if the perms are 0777 it almost certainly is), then you'll need to follow the PolicyKit Configuration For Group Access instructions, or something similar.

Now you should see hypervisor options when creating a new node.

Notes

  1. it has been mostly tested on KVM.
  2. You should already have a network bridge and a storage pool configured on your hypervisor
  3. at the moment, you are required to have a storage group called "default" - until #720 is resolved.
  4. on systems that don't support netcf (such as Ubuntu), it is not possible to show the list of allowed interfaces, and its a free text field (you need to provide the interface bridge name or internal NAT network name)

ruby-libvirt RPMS for RHEL/CentOS can be found in EPEL.

For older version of RHEL5 you may use the following RPM

Note that a foreman restart would be required if you install the rpm for the first time.

As of foreman 0.3 it is now possible to browse though your virtual machines, stop / start destroy etc, under the hypervisor page

Examples

This is just as information, made for test purposes, to have everything working correctly.
Edit /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
auth_tcp = "none"

Edit /etc/init.d/libvirtd
LIBVIRTD_ARGS="--listen"

Edit /etc/libvirt/qemu.conf
vnc_listen = "0.0.0.0"

/etc/init.d/libvirtd restart

You should now be able to add your hypervisor in foreman, using: qemu+tcp://<hostname>/system

You could also check using virt-manager how it is going and have a display of your VM, using the same URI.

If you are using KVM, then you have to make a bridge eth0->br0.
Please make sure that your br0 interface contains those 2 parameters:
DELAY=0
STP=off

Also available in: HTML TXT