Inline Expansion
A place for everything, and everything has it's place.
Thus far the examples have all used references by naming the referred resource. It is also possible to define the content of a resource directly inside the referrer. This is called inline referential expansion and is useful when declaring resources that are entirely encapsulated by a resource. The following example for a virtual machine shows how inline expansion can be used to declare disks and nics within a vm (not a complete blueprint):
compute:
vm:
example:
admin_password: (( admin_password ))
admin_username: adminuser
cores: 2
disks:
data: # inline "data" disk definition
size: 256 GB
log: # inline "log" disk definition
size: 64 GB
type: hdd
memory: 4 GB
nics:
external: # inline "external" nic definition
firewall: example-firewall
ips:
- private:
type: dynamic
public:
type: static
subnet: example-public
internal: # inline "internal" nic definition
ips:
- private:
ip: 10.0.100.4
type: static
subnet: example-backend
tags:
wicked: cool
The property definitions for disks
and nics
are references, however in this case instead of declaring the disks and nics at the top level of the blueprint and then adding their blueprint name, we can define them directly inside the virtual machine using them.
The order in which the disks and nics are defined in this example determines the order in which they are presented to the consuming resource. All blueprints respect the order of definition.
Inline definitions cannot use the count
property to expand. We're working on it...
The inline definitions get expanded by the blueprint loader into their canonical form (and applying autonaming rules), and a classic reference with a fully qualified blueprint path is left behind to connect the resources:
Blueprint Path
Becomes
compute.vm.example.disks.data
storage.disk.example-data
compute.vm.example.disks.log
storage.disk.example-log
compute.vm.example.nics.external
compute.nic.example-external
compute.vm.example.nics.internal
compute.nic.example-internal
Last updated
Was this helpful?