Jinja2 template directives

84 views
Skip to first unread message

Henry Finucane

unread,
Jul 2, 2014, 8:15:41 PM7/2/14
to ansible...@googlegroups.com
Howdy,
One of the changes to 1.6.6 dropped support for jinja2 template
directives: https://github.com/ansible/ansible/commit/3761bc113295e20771544491d007f1d328f40b99

I'd been leaning on that pretty heavily to convert a project to
Ansible, and I'm not really looking forward to auditing a couple
hundred templates. Is there a different way to disable trim_blocks?

Cheers,

--
-----------------------
| Henry Finucane
| "I hear aphorisms are popular"
-----------------------

Michael DeHaan

unread,
Jul 2, 2014, 8:18:05 PM7/2/14
to ansible...@googlegroups.com
Yes, they did, and this was unfortunate.

This was a fix to prevent nodes from returning facts that contain Jinja2 expressions (which long story short could result in some hijinx), and because the filter choices are made in the template here, we had to remove the feature for allowing the block delimiters like {{ and {% to be changed in order to reliably filter these out.

Now, I think what we should probably do (it would have to be on the devel branch) is make this option *ONLY* be able to set trim_blocks (and maybe another whitelist of certain options).

Is this something you might like to take a crack at?

trim_blocks themselves was never a problem.





--
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/CAGYSzJ_RqfQFQhVDecPUXVmpEOSHTLorsXtbRRakSmKBPT3ZEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Brian Coca

unread,
Jul 2, 2014, 8:30:18 PM7/2/14
to ansible...@googlegroups.com
The end/start block functionality is very useful, I'm thinking it could be made 'safe' by 're cleaning' the data if they get changed on override. I have the patch 1/2 done in my head, I should be able to tackle it this weekend if this approach is acceptable.

Michael DeHaan

unread,
Jul 2, 2014, 9:03:17 PM7/2/14
to ansible...@googlegroups.com
Would totally be open to looking at it...


On Wed, Jul 2, 2014 at 8:30 PM, Brian Coca <bria...@gmail.com> wrote:
The end/start block functionality is very useful, I'm thinking it could be made 'safe' by 're cleaning' the data if they get changed on override. I have the patch 1/2 done in my head, I should be able to tackle it this weekend if this approach is acceptable.

--
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.

Henry Finucane

unread,
Jul 3, 2014, 12:27:34 AM7/3/14
to ansible...@googlegroups.com
On Wednesday, July 2, 2014 5:18:05 PM UTC-7, Michael DeHaan wrote:
Yes, they did, and this was unfortunate.

This was a fix to prevent nodes from returning facts that contain Jinja2 expressions (which long story short could result in some hijinx), and because the filter choices are made in the template here, we had to remove the feature for allowing the block delimiters like {{ and {% to be changed in order to reliably filter these out.

Now, I think what we should probably do (it would have to be on the devel branch) is make this option *ONLY* be able to set trim_blocks (and maybe another whitelist of certain options).

Is this something you might like to take a crack at?

 
It doesn't raise an error for settings Ansible no longer supports, primarily because I couldn't figure out the plumbing. But it is a whitelist, and it does work, so there's that.

Michael DeHaan

unread,
Jul 3, 2014, 8:31:36 AM7/3/14
to ansible...@googlegroups.com
I've merged this now on devel for people that need this feature.   We're open to expanding the whitelist if needed, and will also see what Brian comes up with in terms of upgrades.

Thanks!




--
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.
Reply all
Reply to author
Forward
0 new messages