Creating a TemplateΒΆ

A template is a configuration file which defines the machine image you want to build. The format of this file is simple JSON. Note that the template can be saved locally or stored on a server, in which case hammr will access it via a URL. For security reasons we recommend that you save your UForge credentials in a seperate credentials file, saved at the same location as your template.

The mandatory values when creating a template are:

  • name: the name of the template to create. You can easily make the name unique by using the timestamp keyword (surrounded by curly brackets).
  • version: the version of the template.
  • os : the operating system details to use the in your images. You must include the OS family name, version and architecture type. For more information regarding OS and package parameters, see Adding OSes and Packages to Your Template

For more details about the various parameters you can set in your template to define the machine image you want to create, refer to the Templates Specification section.

The following is an example of the minimum information needed in your configuration file to define a template. It includes the name, version, a few installation parameter and the OS. This example describes a CentOS 6.4 32-bit template.

{
  "stack" : {
    "name" : "myTemplate",
    "version" : "1.0",
    "installation" : {
      "internetSettings" : "dhcp",
      "diskSize" : 12288,
      "swapSize" : 512
    },
    "os" : {
      "name" : "CentOS",
      "version" : "6.4",
      "arch" : "x86_64",
      "profile" : "Minimal"
    }
 }
}

Once you have written and saved this minimal template you can then create the template using template create:

$ hammr template create --file <blueprint>.json
Validating the template file [/Users/james/nginx-template.json] ...
OK: Syntax of template file [/Users/james/nginx-template.json] is ok
Creating template from temporary [/var/folders/f6/8kljm7cx3h7fvb26tq18kw4m0000gn/T/hammr-15888/archive.tar.gz] archive ...
100%|#############################################################################|
OK: Template create: DONE
Template URI: users/root/appliances/898
Template Id : 898