New in virt-builder

New in virt-builder 1.23.31:

The --edit option lets you make quite powerful edits to files easily. For example you can do substitutions in configuration files:

virt-builder fedora-19 \
  --edit '/etc/yum.conf:
             s/gpg_check=1/gpg_check=0/'

Or you can delete lines matching a particular pattern:

virt-builder debian-7 \
  --edit '/etc/hosts:
             $_ = "" if /^192\.168/'

Here’s an example showing how to uncomment lines from a configuration file. Notice how the comment character (#) is removed by the substitution:

virt-builder debian-7 \
  --edit '/etc/inittab:
             s{^#([1-9].*:/sbin/getty.*)}{$1}'

In fact the edit option gives you a complete Perl interpreter so some pretty powerful edits are possible. (For more background on this, it works the same way as the virt-edit -e option).

A second new feature are the --delete and --scrub options. The first one deletes a file. However a simple delete doesn’t entirely get rid of a file off disk: it would be possible for the first user of the new guest to undelete files. If that is a problem, you can use --scrub to scrub the file off the disk.

Thirdly you can now precache all templates by doing:

virt-builder --cache-all-templates

This is useful in automated builders where you want a more predictable build time.

Finally there are more templates, including Debian 6 (Squeeze) and 7 (Wheezy), and several Ubuntu guests.

Update

Several people have asked me how to try out virt-builder. It’s not in any released version of any OS yet, but here are some possibilities:

  1. If using the Fedora 20 beta, use this package.
  2. If using Fedora 19, you can build it from source pretty easily:
    sudo yum install fedora-packager
    fedpkg clone -a -B libguestfs
    cd libguestfs/f20
    sudo yum-builddep ./libguestfs.spec
    fedpkg local
    sudo yum install ./noarch/*.rpm ./x86_64/*.rpm
    
  3. If using Debian, keep an eye on “experimental”. There will be a package available in a week or two.

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s