Thursday, September 30, 2010

AutoYaST and Image Creation/Installation

In openSUSE 11.3 I enhanced the AutoYaST image installation feature a bit and I added a nice useable UI to configure it.
It's still quite beta because I was not able to test it the way I should have but I think that if you are interested in that topic, it's worth a look already.
Let's start immediately and create an AutoYaST image with the UI.

Step 1 - make the openSUSE Installation Source available


taylor:~ # mount /dev/dvd /mnt

I simply mount the openSUSE 11.3 DVD here to the /mnt directory.

Step 2 - start the AutoYaST UI


taylor:~ # yast2 autoyast

When the UI is started, go to the software selection configuration. You'll be asked where the installation source is you want to use.
As you can see in the screenshot, I set the installation source to the mounted DVD by "file:///mnt/".

Hint: You can't create 64bit images on a 32bit system but 32bit images on a 64bit system

Step 3 - select your software for the image


I selected the base pattern and the kernel I want (don't forget the kernel. Linux is no fun without a kernel).




Select okay to return to the main UI when you have selected all the software you want to have in the image.
You probably want to configure anything non image related now, like root password, partitioning, ...

Step 4 - Create the Image





Choose "Image Deployment" in the AutoYaST UI and configure the location of the image. That's where AutoYaST can find it during the installation process.
I want to do a network installation and I'll put the image on my webserver and so I type the http address here.
As you can see in the screenshot, you can also create an ISO. Then you don't have to specify a name and the location, because a DVD ISO will be created that contains the image and the autoyast XML file plus everything you need to do an installation from the ISO by booting it.
Creating an ISO is probably easier in the beginning if you want to play with this feature.

Step 5 - Choose the location to store the image


I'll store it to /srv/www/htdocs/ because that's the document root of my webserver. Like mentioned in step 4, I'll fetch the image from my webserver.



If you create an ISO, you have to choose where to save the ISO now.

Step 6 (optional) - make changes to the image





AutoYaST will now create the image and you can do changes to it when all patterns and packages are installed. You can see that in the screenshot.
So if you want to put any files into the image, you can copy them now to the place shown in the popup, which is a directory that contains the system that will later be dumped to you harddisk. You can even chroot into that directory and let scripts run if you want.
This step is optional, so if you don't want to add files or anything, you can simply press "ok" here to compress the image.

Now you are done with the image creation. Let's take a look at what we have in the XML file now:

...
<software>
<image>
<image_location>http://taylor.suse.de/</image_location>
<image_name>my_image</image_name>
<run_kickoff config:type="boolean">true</run_kickoff>
<script_location>file:///usr/lib/YaST2/bin//fetch_image.sh</script_location>
<script_params config:type="list">
<listentry>http://taylor.suse.de//my_image.tar.gz</listentry>
</script_params>
</image>
<instsource>file:///mnt/</instsource>
<packages config:type="list">
<package>kernel-desktop</package>
</packages>
<patterns config:type="list">
<pattern>apparmor_opt</pattern>
<pattern>base</pattern>
<pattern>yast2_install_wf</pattern>
<pattern>sw_management</pattern>
<pattern>apparmor</pattern>
</patterns>
...


The XML file is prepared for an installation of the image. The fetch_image.sh is part of AutoYaST since openSUSE 11.3 and will fetch and unpack the image after the partitioning is done. That's why we can use "file:///" here, because autoyast will find it as it's part of the autoyast2-installation RPM.
You can replace that script by anything you want that can fetch and unpack the image. So if you have a complete different image type, you can write your own script to fetch and unpack the image. Of course if you have a different kind of image, you can't use the AutoYaST UI anymore to create it. AutoYaST will always create a tar.gz file that contains the installed system.

Installing images via AutoYaST has three major benefits compared to the RPM installation step:

  • multiple times faster

  • post-configuration can be done in the image instead of after the installation

  • very easy switching between image installation and RPM installation (with rules, even dynamically when starting the installation)


You can install images without losing any of the AutoYaST functionality. Ask-dialogs, all kind of scripts (even pre-scripts), complex partitioning and so on is still possible because only the slow RPM installation step is skipped and replaced by putting an image to the harddisk while you have all kinds of flexibility of how that image is created.

As mentioned in the beginning of this article, I had not enough time to test this through but if you are interested in it feel free to play with it and report feedback to me if anything fails or can be enhanced :)

Have fun!

ciao, Uwe

Wednesday, July 7, 2010

AutoYaST goes Twitter

well, it's not that it can read XML files from a twitter feed now ;) but after this blog, starting from today, AutoYaST goes one further step to web 2.0 and has it's own twitter account.
It's not for great hints or enhanced support or so. It's just a little look behind the curtain of my life with AutoYaST ... for those who care ;)
And it seems you can't do any bigger project these days without something like a blog, twitter or facebook or ... so ... here it is.

ciao, Uwe

Tuesday, April 20, 2010

AutoYaST and it's Tools


"Al: Didn't you study the manual at all?
Tim: A real man doesn't need a manual. "


Because my last article was for the experts, this is more for the AutoYaST-newbies again.
It's not about AutoYaST itself but about the tools that orbit around it.

  • ayast_setup
    This tool is part of the autoyast2 RPM.
    Bubli wrote an excellent tutorial already so I'll just sum things up a little here.
    With ayast_setup you can reconfigure an already installed and running system without reinstalling it. All you need is an AutoYaST XML file and then call:
    yast2 ayast_setup setup filename=/tmp/my.xml

    The XML file will be read by AutoYaST and applied to your currently running system except (and that's good - you want it that way, believe me) all 1st stage configuration like partitioning, bootloader, pre- and chrootscripts and software selection. So if you use a XML file with partitioning information, your system will not get repartitioned.
    If you want to install packages, you have to use the <post-packages> section because the normal <software> section is evaluated during 1st stage only too.

  • yast2 clone_system
    This tool is also part of the autoyast2 RPM.
    This is kind of the opposite of ayast_setup. At the end of the normal installation, you have the option to clone the freshly installed system for AutoYaST but if you missed that opportunity, you can do that later in the running system with the clone_system client.
    Since openSUSE 11.3 you can call it like this:
    yast2 clone_system help

    and you'll get a list of "known modules" that can be cloned like this:
    known modules:
    bootloader dns-server
    firewall host
    http-server inetd
    iscsi-client kerberos
    lan ldap mail nfs
    ...

    and you can clone them like this:
    yast2 clone_system modules clone=lan,partitioning,software

    This will create an AutoYaST XML file in /root/autoinst.xml with the networking, partitioning and software section. If you don't specify any modules to clone, the same XML file will be created like with the "Clone this System" checkbox at the end of a normal installation.
    The "modules" parameter is new on openSUSE 11.3 and will not work on SLES11. On SLES11 you can only do the default cloning by calling
    yast2 clone_system

    Some customers are even doing remote-cloning with screen and ssh like this:
    ssh --batch root@myhost "screen -D -m yast clone_system &"


  • ayast_probe
    This tool is part of the autoyast2-installation RPM.
    It's not very useful in a running system but can become handy during the installation.
    When you use a rules.xml file, you can do things like (pseudocode) "if installed_product == 'SLES11' and memsize > 1024 use big_software.xml". The real syntax can be found
    here in the documentation.
    The question is, what are reasonable values of installed_product or memsize?
    /usr/lib/YaST2/bin/y2base ayast_probe ncurses
    shows you.


  • yast2 autoyast
    This tool is part of the autoyast2 RPM.
    If you start to look at AutoYaST for the first time, you'll probably get in touch with this tool immediately. It's the AutoYaST userinterface to create a XML file. Every module like networking, samba-client, partitioning, software configuration and so on has a UI here so you don't have to deal with XML code.
    But the AutoYaST UI can do more. You can clone single modules like you can do with the clone_system client by just pressing a single button (I painted that red in the screenshot, where the nfs-client is selected and would be cloned).
    You can apply the config of one module to the currently running system like with ayast_setup but with just a single button press again (green in the screenshot for the nfs-client config).
    And last but not least you can check your XML file for syntax errors.
    It's nearly impossible to create an invalid XML file with the UI and if you are not sure about certain XML parameters, the UI can be of a big help for you.



While the tools above were all 100% AutoYaST related and are only useful in combination with something autoyastish, the following tools are used by people who never heared of AutoYaST too.

  • xsltproc
    xsltproc is part of the libxslt RPM.
    This tool is used to apply XSLT files on a XML file.
    "What???!" - well, you only have to know that AutoYaST uses a XSLT file to merge multiple XML files into one big file. So when you use AutoYaST Rules or AutoYaST Classes your single XML files will be merged to a big one with the help of /usr/share/autoinstall/xslt/merge.xslt.
    It can be very useful to test the merging before you start the actual installation to make sure everything comes out as you planned it:
    /usr/bin/xsltproc --novalid \
    --param replace "'false'" \
    --param dontmerge1 "'package'" \
    --param with "'a.xml'" \
    --output out.xml \
    /usr/share/autoinstall/xslt/merge.xslt \
    b.xml

    a.xml and b.xml will be merged to out.xml. So take a look at out.xml to see if the merging led to the expected result.
    The dontmerge parameter is explained here. In short, you need that parameter if you want to merge two XML files that have the same sections. Like two XML files both with a <software> section.

  • create_update_source.sh and createrepo
    create_update_source.sh is part of the inst-source-utils RPM, createrepo is part of the createrepo RPM
    Both tools are for creating RPM repositories. If you create such a repo and add the location to your XML file, AutoYaST can install the RPMs from that repo too. So if you want to add own RPMs to your installation, don't change the actual SUSE Installation source, but create a new repo and add your RPM's there.
    How to do that is explained here.
    Even if you only want to install RPM's that are on openSUSE or SLES, you can use these tools. You can create a repo with all online-updates that were released and AutoYaST will install those updates then instead of the original RPM's.


I'd say those are the most important tools around AutoYaST - have fun using them for "more power" ;-)

ciao, Uwe