summaryrefslogtreecommitdiff
path: root/doc/rtd/topics/format.rst
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2018-09-11 17:31:46 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2018-09-11 17:31:46 +0000
commitc7555762f3a30190ce7726b4d013bc3e83c7e4b6 (patch)
tree9f35cd8af4c33dc36ff5ee53574d20854273a309 /doc/rtd/topics/format.rst
parent757247f9ff2df57e792e29d8656ac415364e914d (diff)
downloadvyos-cloud-init-c7555762f3a30190ce7726b4d013bc3e83c7e4b6.tar.gz
vyos-cloud-init-c7555762f3a30190ce7726b4d013bc3e83c7e4b6.zip
user-data: jinja template to render instance-data.json in cloud-config
Allow users to provide '## template: jinja' as the first line or their #cloud-config or custom script user-data parts. When this header exists, the cloud-config or script will be rendered as a jinja template. All instance metadata keys and values present in /run/cloud-init/instance-data.json will be available as jinja variables for the template. This means any cloud-config module or script can reference any standardized instance data in templates and scripts. Additionally, any standardized instance-data.json keys scoped below a '<v#>' key will be promoted as a top-level key for ease of reference in templates. This means that '{{ local_hostname }}' is the same as using the latest '{{ v#.local_hostname }}'. Since instance-data is written to /run/cloud-init/instance-data.json, make sure it is persisted across reboots when the cached datasource opject is reloaded. LP: #1791781
Diffstat (limited to 'doc/rtd/topics/format.rst')
-rw-r--r--doc/rtd/topics/format.rst21
1 files changed, 17 insertions, 4 deletions
diff --git a/doc/rtd/topics/format.rst b/doc/rtd/topics/format.rst
index 1b0ff366..15234d21 100644
--- a/doc/rtd/topics/format.rst
+++ b/doc/rtd/topics/format.rst
@@ -1,6 +1,8 @@
-*******
-Formats
-*******
+.. _user_data_formats:
+
+*****************
+User-Data Formats
+*****************
User data that will be acted upon by cloud-init must be in one of the following types.
@@ -65,6 +67,11 @@ Typically used by those who just want to execute a shell script.
Begins with: ``#!`` or ``Content-Type: text/x-shellscript`` when using a MIME archive.
+.. note::
+ New in cloud-init v. 18.4: User-data scripts can also render cloud instance
+ metadata variables using jinja templating. See
+ :ref:`instance_metadata` for more information.
+
Example
-------
@@ -103,12 +110,18 @@ These things include:
- certain ssh keys should be imported
- *and many more...*
-**Note:** The file must be valid yaml syntax.
+.. note::
+ This file must be valid yaml syntax.
See the :ref:`yaml_examples` section for a commented set of examples of supported cloud config formats.
Begins with: ``#cloud-config`` or ``Content-Type: text/cloud-config`` when using a MIME archive.
+.. note::
+ New in cloud-init v. 18.4: Cloud config dta can also render cloud instance
+ metadata variables using jinja templating. See
+ :ref:`instance_metadata` for more information.
+
Upstart Job
===========