Dienstag, 17. November 2009

Interactive AutoYaST Rules

This article describes a new feature of AutoYaST in openSUSE 11.3 (a backport for 11.2 is available too).

The rules.xml file describes how AutoYaST creates the complete XML profile out of single XML snippet files. Like for example "if the main memory is more than 2GB, use kde.xml, else use windowmaker.xml", "if you find more than one harddisk, use lvm.xml, else use simple_partitioning.xml" ... and so on ...
That's available since ages in AutoYaST what's new now is, that you can present all XML snippets you have to the users so they can select which ones to use on their own.
Confused but curious? Then read on ....

A while ago I read a feature request on the AutoYaST mailinglist that it would be cool to have the <rules> visible and selectable during installation and I was thinking: "Sounds like a good idea. So why not?". So here it is.
People love pictures so lets start with a screenshot:

On the screenshot you can see a dialog where you can choose between two rules where the first one is pre-selected and the second one is greyed out because it conflicts with the first one (I'll explain later what that conflict means).
Lets take a look at the interesting part of the rules.xml file now to see how to create such a dialog.

<rules config:type="list">
...
<rule>
<custom1>
<script>
<![CDATA[
echo -n 100
]]>
</script>
<match>100</match>
<match_type>exact</match_type>
</custom1>
<result>
<profile>rules/kde.xml</profile>
<continue config:type="boolean">true</continue>
</result>
<dialog>
<element config:type="integer">0</element>
<question>KDE Desktop</question>
<title>Desktop Selection</title>
<conflicts config:type="list">
<element config:type="integer">1</element>
</conflicts>
<dialog_nr config:type="integer">0</dialog_nr>
<timeout config:type="integer">30</timeout>
</dialog>
</rule>
<rule>
<custom1>
<script>
<![CDATA[
echo -n 100
]]>
</script>
<match>101</match>
<match_type>exact</match_type>
</custom1>
<result>
<profile>rules/gnome.xml</profile>
<continue config:type="boolean">true</continue>
</result>
<dialog>
<element config:type="integer">1</element>
<dialog_nr config:type="integer">0</dialog_nr>
<question>Gnome Desktop</question>
<conflicts config:type="list">
<element config:type="integer">0</element>
</conflicts>
</dialog>
</rule>
<rule>
...
</rule>
...
</rules>

That's not a complete rules.xml but only the interesting part with the two rules that created the dialog you see in the screenshot.
Here comes the description of the single XML elements:

  • <dialog_nr config:type="integer">0</dialog_nr>

    That's a uniq id for the a popup dialog. All rules with the same dialog_nr are presented on the same popup dialog. This element is optional and the default for a missing dialog_nr is always "0". If you have one popup only anyway, you don't need to specify the dialog_nr.

  • <element config:type="integer">0</element>

    element needs to be a uniq id. Even if you have more than one dialog, you must not use the same id twice like an element-id "1" on dialog 1 and and element-id "1" on dialog 2 too. That's different than with <ask> dialogs, where you can have the same <element> id on multiple dialogs. I'll explain later why this is.

  • <title>Software Selection</title>

    that's a text string at the top of the dialog. A caption for that dialog if you want so and it's optional. If you configure multiple titles for one dialog, the last one is used.

  • <question>KDE Software Selection</question>

    That's the text string behind the checkbox. If you don't configure a question, the name of the XML file that is triggered by this rule will be shown instead (in our example above, that would be "rules/kde.xml" and "rules/gnome.xml"). If you know what's in kde.xml and gnome.xml you maybe don't need the <question> but I'd prefer a short explaining text over just a filename.

  • <timeout config:type=""integer">30</timeout>

    if you don't answer the dialog in "timeout" seconds, AutoYaST will continue.
    As soon as you touch one checkbox or button, the timeout stops for this popup and you have to press "okay" to continue. The next dialog can have a new timeout then.

  • <conflicts config:type="list">

    here you can specify a list of element id's that conflict with this XML file. If you select this XML file, the conflicting one(s) will be deselected and disabled. Be careful what you configure here, you can create deadlocks. An element can conflict with another element on a different dialog and that's the reason why element id's have to be uniq.


Whether a question is pre-selected or not is defined by the result of the rule. In my example above, I configured a rule that matches always (100 = 100) and a rule that matches never (101 = 100). Without dialogs, such a rule file would not make a lot of sense because gnome.xml would never be used but here I use them to do the default pre-selection.
So again, if a rule matches, the file (kde.xml in our example) is pre-selected.
That means, if you add dialogs to your already existing rules.xml that has no dialogs yet and you set a timeout, your autoinstallation process will be the same like before, except that you'll see a popup dialog for "timeout" seconds. The rules work like before and you can see which ones have matched in the popups.

To sum things up:

All dialog configuration is done in the rules.xml file. Each <rule> can have one <dialog> which represents one checkbox on a dialog popup. You can have multiple dialog popups and you can have multiple rules (checkboxes) on one dialog popup.


This feature is officially implemented for openSUSE 11.3 but since openSUSE 11.2 is brand new and out for just a few days now, I made a driverupdate_11.2.tar.bz2 to make the feature available for openSUSE 11.2 too. If you want to try it, download and extract the file and copy the "driverupdate" file to the root of your installation source to get that feature on openSUSE 11.2.
Feedback is appreciated.

Thanx to Stacey Murphy and Martin Vogt for the idea.


have fun creating your own rules ;)
Uwe

Donnerstag, 22. Oktober 2009

Meet and Greet with AutoYaST

Bubli said that it might be a good idea to write an article of a very basic step by step instruction for AutoYaST and I had to agree with that. So this is more for people who don't ask questions like "can I use the 'ask' feature for 'rules' in AutoYaST?" ;)

So if you answer those questions with YES, then this article is for you:
  • you have never used AutoYaST
  • you just have a vague idea of what it is
  • you always thought it's too complicated and too much work for "just taking a quick look at it"
if you nodded three times, read on, I wrote this especially for you

What do we need for this tutorial?
  • an openSUSE boot CD/DVD like the openSUSE 11.2 DVD
  • a USB stick and a way to read/write to that stick (like an installed Windows or Linux system)
  • a physical machine for the test run (needs a DVD/CD drive and a USB port). The machine CAN be installed but you'll have the chance to abort the process before anything happened, so nothing will have changed then except that you'll know more about AutoYaST :-)
First of all you have to save the small AutoYaST XML snippet below in a file onto the USB stick. It doesn't matter which filesystem you have on the USB stick. It can be a Linux filesystem like for example ext4 but it can also be fat32 too, as long as openSUSE can mount the stick for reading.
Here is the file we want to use:

<?xml version="1.0"?>
<!DOCTYPE profile>
<profile xmlns="http://www.suse.com/1.0/yast2ns"·
xmlns:config="http://www.suse.com/1.0/configns">
<users config:type="list">
<user>
<encrypted config:type="boolean">false</encrypted>
<user_password>s3cr3t</user_password>
<username>root</username>
</user>
</users>
</profile>
copy that file to the USB stick and name it for example "my.xml". You can name it like you want but I'll refer to it by "my.xml". Later we will take a closer look to the XML file but for now we just want to see AutoYaST in action.
Put the SUSE DVD into the machine and plug the USB stick in too. Now boot from that DVD until you see the bootmenu:
Move the cursor to "Installation" and then type "autoyast=usb:///my.xml" to the prompt, like I did on the screenshot. That "autoyast=...." parameter triggers the automatic installation instead of the manual installation. Of course "usb:///..." is just an example and tells AutoYaST to look for the XML file on all USB devices.

After a while, yast will show up and will present you the so called "proposal screen" that you have to confirm if you are happy with the settings. That screen can be seen during the manual installation too, so it'll be familiar to you. You can do all kind of changes now.

To get a real "free-hand" installation you can turn that confirmation screen off in the AutoYaST XML file but the default is to show it and for this tutorial it's a good idea to take that break to see what AutoYaST will do. Nothing has happened so far to your machine. We could turn off the computer now and your system would be the same like before you booted AutoYaST.

Since we did not specify any partitioning in the AutoYaST XML file, AutoYaST will calculate a reasonable partition plan that you can see on the proposal screen now. It might look different on your hardware than on mine in the screenshot because it depends on your hardware and what kind of partitions you already have on the harddisk.

If you look at the software proposal on the screen, you can see that it's quite minimalist. It will only install 526 MB of software, which is just the base pattern and does not even include a X Window system. We can change that in our my.xml file of course but lets click "Install" for now on the bottom right, to start the installation (or turn off the machine if you don't want to apply any changes).

AutoYaST will partition the harddisk now and will install the software, which looks like during a manual installation.
While AutoYaST is doing it's job, we can take a look at the XML file again.
Every AutoYaST profile starts with the same header:

<?xml version="1.0"?>
<!DOCTYPE profile>
<profile xmlns="http://www.suse.com/1.0/yast2ns"
xmlns:config="http://www.suse.com/1.0/configns">

and ends with the same footer:

</profile>

Everything between the <profile> elements is your configuration.
In our my.xml file it's only the configuration of the root user with the password "s3cr3t". Actually not even that would be needed for an installation but without a root user, you can not login at the end.
You probably want to configure an own software selection too because we already saw that the system which is installing right now is very small.
The partitioning is something many people want to customize too, to have control on how exactly it looks like in the end and to be able to configure more complex setups like LVM or RAID.

So that would add a <software> and <partitioning config:type="list"> section to the profile like this:

<?xml version="1.0"?>
<!DOCTYPE profile>
<profile xmlns="http://www.suse.com/1.0/yast2ns"
xmlns:config="http://www.suse.com/1.0/configns">
<users config:type="list">
<user>
<encrypted config:type="boolean">false</encrypted>
<user_password>s3cr3t</user_password>
<username>root</username>
</user>
</users>
<software>
...
</software>
<partitioning config:type="list">
...
</partitioning>
</profile>

Since this text is for unexperienced AutoYaST users, I want to recommend to use the AutoYaST UI to configure a profile instead of a texteditor. You need to install the autoyast2 package for that and then you can start the UI by typing "yast2 autoyast" on the command line or by clicking on "Miscellaneous" and then on "Autoinstallation" in the YaST2 control center.

In the meantime our automatic installation should have rebooted and AutoYaST has finished the so called "2nd stage installation" where some post configuration happens. There is not so much to see there and AutoYaST will terminate without user interaction when it's finished. At the end you'll see the login prompt where you can login with username "root" and password "s3cr3t". I think you deserved a delicious piece of cheesecake now ;-)

That's it. The very basic steps of using AutoYaST to install a system. Maybe there will be more articles like this in the future, making the installation more and more complex because this were really just the basics.

Some important links:
AutoYaST Homepage
Archive of the AutoYaST mailinglist
Subscription to the AutoYaST mailinglist

thanks for flying AutoYaST - have fun ;)

P.S.: if you want to skip the confirmation screen, add this to your XML file between the <profile> tags:

<general>
<mode>
<confirm config:type="boolean">false</confirm>
</mode>
</general>

Dienstag, 7. Juli 2009

More Timeouts for AutoYaST

Run, Lola, Run!
a famous german movie

Today I want to introduce you some new timeouts you can configure in AutoYaST.
On openSUSE 11,2 you can use timeouts in two new places.

  • The feedback popups of your scripts can timeout now if you want

  • The ask-dialogs can timeout now too


So even with feedback and ask-questions, you can now have a non-stop installation.
How does it work? Lets start with the feedback dialogs:

<script>
<source>
<![CDATA[
echo "this feedback will timeout"
]]>
</source>
<feedback config:type="boolean">true</feedback>
<feedback_type>message</feedback_type>
<debug config:type="boolean">false</debug>
</script>
...
<report>
<messages>
<log config:type="boolean">false</log>
<show config:type="boolean">true</show>
<timeout config:type="integer">5</timeout>
</messages>
</report>

This is an ordinary AutoYaST script which makes use of the feedback mechanism and there is nothing special with it except for the new feedback_type. This type can be "message", "warning" or "error" and if you are experienced with AutoYaST, you might notice that these are the same values that you can configure timeouts for in the <report> section.
Your scripts will timeout like you configure it in the report section if you specify a feedback_type for them.
Without that feedback_type, the old behaviour of a blocking popup is used.

On ask dialogs it works a bit different:

<ask>
<title>Password: root</title>
<path>users,0,user_password</path>
<question>Password for root</question>
<password config:type="boolean">true</password>
<default>lousypassword</default>
<timeout config:type="integer">20</timeout>
</ask>

You can configure the timeout in seconds for each dialog and if the user does not answer the dialog in time, it will continue with the assumption that the default value is wanted.
Without that <timeout ...>, the old behaviour of a blocking ask-dialog is used.

Run, AutoYaST, Run!

au revoir, Uwe

Donnerstag, 18. Juni 2009

One string to rule them all ...

... one string to find them
Lord of the Rings (almost)

On openSUSE 11.2 I did a little change with the handling of how AutoYaST looks for the profile on devices. Currently you have to do it this way:

autoyast=device://sde2/mydir/myprofile.xml

to find the profile on /dev/sde2 in the path /mydir/myprofile.xml.
On openSUSE 11.2 you can use one string to find a profile on every device AutoYaST can find. So with:

autoyast=device:///mydir/myprofile.xml

AutoYaST will look for the profile on every device it can mount and will stop looking when the profile is found. Take care that you use three slashes if you want to use that feature. The old syntax with naming the device still works of course.
Actually that can even make the autoyast=usb://myprofile.xml superfluously because USB devices are found and mounted too with the new feature. I'll still keep the old USB syntax for a while but I might change the code underneath the veil to use the new "devices://" code.

Ciao! - Uwe

Mittwoch, 10. Juni 2009

Two AutoYaST Features by One Char

and the star char is - The Slash!

Feature 1:
On openSUSE 11.2, if you add a "/" at the end of a filename in the <files> section, AutoYaST will create a directory:


<files config:type="list">
<config_file>
<file_path>/myData/</file_path>
<file_permissions>644</file_permissions>
</config_file>
...
</files>


Maybe nothing which makes the crowd go wild but might be useful from time to time and saves you from writing a script just for that.

Feature 2:
That's a bit more impressive than the first. If you use a "/" at the beginning of a <package> or <pattern>, you tell AutoYaST to interpret it as a regular expression like this:


<software>
<patterns config:type="list">
<pattern>/.*_server</pattern>
</patterns>
<packages config:type="list">
<pattern>/kde4.*</pattern>·
</packages>
</software>


Beware of using <package>/.*</package> because that will select every package and some of them conflict.

happy slashing ;) - Uwe

Dienstag, 2. Juni 2009

AutoYaST and LVM striping

A less known fact of the AutoYaST LVM configuration is, that it can do striping too. The reason for that being less known might be, that I just documented it a few weeks ago, even though that feature was available since ages.
If you now say "I want that!!! What is it good for?" you can read this article. In a nutshell, with striping you spread the harddisk IO across multiple physical devices which increases the IO performance but also the risk of data loss, so never use that without a RAID system below.

How to use that in AutoYaST? Just configure the number of physical devices and the blocksize in KB like this:


<drive>
<device>/dev/data_vg</device>
<is_lvm_vg config:type="boolean">true</is_lvm_vg>
<type config:type="symbol">CT_LVM</type>
<partitions config:type="list">
<partition>
<filesystem config:type="symbol">ext3</filesystem>
<lv_name>my_data_lv</lv_name>
<mount>/data</mount>
<stripes config:type="integer">2</stripes>
<stripesize config:type="integer">4</stripesize>
<size>10G</size>
</partition>
</partitions>
<pesize>4M</pesize>
<use>all</use>
</drive>

That's the same like you would do without striping, except for those two keys:

<stripes config:type="integer">2</stripes>

which is the number of physical devices you use. And:

<stripesize config:type="integer">4</stripesize>

which is the size of a block in KB. So after writing 4kb the physical device will be switched.
That's all you need to activate striping on a logical volume.


happy striping - Uwe

Donnerstag, 30. April 2009

Keep what you got

Let's say the docs present a simplified view of reality...
Larry Wall

Recently I got a bugreport against SLES11 by a customer who uses an undocumented a secret feature of AutoYaST that is quite fancy. It's hidden in the <networking> section and that option can not be configured with the UI. It's called:

<keep_install_network config:type="boolean">false</keep_install_network>

unfortunately that feature is broken on openSUSE 11.1 and SLES11 (that's why there was a bugreport) but will be fixed for openSUSE 11.2 and maybe on SP1 for SLES11.
What does it do? Well, actually you can take it literally. A networking section like this ...

<networking>
<keep_install_network config:type="boolean">true</keep_install_network>
</networking>

... will keep the network configuration that was created by linuxrc by doing an installation of the system over a network. linuxrc will raise the network then to connect the installation source and with that boolean set to true in the XML file, AutoYaST will copy that network configuration into the installed system. So if the network configuration during the installation is the same you want in the running system, you don't have to configure it in the XML file. Just set that boolean to true and you'll keep your installation network in the running system.

Thanx to Bubli and Michal for supporting me with that bug.

au revoir - Uwe