Hosts.xml

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search

This document in other languages: French

hosts.xml is a file which defines the hosts and associated profiles, which these hosts will use.

This file has to be placed in the same directory as wpkg.js. Alternatively it may be stored in a subdirectory named hosts with an individual filename e.g. room1.xml, room2.xml.

WPKG will not work without this file.

Profiles are defined in profiles.xml file, and they describe software packages, which will be installed on hosts.


hosts.xml structure

The structure of hosts.xml is as follows:

<wpkg>

<host name="host1" profile-id="custom1" />
<host name="host2" profile-id="custom2" />

</wpkg>

Which means, that a hostname with a name host1 will use a profile custom1, and a hostname with a name host2 will use a profile custom2.

If you have more hosts, or want to group them, it would be unwise to edit dozens of host entries just to attach them all to one or two profiles. That's why you can use Regular Expression Syntax.

The name can not have more than 15 characters. This limitation is due to netbios name length [1]. You can still give your computer a longer name but in this file only the first 15 chars are (transmitted?) matched.

XSD schema

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:complexType name="profileType">
		<xs:attribute name="id" type="xs:string" use="required" />
	</xs:complexType>
	<xs:complexType name="hostType">
		<xs:sequence minOccurs="0">
			<xs:choice maxOccurs="unbounded">
				<xs:element maxOccurs="unbounded"
					    name="profile"
					    type="profileType">
				</xs:element>
			</xs:choice>
		</xs:sequence>
		
		<xs:attribute name="name" type="xs:string" use="required" />
		<xs:attribute name="profile-id" type="xs:string" use="required" />
	</xs:complexType>

	<xs:element name="wpkg">
	<xs:complexType>
	  <xs:sequence>
		<xs:element minOccurs="0" maxOccurs="unbounded"
			    name="host" type="hostType">
		</xs:element>
	  </xs:sequence>
	</xs:complexType>
	</xs:element>
</xs:schema>

Quick examples

Below is a quick explanation on the usage of regular expression within the hosts.xml file.

<host name="b[0-9]+" profile-id="profile" />

works for: b1, b10, b100
does not work for: bubu, b, x, x1, x10, x100


<host name="b.+" profile-id="profile1" />

works for "b10", "b12345", "bubu" etc.


<host name=".+" profile-id="profile" />

works for *all* hosts - use with care (!), place at the bottom of hosts.xml (see below why .+ regular expression match should be placed at the end of the hosts.xml file).


<host name="b.+" profile-id="profile2" />
<host name="bronek1" profile-id="profile1" />
<host name="bron.+" profile-id="profile3" />

Normally, hosts are parsed from top to the bottom, except when the hostname is not a regular expression. So the host bronek1 will match profile1, even though it also matches b.+ and bron.+ (which are regular expressions).


<host name="cad01|cam03|cnc23" profile-id="profile1" />

Use the above to specify several hosts, which do not follow a single pattern

Several profiles for one host

It's possible to assign more than one profile to a host:

<host name="host1" profile-id="custom1" >
  <profile id="addons1"/>
  <profile id="addons2"/>
</host>

Remarks:

  • Use profile-id (profile hyphen id) in the host name, but profile id (profile space id) for the following profiles
  • You cannot omit the main profile (profile-id=...)
  • You can only assign a profile, but no packages
  • host.domain will match ANY machine of that domain!!

Applying multiple profiles to a single host

As of WPKG 1.3 you can set the following in config.xml:

<param name='applyMultiple' value='true' />

Multiple matching host entries will then apply to the machine, instead of just the first one.

See also