Table of Contents
Rules offer the possibility to configure a system depending on system attributes by merging multiple control file during installation. The rules based installation is controlled by a rules file.
The rules file is an XML based file that contains rules for each group of systems (or single systems) that you want to automatically install. A set of rules distinguish a group of systems based on one or more system attributes, after passing all rules, it links each group of rules to a profile. Both the rules file and the profiles must be located in a pre-defined and accessible location.
The rules file is retrieved only if no specific control is supplied using the autoyast keyword. For example, if the following is used, the rules file wont be evaluated:
autoyast=http://10.10.0.1/profile/test.xml |
If more than one rule apply, the final profile for each group is generated on the fly using a merge script. The merging process is based on the order of the rules and later rules override configuration data in earlier rules.
The use of a rules file is optional. If the rules file is not found, system installation proceeds in the classic way by just using the supplied profile or by searching for the profile depending on the MAC or the IP address of the system.
Example 6.1. Simple rules file
The following simple example illustrates how the rules file is used to retrieve the configuration for a client with known hardware.
<?xml version="1.0"?> <!DOCTYPE autoinstall SYSTEM "/usr/share/autoinstall/dtd/rules.dtd"> <autoinstall xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns"> <rules config:type="list"> <rule> <disksize> <match>/dev/hdc 1000</match> <match_type>greater</match_type> </disksize> <result> <profile>machine1.xml</profile> <continue config:type="boolean">false</continue> </result> </rule> <rule> <disksize> <match>/dev/hda 1000</match> <match_type>greater</match_type> </disksize> <result> <profile>machine2.xml</profile> <continue config:type="boolean">false</continue> </result> </rule> </rules> </autoinstall> |
The last example defines 2 rules and provides a different profile for every rule. The rule used in this case is disksize. After parsing the rules file, YaST2 attempts to match the system being installed to the rules in the rules.xml file in the following order: first rule through the last rule. A rule match occurs when the system being installed matches all of the system attributes defined in the rule. As soon as a system matches a rule, the result resource is added to the stack of profiles AutoYaST will be using to create the final profile. The continue property tells AutoYaST if it should continue with other rules or not after a match has been found.
If the first rule does not match, next rule in the list is examined until a match is found.
Using the disksize attribute, you can provide different configurations for different hard drives with different size. First rule checks if the device /dev/hdc is available and if it is greater than 1 GB in size using the match property.
A rule must have at least one attribute to be matched. If you need to check more attributes, i.e. memory or architectures, you can add more attributes in the rule resource as shown in the next example.
Example 6.2. Simple rules file
The following simple example illustrates how the rules file is used to retrieve the configuration for a client with known hardware.
<?xml version="1.0"?> <!DOCTYPE autoinstall SYSTEM "/usr/share/autoinstall/dtd/rules.dtd"> <autoinstall xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns"> <rules config:type="list"> <rule> <disksize> <match>/dev/hdc 1000</match> <match_type>greater</match_type> </disksize> <memsize> <match>1000</match> <match_type>greater</match_type> </memsize> <result> <profile>machine1.xml</profile> <continue config:type="boolean">false</continue> </result> </rule> <rule> <disksize> <match>/dev/hda 1000</match> <match_type>greater</match_type> </disksize> <memsize> <match>256</match> <match_type>greater</match_type> </memsize> <result> <profile>machine2.xml</profile> <continue config:type="boolean">false</continue> </result> </rule> </rules> </autoinstall> |
The rules directory must be located in the same referenced directory used with the autoyast keyword on boot time, so if the client was booted using autoyast=http://10.10.0.1/profiles/, AutoYaST will search for the rules file in http://10.10.0.1/profiles/rules/rules.xml.
The rules.xml file must have:
At least one rule
It must have the name rules.xml
It must be located in the directory rules in the profile repository
At least one attribute to match in the rule
The following table lists the predefined system attributes you can match in the rules file.
Table 6.1. System Attributes
Attribute | Values | Description |
---|---|---|
hostaddress | IP address of host | This attribute must always match exactly |
domain | Domain name of host | This attribute must always match exactly |
network | network address of host | This attribute must always match exactly |
mac | MAC address of host | This attribute must always match exactly. (MAC addresses to be matched should be in the form 0080C8F6484C |
linux | Number of installed Linux partitions on the system | This attribute can be 0 or more |
others | Number of installed non-Linux partitions on the system | This attribute can be 0 or more |
xserver | X Server needed for graphic adapter | This attribute must always match exactly |
memsize | Memory available on host in MByes | All match types are available |
totaldisk | Total disk space available on host in MBytes | All match types are available |
haspcmica | System has PCMCIA (i.e Laptops) | Exact match required, 1 for available PCMCIA or 0 for none |
hostid | Hex representation of IP address | Exact match required |
arch | Architecture of host | Exact match required |
karch | Kernel Architecture of host (i.e. SMP kernel, Athlon Kernel) | Exact match required |
disksize | Drive device and size | All match types are available |
product | The hardware product name as specified in SMBIOS | Exact match required |
product_vendor | The hardware vendor as specified in SMBIOS | Exact match required |
board | The system board name as specified in SMBIOS | Exact match required |
board_vendor | The system board vendor as specified in SMBIOS | Exact match required |
custom1-5 | Custom rules using shell scripts | All match types are available |
The tag match_type is used to define how the rules should be checked. There exist 4 types of matching:
exact
greater
lower
range (for IPs, memsize and totaldisk only)
exact should always be used with all string attributes
When using multiple rules, you might want to have either all rules match or just some. For example you might want either 2 or more rules to always match or just one of a list of rules in a rule set. The operator is defined with the operator tag which can either be "and" (default) or "or".