Tip: Updating RHEL 7.1 cloud images using virt-customize and subscription-manager

Red Hat provide RHEL KVM guest and cloud images. At time of writing, the last one was built in Feb 2015, and so undoubtedly contains packages which are out of date or insecure.

You can use virt-customize to update the packages in the cloud image. This requires the libguestfs subscription-manager feature which will only be available in RHEL 7.3, but see here for RHEL 7.3 preview packages. Alternatively you can use Fedora ≥ 22.

$ virt-customize \
  -a rhel-guest-image-7.1-20150224.0.x86_64.qcow2 \
  --sm-credentials 'USERNAME:password:PASSWORD' \
  --sm-register --sm-attach auto \
  --update
[   0.0] Examining the guest ...
[  17.2] Setting a random seed
[  17.2] Registering with subscription-manager
[  28.8] Attaching to compatible subscriptions
[  61.3] Updating core packages
[ 976.8] Finishing off
  1. You should probably use --sm-credentials USERNAME:file:FILENAME to specify your password using a file, rather than having it exposed on the command line.
  2. The command above will leave the image template registered to RHN. To unregister it, add --sm-unregister at the end.

3 Comments

Filed under Uncategorized

3 responses to “Tip: Updating RHEL 7.1 cloud images using virt-customize and subscription-manager

  1. Do I get to claim inspiration for the addition of this feature? It looks like a nice addition! Bonus points if you patch vagrant-builder to use your new method instead 🙂

    https://github.com/purpleidea/vagrant-builder/blob/master/v7/Makefile#L186

    Cheers!
    @purpleidea

  2. Pino Toscano

    > Do I get to claim inspiration for the addition of this feature?

    Well, I didn’t know you needed it, but surely it made my life slightly easier!

  3. Tip for new players, don’t forget –selinux-relabel

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.