-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexamples.yaml
More file actions
299 lines (270 loc) · 7.87 KB
/
examples.yaml
File metadata and controls
299 lines (270 loc) · 7.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
Hello:
template: "Hello {{ name }}!"
data: "name: Urs"
"Nice words":
data: |
name: Urs
pickups_lines:
- Well, here I am. What are your other two wishes?
- Are you from Tennessee? Because you're the only 10 I see!
- I wish I were cross-eyed so I can see you twice.
- I’m learning about important dates in history. Wanna be one of them?
- Do you like Star Wars? Because Yoda only one for me!
template: |
Hi {{ name}}
{{ pickups_lines | random }}
"MacDonald Farm":
data: |
animals:
cow: moo
pig: oink
duck: quack
template: |
{% for animal, sound in animals.items() %}
Old MacDonald had a farm, E I E I O,
And on his farm he had a {{animal}}, E I E I O.
With a {{sound}} {{sound}} here and a {{sound}} {{sound}} there,
Here a {{sound}}, there a {{sound}}, everywhere a {{sound}} {{sound}}.
Old MacDonald had a farm, E I E I O.
{% endfor %}
Interface:
template: |
{% for interface in interfaces %}
interface {{ interface.name }}
ip address {{ interface.addr }} {{ interface.mask}}
{% endfor %}
data: |
interfaces:
- name: Loopback0
addr: 10.10.10.10
mask: 255.255.255.255
- name: Ethernet0/1
addr: 192.168.1.1
mask: 255.255.255.0
"Linux bond0":
data: |
interfaces:
- eno1
- eno2
ip: 192.168.1.10/24
gw: 192.168.1.1
dns:
- 1.1.1.1
- 8.8.8.8
template: |
network:
version: 2
renderer: networkd
bonds:
bond0:
interfaces: {{interfaces}}
addresses: [{{ip}}]
gateway4: {{gw}}
parameters:
mode: 802.3ad
nameservers:
search: [subdomain.example.com]
addresses: {{dns}}
dhcp4: false
optional: true
SegmentRouting:
data: |
id: 3
interfaces:
# interface number and
# the connected neighbor ID
0: 16
1: 18
services:
- name: cust1
number: 1
- name: cust2
number: 2
bgp:
neighbors:
- 1
- 2
template: |
{# This example is not a perfect template. It's for demonstration #}
hostname R{{ "%02d"|format(id)}}
!
!
address-family ipv4 unicast
!
cdp
!
{% set lo0v4 = "{0}.{0}.{0}.{0}".format(id) %}
interface Loopback0
ipv4 address {{lo0v4}} 255.255.255.255
ipv6 address 3001::{{id}}:{{id}}:{{id}}:{{id}}/128
!
{% for i, n in interfaces.items() %}
{% set sorted_id = [n, id] | sort %}
interface GigabitEthernet0/0/0/{{ i }}
description to_R{{ "%02d"|format(n) }}
ipv6 address 3001::10:{{ sorted_id[0] }}:{{ sorted_id[1] }}:{{id}}/112
no shutdown
cdp
!
{% endfor %}
!
router isis 1
is-type level-2-only
net 47.0000.0000.00{{ "%02d"|format(id) }}.00
address-family ipv6 unicast
metric-style wide
!
!
interface Loopback0
address-family ipv6 unicast
!
!
{% for i, n in interfaces.items() %}
interface GigabitEthernet0/0/0/{{ i }}
point-to-point
address-family ipv6 unicast
fast-reroute per-prefix
fast-reroute per-prefix ti-lfa
!
!
{% endfor %}
!
{% for s in services %}
vrf vrf_{{ s['name'] }}
rd 65100:{{ s['number'] }}
address-family ipv4 unicast
import route-target
65100:{{ s['number'] }}
!
export route-target
65100:{{ s['number'] }}
!
!
!
{% endfor %}
{% for s in services %}
interface Loopback{{ 100 + s['number'] }}
vrf vrf_{{ s['name'] }}
ipv4 address {{ s['number'] % 255 }}.0.0.{{ id }} 255.255.255.255
!
{% endfor %}
!
router isis 1
address-family ipv6 unicast
segment-routing srv6
locator R{{"%02d"|format(id)}}
!
!
!
{% if bgp is defined %}
router bgp 65100
bgp router-id {{lo0v4}}
address-family ipv4 unicast
!
address-family vpnv4 unicast
segment-routing srv6
locator R{{"%02d"|format(id)}}
!
!
{% for nid in bgp.neighbors %}
neighbor 3001::{{nid}}:{{nid}}:{{nid}}:{{nid}}
remote-as 65100
update-source Loopback0
address-family vpnv4 unicast
soft-reconfiguration inbound always
!
{% endfor %}
!
{% for s in services %}
vrf vrf_{{ s['name'] }}
rd 65100:{{ s['number'] }}
address-family ipv4 unicast
segment-routing srv6
alloc mode per-vrf
!
redistribute connected
!
!
{% endfor %}
!
segment-routing
srv6
encapsulation
source-address 3001::{{id}}:{{id}}:{{id}}:{{id}}
!
locators
locator R{{"%02d"|format(id)}}
prefix cafe:0:0:{{id}}::/64
!
!
!
!
{% endif %}
Ansible Filter:
data: |
my_list1: [3, [4, 2] ]
my_list2: [3, 2, 5]
files:
users: /etc/passwd
groups: /etc/group
ip_net: 172.16.0.0/16
text: Ansible
template: |
{#- Ansible filter demo.
Select Ansible in the environment settings -#}
{{ my_list1 | flatten }}
{{ my_list1 | flatten | symmetric_difference(my_list2) }}
{{ files | dict2items(key_name='file', value_name='path') | to_nice_yaml }}
{{ '52:54:00' | community.general.random_mac }}
{% for i in range(10, 20) %}
{{ ip_net | ansible.utils.ipaddr(i) }}{% endfor %}
{{ text | hash('sha1') }}
{{ text | hash('md5') }}
{{ text | password_hash('sha512') }}
Salt Filter:
data: |
test:
a: b
c: [1, 2, 3, 0]
my_text: yes, this is a TEST
template: |
{{ "2021/10/31"|strftime("%y") }}
{{ "tomorrow"|strftime }}
{{ test.c[0] | to_bool }}
{{ test.c | exactly_n_true(3) }}
{{ 'abcdefabcdef' | regex_search('BC(.*)', ignorecase=True) }}
{{ my_text | regex_replace(' ([a-z])', '__\\1', ignorecase=True) }}
{{ 'random' | uuid }}
{{ test.c | is_list }}
{{ test.c | is_iter }}
{{ test.c | min }}
{{ test.c | max }}
{{ test.c | avg }}
{{ test.c | union([4, 5, 6]) }}
{{ test.c | intersect([1, 2, 4]) }}
{{ test.c | symmetric_difference([2, 3, 4]) }}
{{ '0xabcd' | is_hex }}
{{ 'xyzt' | is_hex }}
{{ 'abcd' | contains_whitespace }}
{{ 'ab cd' | contains_whitespace }}
{{ 5 | check_whitelist_blacklist(whitelist=[5, 6, 7]) }}
{{ 5 | check_whitelist_blacklist(blacklist=[5, 6, 7]) }}
{{ 'wall of text' | to_bytes }}
md5: {{ 'random' | md5 }}
sha256:{{ 'random' | sha256 }}
sha512:{{ 'random' | sha512 }}
{{ "camelsWillLoveThis" | to_snake_case }}
{{ "snake_case_for_the_win" | to_camelcase }}
{{ '192.168.0.1' | is_ip }}
{{ '192.168.0.1' | is_ipv4 }}
{{ 'fe80::' | is_ipv6 }}
{{ '192.168.0.1/30' | network_hosts }}
{{ '00:50' | gen_mac }}
{{ 'random' | base64_encode | base64_decode }}
ST2 Filter:
data: |
input: {'a': {'b': {'c': 1234} } }
template: |
# input = {'a': {'b': {'c': 1234} } }
# result = [1234]
{{ input | jsonpath_query('a.b.c') }}