Product Documentation

Create a composite StyleBook

May 24, 2018

An important and powerful feature of StyleBooks is that they can be used as building blocks for other StyleBooks. A StyleBook can be imported into another StyleBook and it can be referred to as a type that is used by components of the second StyleBook similar to a Nitro built-in StyleBook.

For example, you can use the basic-lb-config StyleBook that you built in the previous section, to build another StyleBook called composite-example. To use the "basic-lb-config" StyleBook, you have to import it in the new StyleBook in the import-stylebooks section.

The new StyleBook would look as follows:

composite-example.yaml Copy

name: composite-example

namespace: com.example.stylebooks

version: "0.1"

display-name: Load Balancing Virtual Server (HTTP/RoundRobin)

description: This StyleBook defines a RoundRobin load balancing configuration with a monitor.

schema-version: "1.0"



    namespace: netscaler.nitro.config

    version: "10.5"

    prefix: ns


    namespace: com.example.stylebooks

    version: "0.1"

    prefix: stlb



    name: name

    type: string

    label: Application Name

    description: Give a name to the application configuration.

    required: true


    name: ip

    type: ipaddress

    label: Application Virtual IP (VIP)

    description: The Application VIP that clients access

    required: true


    name: svc-servers

    type: ipaddress[]

    label: Application Server IPs

    description: The IP addresses of all the servers of this application

    required: true



    name: basic-lb-comp

    type: stlb::basic-lb-config

    description: This component's type is another StyleBook that builds the NetScaler lbvserver, servicegroups and services configuration objects.


      name: $

      ip: $parameters.ip

      svc-servers: $parameters.svc-servers


    name: monit-comp

    type: ns::lbmonitor

    description: This component is a basic Nitro type (a Builtin StyleBook) that builds the NetScaler monitor configuration object.


      monitorname: $ + "-mon"

      type: HTTP


      httprequest: "'GET /'"

      lrtm: ENABLED

      secure: "YES"



        name: monit-svcgrp-bind-comp

        type: ns::servicegroup_lbmonitor_binding


          servicegroupname: $

          monitor_name: $

In the import-stylebooks section, you import the basic-lb-config StyleBook by using its namespace and version, referred to with the prefix "stlb".

In the components section, two components are defined. The first component is of type stlb::basic-lb-config, where "basic-lb-config" is the name of the StyleBook you created in StyleBook to create a basic load balancing configuration. The properties that are defined for this component correspond to the mandatory parameters declared in the basic-lb-config StyleBook. You can, however, use any parameter of the StyleBook (both required and optional.) Instead of re-building a lbvserver, a service group, and service and service group bindings, you import the StyleBook that does all of this as a component and use it to create these configuration objects in the new StyleBook.

StyleBook adds a second component "monit-comp" that uses the attributes of the Nitro resource “lbmonitor” (a built-in StyleBook) to create a monitor configuration object. It also has a sub-component "monit-svcgrp-bind-comp" to create the binding configuration object that binds the monitor to the servicegroup created in the first component. Because the servicegroup component created in the "basic-lb-config" StyleBook is exposed as an output, this StyleBook can access it using the expression $components.basic-lb-comp.outputs.servicegroup-comp. This is an example of how the outputs section can be used by the importing StyleBooks to have access to components in the imported StyleBooks that they would not have been able to access otherwise.

Next, copy and paste the StyleBook content to a text editor, and then save the file as composite-example.yaml. Run the contents of your StyleBook through the online tool to validate the YAML syntax. Then, import it to NetScaler MAS and create one or several configurations by using this StyleBook.