Automate Install With AutoYaST Answer Files
Desktop - OpenSUSE

 

This is the final article on installing opensuse. To recap we've covered Configuring the DHCP ServerInstalling Apache on OpenSUSEOpenSUSE PXE Boot and today we'll be tackling how to automate an install with AutoYaST answer files.

The final part of our installation jigsaw puzzle is to create the answer file, in SUSE this is known as AutoYaST. If we were only ever to install one server or one desktop then maybe we could do without answer files; however where we need to install a few or many then AutoYaST provides us with an unattended installation:- a build script to create consistency and compliance we regulatory bodies governing security. In short we need answer files.

 

What we will look at

  1. Building a reference file
  2. Editing the file
    a. Disk Partitioning
    b. Boot Loader
    c. User
    d. Networking
  3. Running the install with AutoYaST

Building a Reference File

During the installation of openSUSE you can clone your installation to make an answer file. If that was not chosen though, it is still easy to create after the install though YaST after the event. I would suggest though, whichever way the answer file is created it will still want some tuning with a text editor afterwards. With openSUSE the autoyast editor is not installed by default, so we need to add this with:

zypper in autoyast2

OpenSUSE Install With AutoYaST

Once this is successfully installed you will be able to access this in YaST, the main SUSE control panel, in the Miscellaneous Section > Autoinstallation
OpenSUSE Install With AutoYaST

Selecting the program icon then will take you into the answer file editor. From the tools menu, found at the top, we can then select: “Create Reference Profile”. This allows an answer file to be created from the current, or host machine settings. We can choose which settings we want to copy and then select ok.
OpenSUSE Install With AutoYaST

The editor is OK and we can choose some configurations that we want to copy, like the boot loaded, date and time, keyboard, package selection etc. Some of these settings will need editing after and with others, it is simply easiest to add the configuration to the XML file directly.
With the file created choose save as from the menu and in my case, for the demonstration, I will save to /install/11-4/oss.xml. This location is accessible as my web installation source.

Editing to answer file

To edit the file directly you can use any text editor, I will use VI but it is personal choice. The YaST editor is ok but, as with so many GUI tools, it simply cannot set everything exactly the way you want or need. Many of the setting relate to specific resources like the disk-id of the host machine or the MAC Address of the host. If we were to clone the users and groups, all users and groups are cloned, even the system accounts. This is not required as the accounts are created as services are installed. I would see the YaST tool as a starting point from then on edits can be made with the text editor.

Disk Partitioning

Unless we need a specific partitioning scheme we can allow autoyast to build the partition table for us and format the volumes. This will provide for a swap partition and a root partition. For simple desktops and servers this is enough and keeps the configuration really simple:

OpenSUSE Install With AutoYaST
Being an XM file we start with <partitioning> and close with </partitioning>. We then add a <drive>. We do not mention the device name so the first drive found is used, the partition table is wiped and <use>all</use> denotes the auto-partitioning.

Bootloader

This is easy to clone but we need to make sure that we delete any reference to disks by their ID and replace with device names.

OpenSUSE Install With AutoYaST

From the partial <bootloader> XML section we can see the grub stanzas point to disk/by-id entries. This, then, is pointing to unique identifiers on the cloned machine. We need to change these to device names, such as, for the resume (swap) entry /dev/sda1 and the root entry /dev/sda2:

OpenSUSE Install With AutoYaST

Check the whole of the bootloader section for these types of entries. I have also removed the stanzas for the failsafe mode and floppy boot as they are not required.

Users

It is easy to add your own user section. If you use the YaST tool, it will clone all users and groups. We only need to create the root user and perhaps one other standard user. All other system users and groups are created as required.

OpenSUSE Install With AutoYaST

Each user will appear in the <users> XML section delineated but <user></user>. Here , the user root has been added with a clear text password. For added security, use the output of the normal passwd command to generate an encrypted password. The encrypted flag would then be set to true.

Networking

Take great care and caution when cloning the networking settings, it is easy to have misconfigurations with MAC Address being included which relate to the host machine. Once you have a Networking section created it become easy to copy, personally, I have become used to using my own Networking section.

OpenSUSE Install With AutoYaST

Installing using the answer file

Once created there may be a little debugging left. However, we need to test with a sample build to work out what is working and what is not. Building on to a virtual machine is just perfect as we can always revert to saved version of the VM to test again and again. It will not take long until you have the perfect answer file. If you are installing using the PXE boot setup we have created we then need to add the autoyast file entry into the /srv/tftpboot/pxelinux.cfg/default file.

OpenSUSE Install With AutoYaST

The addition being to the append line: autoyast=http://172.17.1.1/opensuse11-4/oss.xml

The install then should proceed unhindered and without input from yourself other than to select the install option from the PXE menu.

 

Don't forget this is part 4 of our OpenSUSE installation series. Other articles include Configuring the DHCP ServerInstalling Apache on OpenSUSE, and OpenSUSE PXE Boot.