Add 'toyaml()' jinja2 function

Syntax is like for built-in 'indent' filter, but must be used as
function:

{{ toyaml(data, width=0, indentfirst=False) }}

Change-Id: I067062f03a77af20c40641056d2d5e15b2c0ef09
diff --git "a/examples/environment/\173\173 cookiecutter.cluster_name \175\175/init.yml" "b/examples/environment/\173\173 cookiecutter.cluster_name \175\175/init.yml"
index d1b5b7f..f7a1b70 100644
--- "a/examples/environment/\173\173 cookiecutter.cluster_name \175\175/init.yml"
+++ "b/examples/environment/\173\173 cookiecutter.cluster_name \175\175/init.yml"
@@ -15,7 +15,8 @@
             # For example, you can take the 'inventory_node_name' and find it's config
             # in an additional dict inventory[inventory_node_name] loaded from custom_inventory.yaml,
             # or skip the original context from 'cookiecutter' object and iterate only custom inventory.
-            linux_network_interfaces: {{ node['parameters']['linux']['network']['interface'] }}
+            linux_network_interfaces:
+              {{ toyaml( node['parameters']['linux']['network']['interface'], width=14 ) }}
 {%- endif %}
           classes:
           - environment.{{ cookiecutter.cluster_name }}.networking
diff --git a/reclass_tools/create_inventory.py b/reclass_tools/create_inventory.py
index 9b03632..f08fafe 100644
--- a/reclass_tools/create_inventory.py
+++ b/reclass_tools/create_inventory.py
@@ -90,10 +90,19 @@
                           Merge of the files usind update() into a single
                           dict is in the same order as files in the list.
     """
+    def toyaml(value, width=0, indentfirst=False):
+        string = yaml.dump(value, default_flow_style=False)
+        if string.splitlines():
+            return (
+                ' ' * width * indentfirst +
+                ('\n' + ' ' * width).join(string.splitlines()) + '\n')
+        else:
+            return ''
 
     overwrite_if_exists = True
 
     merged_context = {}
+
     for fcon in contexts:
         if fcon.endswith('.yaml'):
             context = helpers.yaml_read(fcon)
@@ -104,6 +113,8 @@
 
         merged_context = helpers.merge_nested_objects(merged_context, context)
 
+    merged_context['toyaml'] = toyaml
+
     try:
         generate.generate_files(
             repo_dir=template_dir,