theforeman/smart-proxy — pull request #116 by lzap (2013-12-02 10:04:11+00:00)
Title: Adding simple virsh provider for libvirt DNS/DHCP/TFTP

For over an year now it is possible to modify libvirt network settings using
virsh commands, either on live instance or permanent configuration (or both)
thanks to this patch:

http://www.redhat.com/archives/libvir-list/2012-September/msg01380.html

That means I was able to create DHCP and DNS provider called *virsh* that does
all we want. *Development setup of Foreman was never that easy*. With simple
steps, one can configure full provisioning on a box with libvirt. This is
_Foreman in a box_, batteries included!

Part of this patch is tutorial, which I want to put on our wiki once this is
waived. Please try this out.

We are using *default libvirt installation* without any changes. First, let's
define TFTP root. Edit "default" virtual network and add 'tftp',
'bootp' and 'domain' elements.

default
16b7b280-7462-428c-a65c-5753b84c7545

Create a tftpboot directory, make sure it is accessible for account dnsmasq is
running on (in Fedora this is nobody), set gid flag for newly copied files and
copy necessary files to the new TFTP root directory:

mkdir -p /var/tftpboot/{boot,pxelinux.cfg}
yum -y install syslinux
cp /usr/share/syslinux/{pxelinux.0,menu.c32,chain.c32} /var/tftpboot
chgrp -R nobody /var/tftpboot
find /var/tftpboot/ -type d | xargs chmod g+s

Configure smart-proxy:

* enable tftp
* set correct tftp boot and set explicit tftp_servername
* enable dns virsh provider
* enable dhcp virsh provider
* check virsh_network name ('default')

Important configuration values:

:tftp: true
:tftproot: /var/tftpboot
:tftp_servername: 192.168.122.1
:dns: true
:dns_provider: nsupdate_virsh
:dhcp: true
:dhcp_vendor: virsh
:virsh_network: default

Make sure the user foreman proxy will be running with has sudo and virsh
commands available and password is not required for virsh command. Also make
sure sudo is not requiring tty. Something like:

Defaults !requiretty
%users ALL=/usr/bin/virsh

Foreman is now configured for libvirt provisioning, you can now start both
foreman and smart-proxy directly from git and work on provisioning easily.