jinja2 for setting module parameters

31 views
Skip to first unread message

Xu Chen

unread,
Aug 27, 2014, 12:01:30 PM8/27/14
to ansible...@googlegroups.com
I have difficulty using jinja2 combined with cron module in the following way:

- cron: name=test job="abc {{ data | filter_x('a') | filter_y('b') }} edf"

I tried various combinations, but either the jinja2 template isn't expanded, or I am seeing errors parsing. 

Any ideas how to make something like this work? Thanks.

Michael DeHaan

unread,
Aug 27, 2014, 3:03:28 PM8/27/14
to ansible...@googlegroups.com
I assume filter_x and filter_y are plugins you wrote?




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e90cdfa3-8681-4436-b0ef-45eeb5a6c4eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Xu Chen

unread,
Aug 27, 2014, 3:44:37 PM8/27/14
to ansible...@googlegroups.com
Yes, I wrote some additional plugins and put them in ansible/lib/runner/filter_plugins/core.py

Thanks.

Michael DeHaan

unread,
Aug 27, 2014, 4:11:17 PM8/27/14
to ansible...@googlegroups.com
Hard to say what you error is without seeing the plugin.

Perhaps you could paste it?


Xu Chen

unread,
Aug 30, 2014, 12:23:39 AM8/30/14
to ansible...@googlegroups.com
Ah, thanks for the hint...

I wrote a new filter function but didn't register it in the end. Is there a way to make such errors more obvious? Like fail the execution and tell me jinja2 template expansion failed - currently the unexpanded template is directly used as the output..

Thanks.
-Simon

Michael DeHaan

unread,
Sep 2, 2014, 7:02:55 PM9/2/14
to ansible...@googlegroups.com
Using a filter that doesn't exist should generate an error, that I would definitely like a bug report on if you are not seeing that behavior in 1.7.X.

Thanks!


Reply all
Reply to author
Forward
0 new messages