blob: 59fc3b89c962700430d854f06c0f95e02bc5b332 (
plain)
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
|
.. -*- mode: rst -*-
=========================
Basic Jinja2 Templates
=========================
This simple example demonstrates basic usage of Jinja2 templates.
``/var/lib/bcfg2/Cfg/foo/foo.jinja2``
.. code-block:: none
Hostname is {{ metadata.hostname }}
Filename is {{ path }}
Template is {{ source_path }}
Groups:
{% for group in metadata.groups -%}
* {{ group }}
{% endfor %}
Categories:
{% for category in metadata.categories -%}
* {{ category }} -- {{ metadata.categories[category] }}
{% endfor %}
Probes:
{% for probe in metadata.Probes -%}
* {{ probe }} -- {{ metadata.Probes[probe] }}
{% endfor %}
Output
======
.. code-block:: xml
<Path type="file" name="/foo" owner="root" mode="0644" group="root">
Hostname is topaz.mcs.anl.gov
Filename is /foo
Template is /var/lib/bcfg2/Cfg/foo/foo.jinja2
Groups:
* desktop
* mcs-base
* ypbound
* workstation
* xserver
* debian-sarge
* debian
* a
Categories:
* test -- a
Probes:
* os -- debian
</Path>
|