Create a composite StyleBook
Build your StyleBook
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"
import-stylebooks:
-
namespace: netscaler.nitro.config
version: "10.5"
prefix: ns
-
namespace: com.example.stylebooks
version: "0.1"
prefix: stlb
parameters:
-
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: response-code
type: string[]
label: List of Response Codes
description: List of Response Codes - Provide a list of response codes in integer.
components:
-
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.
properties:
name: $parameters.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.
properties:
monitorname: $parameters.name + "-mon"
type: HTTP
respcode: $parameters.response-code
httprequest: "'GET /'"
lrtm: ENABLED
secure: "YES"
components:
-
name: monit-svcgrp-bind-comp
type: ns::servicegroup_lbmonitor_binding
properties:
servicegroupname: $components.basic-lb-comp.outputs.servicegroup-comp.properties.servicegroupname
monitor_name: $parent.properties.monitorname
stlb.
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.
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.