All 1 entries tagged PHP
View all 8 entries tagged PHP on Warwick Blogs | View entries tagged PHP at Technorati | There are no images tagged PHP on this blog
November 05, 2008
Altering AutoYaST profiles on the fly…
...or: How to have one or more variants of an AutoYaST profile without having to actually maintain them.
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 realise hasn't been maintained.
Faced with such a situation myself a neat solution occurred to me. My AutoYaST profile is accessed from a web sever at time of installation, so a script on the web 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. E.g. This PHP:
<?php
# reads the autoinst.xml file, alters the partition config data so that
# partitions are re-used rather than created, and /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();
?>
saved as a suitably named file on the web server and it's url provided as the source of the AutoYaST profile at install time allows machines to be re-installed whilst preserving the contents of the partition that gets mounted at /local.