Skip to content

Commit

Permalink
doc: add example query commands to debug Jinja templates (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
blackboxsw committed Nov 2, 2020
1 parent f8c84ae commit 8642e8b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions doc/rtd/topics/instancedata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8642e8b

Please sign in to comment.