Skip to content

Template language and variables

You can use the following variables in “text” OS Template assets, with the “Advanced” template type.

Note that MetalSoft provides most of the templates already so their manual creation is not necessary in most situations. Refer to Managing OS templates for more details.

The template language uses the Nunjucks language, a subset of the “Jinja2” language that many solutions use. Refer to the Nunjucks documentation for a complete reference of the language capabilities.

MetalSoft currently uses this template language only for OS templates, but will implement it for Switch provisioning as well as Workflows in the future.

The variables are accessed in blocks such as this one:

{% for interface in network_configuration.interfaces. %}
{% for address in interface.ipv4_addresses %}
address: {{address.ip}}
netmask: {{address.netmask}}
gateway: {{address.gateway}}
{% endfor %}

For a real world example of this in action see This template.

You can also directly access variables using the full path for simpler scenarios:

{{network_configuration.interfaces[0].ipv4_addresses[0].ip}}

MetalSoft sends the ServerInstanceContextOSInstallationData object to the OS template during deployment. The definition might be different from site to site, so you can see it in the swagger or redoc documentation: /api/v2/redoc#schema/ServerInstanceContextOSInstallationData

A live example (which might not match your deployed version) can be found here: https://us08.metalsoft.io/api/v2/redoc#schema/ServerInstanceContextOSInstallationData

The following are examples of objects and how they are populated.

{
"site": {
"id": 1,
"slug": "reading-uk",
"name": "Reading, UK"
},
"siteConfig": {
"repoURL": "string",
"dnsZoneId": 5,
"dnsZoneName": "example.com",
"DNSServers": [
"string"
],
"NTPServers": [
"string"
]
},
"server": {
"serverId": 0,
"serverTypeId": 0,
"serverUUID": "string",
"serialNumber": "string",
"managementAddress": "string",
"username": "string",
"passwordEncrypted": "string",
"diskCount": 0,
"bmcMacAddress": "string",
"vendor": "Unknown",
"vendorSkuId": "string",
"model": "string",
"rackName": "string",
"gpuCount": 0,
"gpuInfo": [
{
"model": "string",
"vendor": "string"
}
],
"interfaces": [
{
"serverInterfaceId": 0,
"serverId": 0,
"macAddress": "string",
"index": 0,
"switchPortId": "string",
"switchHostname": "string",
"capacityMbps": 0,
"addOnMac": "string",
"addOnType": "hba",
"addOnInfo": {},
"pxeEnabled": 0,
"supportsIscsiBoot": 0,
"fibreChannelWwpn": "string",
"description": "string",
"aliasIndex": 0,
"osInfo": "not_tested",
"networkDevice": {},
"networkDeviceInterface": {},
"ipv4Addresses": [
"192.168.1.1",
"192.168.1.2"
],
"ipv6Addresses": [
"2001:db8::1",
"2001:db8::2"
],
"vlanId": 0,
"defaultFabricId": 0,
"redundancyGroupIndex": 0
}
],
"disks": [
{
"id": 0,
"serverId": 0,
"model": "string",
"diskSizeGb": 0,
"serial": "string",
"vendor": "string",
"status": "installed",
"type": "none",
"serverStorageControllerId": 0
}
],
"storageControllers": [
{
"id": 0,
"serverId": 0,
"name": "string",
"label": "string",
"description": "string",
"options": {
"raidTypesSupported": [
"RAID0",
"RAID1",
"RAID5",
"RAID10"
],
"controllerModesSupported": [
"HBA",
"RAID"
]
},
"mode": "HBA"
}
],
"tags": [
"string"
]
},
"serverInstance": {
"id": 1,
"label": "string",
"fqdn": "string",
"customVariables": {},
"customStorageProfile": {
"controllers": [
{
"id": "RAID-1.1",
"mode": "RAID",
"volumes": [
{
"controllerName": "string",
"volumeName": "string",
"diskSizeGb": 0,
"diskType": "none",
"diskCount": 0,
"raidType": "raid0"
}
]
}
]
},
"isVmInstance": 0,
"isEndpointInstance": 0,
"provisionInstanceDnsRecords": true,
"hostname": "my-custom-hostname",
"osCredentials": {
"initialUser": "string",
"initialPasswordEncrypted": "string"
},
"initiatorNqn": "string",
"iscsiInitiatorIqn": "string",
"iscsiInitiatorUsername": "string",
"iscsiInitiatorPasswordEncrypted": "string"
},
"serverInstanceGroup": {
"id": 1,
"label": "string",
"subdomainPermanent": "string",
"serverGroupName": "server-instance-group-name",
"customVariables": {},
"isVmGroup": 0,
"isEndpointInstanceGroup": 0
},
"infrastructure": {
"label": "string",
"customVariables": {}
},
"driveGroups": [
{
"label": "string",
"infrastructureId": 0,
"templateId": 1,
"driveSizeMbDefault": 0,
"serverInstanceGroupId": 1,
"expandWithServerInstanceGroup": 1,
"qoS": "string",
"storageType": "iscsi_ssd",
"filesystemInfo": {},
"subdomain": "string",
"updatedTimestamp": "string",
"id": 0,
"revision": 0,
"extensionInstanceId": 1,
"containerClusterId": 1,
"serviceStatus": "ordered",
"subdomainPermanent": "string",
"dnsSubdomainId": 0,
"dnsSubdomainPermanentId": 0,
"allocationAffinity": "same_storage",
"config": {
"revision": 0,
"label": "string",
"infrastructureId": 0,
"templateId": 1,
"driveSizeMbDefault": 0,
"serverInstanceGroupId": 1,
"expandWithServerInstanceGroup": 1,
"qoS": "string",
"storageType": "iscsi_ssd",
"filesystemInfo": {},
"subdomain": "string",
"updatedTimestamp": "string",
"dnsSubdomainChangeId": 0,
"deployType": "create",
"deployStatus": "not_started",
"infrastructureDeployId": 0
},
"createdTimestamp": "string"
}
],
"drives": [
{
"label": "string",
"groupId": 1,
"instanceId": 1,
"storagePoolId": 0,
"sizeMb": 0,
"storageImageName": "string",
"iscsiIndexHex": "string",
"templateId": 1,
"osAdminUsername": "string",
"osAdminPasswordEncrypted": "string",
"storageType": "iscsi_ssd",
"subdomain": "string",
"updatedTimestamp": "string",
"sshPort": 0,
"operatingSystemInfo": {},
"filesystemInfo": {},
"id": 0,
"revision": 0,
"infrastructureId": 0,
"infrastructure": {
"userIdOwner": 0,
"id": 1
},
"serviceStatus": "ordered",
"storageRealSizeCachedMb": 0,
"storageRealSizeWithSnapshotsCachedMb": 0,
"storageVirtualSizeCachedMb": 0,
"storageUpdatedTimestamp": "string",
"targets": [
{}
],
"clusterCustomInfo": {},
"sshKeyPairInternalEncrypted": {},
"wwn": "string",
"provisioningProtocol": "iSCSI",
"subdomainPermanent": "string",
"dnsSubdomainId": 0,
"dnsSubdomainPermanentId": 0,
"networkVlanId": 0,
"config": {
"revision": 0,
"label": "string",
"groupId": 1,
"instanceId": 1,
"storagePoolId": 0,
"sizeMb": 0,
"storageImageName": "string",
"iscsiIndexHex": "string",
"templateId": 1,
"osAdminUsername": "string",
"osAdminPasswordEncrypted": "string",
"storageType": "iscsi_ssd",
"subdomain": "string",
"updatedTimestamp": "string",
"sshPort": 0,
"operatingSystemInfo": {},
"filesystemInfo": {},
"dnsSubdomainChangeId": 0,
"deployType": "create",
"deployStatus": "not_started",
"infrastructureDeployId": 0
},
"createdTimestamp": "string"
}
],
"fileShares": [
{
"sizeGB": 0,
"updatedTimestamp": "string",
"storagePoolId": 0,
"label": "string",
"subdomain": "string",
"logicalNetworkId": 0,
"id": 0,
"revision": 0,
"infrastructureId": 0,
"infrastructure": {
"userIdOwner": 0,
"id": 1
},
"createdTimestamp": "string",
"serviceStatus": "ordered",
"subdomainPermanent": "string",
"dnsSubdomainId": 0,
"networkVlanId": 0,
"endpoint": "string",
"config": {
"revision": 0,
"sizeGB": 0,
"updatedTimestamp": "string",
"storagePoolId": 0,
"label": "string",
"subdomain": "string",
"dnsSubdomainChangeId": 0,
"deployType": "create",
"deployStatus": "not_started",
"infrastructureDeployId": 0,
"logicalNetworkId": 0
}
}
],
"buckets": [
{
"sizeGB": 0,
"updatedTimestamp": "string",
"storagePoolId": 0,
"label": "string",
"subdomain": "string",
"logicalNetworkId": 0,
"id": 0,
"revision": 0,
"infrastructureId": 0,
"infrastructure": {
"userIdOwner": 0,
"id": 1
},
"createdTimestamp": "string",
"serviceStatus": "ordered",
"subdomainPermanent": "string",
"dnsSubdomainId": 0,
"endpoint": "string",
"accessKeyId": "string",
"secretKeyEncrypted": "string",
"config": {
"revision": 0,
"sizeGB": 0,
"updatedTimestamp": "string",
"storagePoolId": 0,
"label": "string",
"subdomain": "string",
"dnsSubdomainChangeId": 0,
"deployType": "create",
"deployStatus": "not_started",
"infrastructureDeployId": 0,
"logicalNetworkId": 0
}
}
],
"sharedDrives": [
{
"label": "string",
"storagePoolId": 0,
"sizeMb": 0,
"storageImageName": "string",
"storageType": "iscsi_ssd",
"qoS": null,
"subdomain": "string",
"logicalNetworkId": 0,
"updatedTimestamp": "string",
"id": 0,
"revision": 0,
"infrastructureId": 0,
"infrastructure": {
"userIdOwner": 0,
"id": 1
},
"serviceStatus": "ordered",
"storageRealSizeCachedMb": null,
"storageRealSizeWithSnapshotsCachedMb": null,
"storageVirtualSizeCachedMb": null,
"storageUpdatedTimestamp": "string",
"targets": [
{}
],
"wwn": null,
"allocationAffinity": "same_storage",
"provisioningProtocol": "iSCSI",
"subdomainPermanent": "string",
"dnsSubdomainId": 0,
"dnsSubdomainPermanentId": 0,
"config": {
"revision": 0,
"label": "string",
"storagePoolId": 0,
"sizeMb": 0,
"storageImageName": "string",
"storageType": "iscsi_ssd",
"qoS": null,
"subdomain": "string",
"dnsSubdomainChangeId": 0,
"deployType": "create",
"deployStatus": "not_started",
"infrastructureDeployId": 0,
"logicalNetworkId": 0,
"updatedTimestamp": "string"
},
"createdTimestamp": "string"
}
],
"network": [
{
"interfaces": [
{
"interfaceType": "physical",
"logicalNetworkId": 0,
"logicalNetworkName": "string",
"logicalNetworkLabel": "string",
"typeInterfaceId": 0,
"macAddress": "string",
"mtu": 0,
"vlanId": 0,
"ipv4Addresses": [
{
"ip": "string",
"cidr": "string",
"gateway": "string",
"isDefaultGateway": true,
"netmask": "string",
"maskBits": 0
}
],
"ipv6Addresses": [
{
"ip": "string",
"cidr": "string",
"netmask": "string",
"maskBits": 0
}
],
"routes": [
{
"to": "string",
"via": "string"
}
],
"members": [
{
"id": 0,
"interfaceType": "physical"
}
],
"links": [
{
"id": 0,
"interfaceType": "physical"
}
]
}
]
}
],
"variables": {},
"secrets": {},
"userSSHKeys": [
"string"
],
"managementSSHKey": "string"
}