Merge "Fix default value for plugin metadata"
[fuel.git] / deploy / README.templater
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 ##############################################################################
9
10 ======== TEMPLATING SUPPORT IN YAML CONFIGURATION FILES ========
11
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.
17
18
19 ======== SYNTAX OF TEMPLATE FILES ========
20
21 A template file can contain any valid YAML data and template variables, whose
22 syntax is described below:
23
24 1. Single value references
25
26    %{title}
27
28    %{environment/net_segment_type}
29
30    Either a root element, or a path can be specified.
31
32 2. YAML sections
33
34    %{nodes}
35
36    %{network/networking_parameters}
37
38    Either a root element, or a path can be specified.
39
40 3. Interface lookup for network
41
42    %{interface(storage)}
43
44    Specify a network type as argument to interface().
45
46 4. Interface lookup for network and role
47
48    %{interface(public,compute)}
49
50    Specify a network type and a role as arguments to interface().
51
52
53 ======== EXAMPLES ========
54
55 Base YAML file (excerpt):
56
57 title: Deployment Environment Adapter (DEA)
58 version: 1.1
59 created: Wed Mar 30 08:16:04 2016
60 environment:
61   name: vCity
62   net_segment_type: tun
63 wanted_release: Liberty on Ubuntu 14.04
64 nodes:
65 - id: 1
66   interfaces: interfaces_1
67   role: ceph-osd,compute
68   transformations: transformations_1
69 - id: 2
70   interfaces: interfaces_1
71   role: ceph-osd,compute
72   transformations: transformations_1
73 - id: 3
74   interfaces: interfaces_1
75   role: ceph-osd,compute
76   transformations: transformations_1
77 - id: 4
78   interfaces: interfaces_2
79   role: controller,mongo
80   transformations: transformations_2
81 - id: 5
82   interfaces: interfaces_2
83   role: controller,mongo
84   transformations: transformations_2
85 - id: 6
86   interfaces: interfaces_2
87   role: controller,mongo
88   transformations: transformations_2
89 interfaces_1:
90   ens3:
91   - fuelweb_admin
92   - management
93   ens4:
94   - storage
95   ens5:
96   - private
97   ens6:
98   - public
99 interfaces_2:
100   ens3:
101   - fuelweb_admin
102   - management
103   ens4:
104   - storage
105   - private
106   - public
107 network:
108   networks:
109   - cidr: 172.16.0.0/24
110     gateway: 172.16.0.1
111     ip_ranges:
112     - - 172.16.0.2
113       - 172.16.0.126
114     meta:
115       cidr: 172.16.0.0/24
116       configurable: true
117       floating_range_var: floating_ranges
118       ip_range:
119       - 172.16.0.2
120       - 172.16.0.126
121       map_priority: 1
122       name: public
123       notation: ip_ranges
124       render_addr_mask: public
125       render_type: null
126       use_gateway: true
127       vips:
128       - haproxy
129       - vrouter
130       vlan_start: null
131     name: public
132     vlan_start: null
133   - cidr: 192.168.1.0/24
134     gateway: null
135     ip_ranges:
136     - - 192.168.1.1
137       - 192.168.1.254
138     meta:
139       cidr: 192.168.1.0/24
140       configurable: true
141       map_priority: 2
142       name: storage
143       notation: cidr
144       render_addr_mask: storage
145       render_type: cidr
146       use_gateway: false
147       vlan_start: 102
148     name: storage
149     vlan_start: 102
150
151
152 --- Example 1 ---
153
154 Template file:
155
156 deployment-scenario-metadata:
157   title: %{title}
158   version: 0.1
159 dea-override-config:
160   environment:
161     net_segment_type: %{environment/net_segment_type}
162   nodes:
163   %{nodes}
164
165
166 Result:
167
168 deployment-scenario-metadata:
169   title: Deployment Environment Adapter (DEA)
170   version: 0.1
171 dea-override-config:
172   environment:
173     net_segment_type: tun
174   nodes:
175   - id: 1
176     interfaces: interfaces_1
177     role: ceph-osd,compute
178     transformations: transformations_1
179   - id: 2
180     interfaces: interfaces_1
181     role: ceph-osd,compute
182     transformations: transformations_1
183   - id: 3
184     interfaces: interfaces_1
185     role: ceph-osd,compute
186     transformations: transformations_1
187   - id: 4
188     interfaces: interfaces_2
189     role: controller,mongo
190     transformations: transformations_2
191   - id: 5
192     interfaces: interfaces_2
193     role: controller,mongo
194     transformations: transformations_2
195   - id: 6
196     interfaces: interfaces_2
197     role: controller,mongo
198     transformations: transformations_2
199
200
201 --- Example 2 ---
202
203 Template file:
204
205 dea-override-config:
206   network:
207     networks:
208     %{network/networks}
209
210
211 Result:
212
213 dea-override-config:
214   network:
215     networks:
216     - cidr: 172.16.0.0/24
217       gateway: 172.16.0.1
218       ip_ranges:
219       - - 172.16.0.2
220         - 172.16.0.126
221       meta:
222         cidr: 172.16.0.0/24
223         configurable: true
224         floating_range_var: floating_ranges
225         ip_range:
226         - 172.16.0.2
227         - 172.16.0.126
228         map_priority: 1
229         name: public
230         notation: ip_ranges
231         render_addr_mask: public
232         render_type: null
233         use_gateway: true
234         vips:
235         - haproxy
236         - vrouter
237         vlan_start: null
238       name: public
239       vlan_start: null
240     - cidr: 192.168.1.0/24
241       gateway: null
242       ip_ranges:
243       - - 192.168.1.1
244         - 192.168.1.254
245       meta:
246         cidr: 192.168.1.0/24
247         configurable: true
248         map_priority: 2
249         name: storage
250         notation: cidr
251         render_addr_mask: storage
252         render_type: cidr
253         use_gateway: false
254         vlan_start: 102
255       name: storage
256       vlan_start: 102
257
258
259 --- Example 3 ---
260
261 Template file:
262
263 storage_if: %{interface(storage)}
264 compute_private_if: %{interface(private,compute)}
265 # Management interface of a mongo node
266 mongo_mgmt_if: %{interface(management,mongo)}
267 controller_private_if: %{interface(private,controller)}
268
269
270 Result:
271
272 storage_if: ens4
273 compute_private_if: ens5
274 # Management interface of a mongo node
275 mongo_mgmt_if: ens3
276 controller_private_if: ens4
277