Quantcast
Channel: User Michael Mol - DevOps Stack Exchange
Viewing all articles
Browse latest Browse all 14

Answer by Michael Mol for How to examine Jinja output in Saltstack?

$
0
0

Given how much time I spent weeks ago struggling with a closely-related issue, I wish I'd figured this out sooner.

The solution appears to be to use salt.modules.cp.get_template to have the Salt minion retrieve the file, render it through the templating engine and place it in a readable place:

# salt my-minion-id cp.get_template salt://network/init.sls /root/network.sls template=jinjamy-minion-id:    /root/network.sls

From there, you connect to the my-minion-id host and examine the file you placed at /root/network.sls.

This makes sense; salt.renderers.jinja is in the salt.renderers namespace, while the modules you have access to from the CLI are in the salt.modules namespace.

It also makes sense from a data visibility standpoint; template rendering happens on the minion, where grains and such are available, and I've yet to see a module that executes minion code return arbitrary output to the master (for view on the CLI, for example); the returned data is invariably well-structured and concise. (There may be such a module, but I don't know what it is. It would be a preferable solution to dropping test files onto a minion.)

edit: @gtmanfred's answer is far better and more direct, and I've accepted that one. I'm leaving this one here for informative purposes. It's not the best solution, but it does still work.


Viewing all articles
Browse latest Browse all 14

Trending Articles