Template¶
The template object defines a templated content that can be referenced by its ID. The content of the template (or in-line template in a bootenv object) is a golang text/template string. The template has a set of special expansions. The normal expansion syntax is:
This would expand to the machine's Name
field. There are helpers for the parameter spaces, the bootenv object, and some miscellaneous functions. Additionally, the normal golang text/template functions are available as well. Things like range
, len
, and comparators are available as well. Template inclusion is supported by the following syntax:
The following table lists the current set of expansion custom functions.
Note
.GenerateToken
generates either a known or unknown token for use by the template to update objects in DRP. The tokens are valid for a limited time as defined by the knownTokenTimeout
and unknownTokenTimeout
preferences. The tokens are also restricted to the function they can perform. The known token is limited to only reading and updating the specific machine the template is being rendered for. If a machine is not present during the render, an unknown token is generated that has the ability to query and create machines. These are used by the install process to indicate that the install is finished and that the local
bootenv should be used for the next boot and during the discovery process to create the newly discovered machine.
Note
.Machine.Path
is particularly useful for ensuring that templates are expanded into a unique file space for each machine. An example of this is per machine kickstart files. These can be seen in the ubuntu-16.04-install bootenv.
With regard to the .Param
and .ParamExists
functions, these return the parameter or existence of the parameter specified by the key
input. The parameters are examined from most specific to global. This means that the Machine object's profile is checked first, then the list of profiles associated with the machine, and finally the global profile. The parameters are stored in a profile.
The default template and bootenv use the following optional (unless noted with "*") parameters.
Parameter | Type | Description |
---|---|---|
ntp_servers |
Array of string | The format is an array of IP addresses in dotted quad format. |
proxy-servers |
Array of objects | See the parameter definition. |
operating-system-disk |
String | A string to use as the default install drive. Examples include /dev/sda , or sda depending upon kickstart or preseed. |
access-keys |
Map of strings | The key is the name of the public key. The value is the public key. All keys are placed in the .authorized_keys file for the root account. |
provisioner-default-password-hash |
String | The password hash for the initial default password, RocketSkates |
provisioner-default-user |
String | The initial user to create for ubuntu/debian installs |
dns-domain |
String | DNS Domain to use for this system's install |
operating-system-license-key * |
String | Windows only |
operating-system-install-flavor * |
String | Windows only |
For some examples of this in use, see as well as the example profiles in the assets directory.
Sub-templates¶
A template may contain other templates as described above. The system comes with some pre-existing sub-templates to make kickstart and preseed generation easier. The following templates are available had have some parameters that drive them. The required parameters can be applied through profiles or the machine profile. The templates contain comments with how to use and parameters to set.
JSON Template Fields¶
Field | Definition |
---|---|
Contents | Contents is the raw template. It must be a valid template according to text/template. required: true |
Description | Description is a string for providing a simple description |
EndDelimiter | EndDelimiter is an optional end delimiter. required: false |
ID | ID is a unique identifier for this template. It cannot change once it is set. required: true |
Meta | Meta contains the meta data of the object. The type of this field is a key / value map/dictionary. The key type is string. The value type is also string. The general content of the field is undefined and can be an arbritary store. There are some common known keys: color - The color the UX uses when displaying icon - The icon the UX uses when displaying * title - The UX uses this for additional display information. Often the source of the object. Specific Object types use additional meta data fields. These are described at: https://docs.rackn.io/stable/redirect/?ref=rs_object_metadata |
StartDelimiter | StartDelimiter is an optional start delimiter. required: false |