1 ##############################################################################
2 # Copyright (c) 2016 Ericsson AB and others.
3 # peter.barabas@ericsson.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 ======== TEMPLATING SUPPORT IN YAML CONFIGURATION FILES ========
12 deploy/templater.py makes it possible to use templates to generate configuration
13 files. It takes 2 input YAML files and an output file as arguments. One being
14 the dictionary (called the base file), which is used to look up values in; the
15 other file is the template, where the substitution will take place. Templater
16 will write the result to an output file, specified as the 3rd argument.
19 ======== SYNTAX OF TEMPLATE FILES ========
21 A template file can contain any valid YAML data and template variables, whose
22 syntax is described below:
24 1. Single value references
28 %{environment/net_segment_type}
30 Either a root element, or a path can be specified.
36 %{network/networking_parameters}
38 Either a root element, or a path can be specified.
40 3. Interface lookup for network
44 Specify a network type as argument to interface().
46 4. Interface lookup for network and role
48 %{interface(public,compute)}
50 Specify a network type and a role as arguments to interface().
54 %{include(templates/interfaces.yaml)}
56 Filename with absolute or relative path.
59 ======== EXAMPLES ========
61 Base YAML file (excerpt):
63 title: Deployment Environment Adapter (DEA)
65 created: Wed Mar 30 08:16:04 2016
69 wanted_release: Liberty on Ubuntu 14.04
72 interfaces: interfaces_1
73 role: ceph-osd,compute
74 transformations: transformations_1
76 interfaces: interfaces_1
77 role: ceph-osd,compute
78 transformations: transformations_1
80 interfaces: interfaces_1
81 role: ceph-osd,compute
82 transformations: transformations_1
84 interfaces: interfaces_2
85 role: controller,mongo
86 transformations: transformations_2
88 interfaces: interfaces_2
89 role: controller,mongo
90 transformations: transformations_2
92 interfaces: interfaces_2
93 role: controller,mongo
94 transformations: transformations_2
115 - cidr: 172.16.0.0/24
123 floating_range_var: floating_ranges
130 render_addr_mask: public
139 - cidr: 192.168.1.0/24
150 render_addr_mask: storage
162 deployment-scenario-metadata:
167 net_segment_type: %{environment/net_segment_type}
174 deployment-scenario-metadata:
175 title: Deployment Environment Adapter (DEA)
179 net_segment_type: tun
182 interfaces: interfaces_1
183 role: ceph-osd,compute
184 transformations: transformations_1
186 interfaces: interfaces_1
187 role: ceph-osd,compute
188 transformations: transformations_1
190 interfaces: interfaces_1
191 role: ceph-osd,compute
192 transformations: transformations_1
194 interfaces: interfaces_2
195 role: controller,mongo
196 transformations: transformations_2
198 interfaces: interfaces_2
199 role: controller,mongo
200 transformations: transformations_2
202 interfaces: interfaces_2
203 role: controller,mongo
204 transformations: transformations_2
222 - cidr: 172.16.0.0/24
230 floating_range_var: floating_ranges
237 render_addr_mask: public
246 - cidr: 192.168.1.0/24
257 render_addr_mask: storage
269 storage_if: %{interface(storage)}
270 compute_private_if: %{interface(private,compute)}
271 # Management interface of a mongo node
272 mongo_mgmt_if: %{interface(management,mongo)}
273 controller_private_if: %{interface(private,controller)}
279 compute_private_if: ens5
280 # Management interface of a mongo node
282 controller_private_if: ens4
290 created: Mon Jun 13 19:39:35 2016
292 %{include(environment.yaml)}
298 name: F9-NOSDN-NOFEATURE-VXLAN-BAREMETAL
299 net_segment_type: tun
305 created: Mon Jun 13 19:39:35 2016
308 name: F9-NOSDN-NOFEATURE-VXLAN-BAREMETAL
309 net_segment_type: tun
314 Template file (except):
320 description: Email address for Administrator
326 value: admin@localhost
329 # lines omitted for brevity
330 %{include(templates/cgroups.yaml)}
337 always_editable: true
339 label: Cgroups conguration for services
352 description: Email address for Administrator
358 value: admin@localhost
361 # again, lines omitted for brevity
364 always_editable: true
366 label: Cgroups conguration for services