Skip to content

Hello World Basic Development Life Cycle

YanaSimeonova edited this page Apr 8, 2019 · 9 revisions

The core of composite template is a YAML based textual definition of the target environment or one of its parts.

Template YAML

  1. Open the templates/tutorial/template.yaml file in a YAML-enabled editor
  2. Each template MUST have a unique identifier, alias, within Command Central templates list. The alias can only have alpha-numeric characters, underscores, dashes, and dots.
  3. The description is optional but always useful. It should be short.
  4. The version is optional but also useful

Enter the following in the initial version of the template.

alias: tutorial
description: Hello Command Central DevOps World!
version: 0.1

Save the changes you made to template.yaml

See complete template DSL (Domain Specific Language) documentation here

Import project 'templates' by running the ant templates command:

[user@linuxbox tutorial]$ ant templates
 
...
 
BUILD SUCCESSFUL
 
Total time: N seconds

The ant templates command builds the template archive build/templates/tutorial.zip, then imports it into Command Central, overwriting any previous version of the template.

Apply the template by running the ant up command:

[user@linuxbox tutorial]$ ant up -Dtemplates=tutorial
 
...
 
BUILD SUCCESSFUL
 
Total time: N seconds

The ant up command validates input parameters and then starts the template application job. Then it monitors the execution of the created job and reports its status as the jobs runs. If the template job fails, the command fails with Build Failed error message, otherwise BUILD SUCCESSFUL message is displayed.

You can check Command Central default log by running ant log command

[user@linuxbox tutorial]$ ant log
...
[cc] 2018/01/04 11:56:22 INFO  #1174  Begin applying composite template: tutorial
[cc] 2018/01/04 11:56:22 INFO  #1174  Skipping stage: Checking migration source nodes registry...
[cc] 2018/01/04 11:56:22 INFO  #1174  Skipping stage: Adding source nodes to Command Central:  ...
[cc] 2018/01/04 11:56:22 INFO  #1174  Skipping stage: Updating migration source nodes registry...
[cc] 2018/01/04 11:56:22 INFO  #1174  Skipping stage: Preparing source machines for migration:  ...
[cc] 2018/01/04 11:56:22 INFO  #1174  Skipping stage: Preparing target machines for migration:  ...
[cc] 2018/01/04 11:56:22 WARN  #1174  No nodes will be bootstrapped!
[cc] 2018/01/04 11:56:22 INFO  #1174  Updating inventory cache for nodes []
[cc] 2018/01/04 11:56:22 INFO  #1174  Updating configurations cache for nodes []
[cc] 2018/01/04 11:56:22 INFO  #1174  Layers to provision: []
[cc] 2018/01/04 11:56:22 INFO  #1174  Updating inventory cache for nodes []
[cc] 2018/01/04 11:56:22 INFO  #1174  Updating configurations cache for nodes []
[cc] 2018/01/04 11:56:22 INFO  #1174  Finish applying composite template: tutorial
[cc] 2018/01/04 11:56:22 INFO  #1174  Job completed: id 66 status DONE started Thu Jan 04 11:56:22 PST 2018 - Applying template tutorial

BUILD SUCCESSFUL

Experiment

Make a minor change to the template, for example, add !! to the description property

description: Hello Command Central DevOps World!!!

Save your changes.

Run ant templates up log -Dtemplates=tutorial

Basic YAML Rules

Here are the basic YAML rules:

  1. Indentation

YAML is a whitespace-indented language, meaning that indentation is used to denote structure. Items of the same indentation are considered to be siblings, while more or less indentation denotes child and parent relationships, respectively. For example:

- john:
    children:
        - james:
            children:
                - jim
                - jane
        - jenny:
            children: []
- jeremy:
    children: []
  1. No Tabs

Because they are universally supported, spaces are the whitespace character of choice within YAML files, and tabs are never allowed. Indenting with tabs instead of spaces within a YAML file is a common mistake for beginners, and can be very difficult to diagnose, so take special care to use the proper indentation method whenever working with YAML. To help mitigate this issue, it is highly recommended to display whitespace characters in your editor otherwise, it could be difficult to tell if the following code block is valid or not:

animals:
    - Dog
    - Cat
    - Bird

Also, many editors have the ability to automatically replace a tab with a space. For example, in Notepad++ turn on 'Replace by space' in Settings -> Preferences -> Language.

  1. Case-Sensitive

While some languages—like PHP and MySQL—are case insensitive, YAML is not, so the following structure is considered valid:

key: "value 1"
Key: "value 2"
KEY: "value 3"

Summary

Congratulations! You have completed the basic composite template development lifecycle.

To continue with the next step in the tutorial project, type the following command:

[user@linuxbox tutorial]$ git checkout stage-01 -f
Switched to branch 'stage-01'