summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2020-11-02 07:20:30 -0700
committerGitHub <noreply@github.com>2020-11-02 09:20:30 -0500
commit8642e8bce3530d2deb6b02895c08edd291eea48f (patch)
treedb5ceddf8603ba530206c18ba695388bb1825d1f /doc
parentf8c84aeead77b7e508644d94889ee701f20e8d31 (diff)
downloadvyos-cloud-init-8642e8bce3530d2deb6b02895c08edd291eea48f.tar.gz
vyos-cloud-init-8642e8bce3530d2deb6b02895c08edd291eea48f.zip
doc: add example query commands to debug Jinja templates (#645)
Diffstat (limited to 'doc')
-rw-r--r--doc/rtd/topics/instancedata.rst16
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/rtd/topics/instancedata.rst b/doc/rtd/topics/instancedata.rst
index 255245a4..1850982c 100644
--- a/doc/rtd/topics/instancedata.rst
+++ b/doc/rtd/topics/instancedata.rst
@@ -592,6 +592,22 @@ see only redacted values.
% cloud-init query --format 'cloud: {{ v1.cloud_name }} myregion: {{
% v1.region }}'
+ # Locally test that your template userdata provided to the vm was rendered as
+ # intended.
+ % cloud-init query --format "$(sudo cloud-init query userdata)"
+
+ # The --format command renders jinja templates, this can also be used
+ # to develop and test jinja template constructs
+ % cat > test-templating.yaml <<EOF
+ {% for val in ds.meta_data.keys() %}
+ - {{ val }}
+ {% endfor %}
+ EOF
+ % cloud-init query --format="$( cat test-templating.yaml )"
+ - instance_id
+ - dsmode
+ - local_hostname
+
.. note::
To save time designing a user-data template for a specific cloud's
instance-data.json, use the 'render' cloud-init command on an