openstack-manuals/doc/image-guide/ch_creating_images_automatically.xml
Sandro Tosi bcec02416e Typos and spellings errors fix in config-ref, HA/image guides
Another round of typos/spelling errors fixing, in particular for
config-reference, HA guide and image guide.

Change-Id: Ibc3661e132a0ea4010a5a61f71ef5209ae6655b6
Closes-Bug: #1356970
2014-08-15 09:00:11 +01:00

177 lines
8.6 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<chapter xmlns="http://docbook.org/ns/docbook"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="5.0"
xml:id="ch_creating_images_automatically">
<title>Tool support for image creation</title>
<?dbhtml stop-chunking?>
<para>There are several tools that are designed to automate image
creation.</para>
<section xml:id="oz">
<title>Oz</title>
<para><link
xlink:href="https://github.com/clalancette/oz/wiki"
>Oz</link> is a command-line tool that automates the
process of creating a virtual machine image file. Oz is a
Python app that interacts with KVM to step through the
process of installing a virtual machine. It uses a
predefined set of kickstart (Red Hat-based systems) and
preseed files (Debian-based systems) for operating systems
that it supports, and it can also be used to create
Microsoft Windows images. On Fedora, install Oz with yum:<screen><prompt>#</prompt> <userinput>yum install oz</userinput></screen><note>
<para>As of this writing, there are no Oz packages for
Ubuntu, so you will need to either install from
source or build your own .deb file.</para>
</note></para>
<para>A full treatment of Oz is beyond the scope of this
document, but we will provide an example. You can find
additional examples of Oz template files on GitHub at
<link
xlink:href="https://github.com/rackerjoe/oz-image-build/tree/master/templates"
>rackerjoe/oz-image-build/templates</link>. Here's how
you would create a CentOS 6.4 image with Oz.</para>
<para>Create a template file (we'll call it
<filename>centos64.tdl</filename>) with the following
contents. The only entry you will need to change is the
<literal>&lt;rootpw></literal>
contents.<programlisting language="xml">&lt;template>
&lt;name>centos64&lt;/name>
&lt;os>
&lt;name>CentOS-6&lt;/name>
&lt;version>4&lt;/version>
&lt;arch>x86_64&lt;/arch>
&lt;install type='iso'>
&lt;iso>http://mirror.rackspace.com/CentOS/6/isos/x86_64/CentOS-6.4-x86_64-bin-DVD1.iso&lt;/iso>
&lt;/install>
&lt;rootpw>CHANGE THIS TO YOUR ROOT PASSWORD&lt;/rootpw>
&lt;/os>
&lt;description>CentOS 6.4 x86_64&lt;/description>
&lt;repositories>
&lt;repository name='epel-6'>
&lt;url>http://download.fedoraproject.org/pub/epel/6/$basearch&lt;/url>
&lt;signed>no&lt;/signed>
&lt;/repository>
&lt;/repositories>
&lt;packages>
&lt;package name='epel-release'/>
&lt;package name='cloud-utils'/>
&lt;package name='cloud-init'/>
&lt;/packages>
&lt;commands>
&lt;command name='update'>
yum update
yum clean all
sed -i '/^HWADDR/d' /etc/sysconfig/network-scripts/ifcfg-eth0
echo -n > /etc/udev/rules.d/70-persistent-net.rules
echo -n > /lib/udev/rules.d/75-persistent-net-generator.rules
&lt;/command>
&lt;/commands>
&lt;/template></programlisting>
</para>
<para>This Oz template specifies where to download the Centos
6.4 install ISO. Oz will use the version information to
identify which kickstart file to use. In this case, it
will be <link
xlink:href="https://github.com/clalancette/oz/blob/master/oz/auto/RHEL6.auto"
>RHEL6.auto</link>. It adds EPEL as a repository and
install the <literal>epel-release</literal>,
<literal>cloud-utils</literal>, and
<literal>cloud-init</literal> packages, as specified
in the <literal>packages</literal> section of the
file.</para>
<para>After Oz does the initial OS install using the kickstart
file, it customizes the image by doing an update. It also
removes any reference to the eth0 device that libvirt
creates while Oz does the customizing, as specified
in the <literal>command</literal> section of the XML
file.</para>
<para>To run this, do, as root:</para>
<para><screen><prompt>#</prompt> <userinput>oz-install -d3 -u centos64.tdl -x centos64-libvirt.xml</userinput></screen><itemizedlist>
<listitem>
<para>The <literal>-d3</literal> flag tells Oz to
show status information as it runs.</para>
</listitem>
<listitem>
<para>The <literal>-u</literal> tells Oz to do the
customization (install extra packages, run the
commands) once it does the initial
install.</para>
</listitem>
<listitem>
<para>The <literal>-x &lt;filename></literal> flag
tells Oz what filename to use to write out a
libvirt XML file (otherwise it will default to
something like
<filename>centos64Apr_03_2013-12:39:42</filename>).</para>
</listitem>
</itemizedlist>If you leave out the <literal>-u</literal>
flag, or you want to edit the file to do additional
customizations, you can use the
<command>oz-customize</command> command, using the
libvirt XML file that <command>oz-install</command>
creates. For example:
<screen><prompt>#</prompt> <userinput>oz-customize -d3 centos64.tdl centos64-libvirt.xml</userinput></screen>
Oz will invoke libvirt to boot the image inside of KVM,
then Oz will ssh into the instance and perform the
customizations.</para>
</section>
<section xml:id="vmbuilder">
<title>VMBuilder</title>
<para><link xlink:href="https://launchpad.net/vmbuilder"
>VMBuilder</link> (Virtual Machine Builder) is a
command-line tool that creates virtual machine images for
different hypervisors. The version of VMBuilder that ships
with Ubuntu can only create Ubuntu virtual machine guests.
The version of VMBuilder that ships with Debian can create
Ubuntu and Debian virtual machine guests.</para>
<para>The <link
xlink:href="https://help.ubuntu.com/12.04/serverguide/jeos-and-vmbuilder.html"
><citetitle>Ubuntu Server Guide</citetitle></link>
has documentation on how to use VMBuilder to create an
Ubuntu image.</para>
</section>
<section xml:id="boxgrinder">
<title>BoxGrinder</title>
<para>
<link xlink:href="http://boxgrinder.org/"
>BoxGrinder</link> is another tool for creating
virtual machine images, which it calls appliances.
BoxGrinder can create Fedora, Red Hat Enterprise Linux, or
CentOS images. BoxGrinder is currently only supported on
Fedora.</para>
</section>
<section xml:id="veewee">
<title>VeeWee</title>
<para><link xlink:href="https://github.com/jedi4ever/veewee">
VeeWee</link> is often used to build <link
xlink:href="http://vagrantup.com">Vagrant</link>
boxes, but it can also be used to build KVM images.</para>
</section>
<section xml:id="packer">
<title>Packer</title>
<para><link xlink:href="http://www.packer.io/">
Packer</link> is a tool for creating machine images for multiple platforms
from a single source configuration.
</para>
</section>
<section xml:id="imagefactory">
<title>imagefactory</title>
<para><link xlink:href="http://imgfac.org/"
>imagefactory</link> is a newer tool designed to
automate the building, converting, and uploading images to
different cloud providers. It uses Oz as its back-end and
includes support for OpenStack-based clouds.</para>
</section>
<section xml:id="susestudio">
<title>SUSE Studio</title>
<para><link xlink:href="http://susestudio.com">SUSE
Studio</link> is a web application for building and
testing software applications in a web browser. It
supports the creation of physical, virtual or cloud-based
applications and includes support for building images for
OpenStack based clouds using SUSE Linux Enterprise and
openSUSE as distributions.</para>
</section>
</chapter>