SUSE Conversations


How to have one or more variants of an AutoYaST profile without having to maintain them



By: mikewillis

January 14, 2009 1:11 pm

Reads:272

Comments:0

Rating:0

Say you maintain a bunch of machines running some SUSE variant, you install them using AutoYaST so they’re all identical but you find that sometimes you want to install a machine in a way which is slightly different to normal. For example, you want to be able to re-install a machine whilst preserving the contents of a particular partition. This presents a problem because it means you need more than one AutoYaST profile, the one you usually use and the variant. If you change the main profile you have to make the same changes to the variant. Maintaining a variant is going to be prone to human error, forgetfulness and possibly problems could be caused by trying to use a variant which you don’t realize hasn’t been maintained.

Faced with such a situation myself a neat solution occurred to me. My AutoYaST profile is retrieved via http from the installation server (running SLES 10 SP2), so a script on the server can be used to manipulate the XML on the fly and serve the modified version. This way only one AutoYaST profile has to be maintained but you can can have as many variants of it as you like provided you write a script to produce that variant. For example;

<?php
# N.B. Requires PHP 5
# reads the autoinst.xml file, alters the partition config data so that
# partitions are re-used rather than created and the once mounted at  /local is not formatted
# then outputs the new xml.

$sourcexmlfile="autoyast.xml";

$data=simplexml_load_file($sourcexmlfile);

foreach ($data->partitioning->drive->partitions->partition as $partition) {
 $partition->create="false";
 if ($partition->mount=="/local") $partition->format="false";
}

header('Content-Type: text/xml');
print $data->asXML();
?>

Save that on your server, provide it’s url as the source of the AutoYaST profile and you can re-install a machine as normal only without losing the contents of the /local partition. If you use PXE boot you can put a suitable entry in to /tftpboot/pxelinux.cfg/default.

I used PHP, but you could of course use perl or whatever other scripting language you may already be comfortable manipulating xml with.

N.B. I have used this method of re-installation whilst preserving the contents of a partition in a production environment without problems. However you should of course make sure you have a backup of any files in the partition that you cannot afford to lose before you do a re-install.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

Tags: ,
Categories: SUSE Linux Enterprise Server, Technical Solutions

Disclaimer: As with everything else at SUSE Conversations, this content is definitely not supported by SUSE (so don't even think of calling Support if you try something and it blows up).  It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.

Comment

RSS