syntax checking sls and jinja templates

1,594 views
Skip to first unread message

Alex Leonhardt

unread,
Jun 22, 2014, 7:56:43 AM6/22/14
to salt-...@googlegroups.com
Hiya,

as am starting to get the hang of salt a little, I'm wondering how to do basic syntax checking for sls formulas and jinja templates ? I mainly use VIM as editor and already have some plugins I use - but, e.g. if I have a missing ")" .. i'd like vim to do a quick syntax check to validate whether the sls formula would be successfully parsed ? Has anyone suggestions or methods (vim plugins??) they already use ? 

Thanks
Alex

Colton Myers

unread,
Jun 27, 2014, 7:06:26 PM6/27/14
to salt-...@googlegroups.com
It looks like syntastic (https://github.com/scrooloose/syntastic) does have support for checking YAML, but I doubt it will play well with jinja templating.  Though I think you can probably find a plugin that at least highlights non-matched parens and other inconsistencies, but I'm not sure of one off the top of my head.

--
Colton Myers


--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Leonhardt

unread,
Jun 28, 2014, 1:50:12 PM6/28/14
to salt-...@googlegroups.com
Ah, no i meant it more like a "salt parser salt-formula/" - it'd try to parse the module and ensure that when salt runs on a client it'd work - is there something similar ? 

Alex

viq

unread,
Jun 28, 2014, 6:31:55 PM6/28/14
to salt-...@googlegroups.com
On Sat, Jun 28, 2014 at 7:50 PM, Alex Leonhardt <aleonh...@gmail.com> wrote:
> Ah, no i meant it more like a "salt parser salt-formula/" - it'd try to
> parse the module and ensure that when salt runs on a client it'd work - is
> there something similar ?

https://github.com/simonmcc/kitchen-salt ?
--
viq

Jean-Michel Smith

unread,
Jun 30, 2014, 10:31:01 AM6/30/14
to salt-...@googlegroups.com
I run the following command on all my states (but this requires a test minion node, and root access, with various environments/pillars/etc defined).  Ideally you'd crate a vm and run this for every common iteration of pillar/grain environments that define which states get run and how.  Obviously that can grow geometrically, so this isn't perfect, but it is a pretty good start as far as testing syntax and making sure results are sensible.

# test sls file syntax by identifying files, then running state.show_sls.
for state in `salt-call cp.list_states | awk '{print $2}' | grep -v '^top#39;`; do
  salt-call --retcode-passthrough state.show_sls ${state}
done

Jean-Michel Smith

unread,
Jun 30, 2014, 10:33:20 AM6/30/14
to salt-...@googlegroups.com
sigh.  ignore the '#39', that should be another single quote instead.  I hate cut-and-paste on non-Linux boxes.

for state in `salt-call cp.list_states | awk '{print $2}' | grep -v '^top'`; do
[ ... ]

Colton Myers

unread,
Jul 11, 2014, 5:23:50 PM7/11/14
to salt-...@googlegroups.com
You might consider using something like `salt 'myminion' state.show_highstate` or `state.show_lowstate`, as those functions will compile the state run and you can inspect it to make sure everything came out correctly.

--
Colton Myers
Reply all
Reply to author
Forward
0 new messages