error in templating jinja replace "." with nothing

15 views
Skip to first unread message

Meher Garda

unread,
Mar 27, 2016, 12:49:05 AM3/27/16
to Ansible Project
In my default folder , main.yml I have the following

percona_version: 5.6
percona_pckg_version: "{% {{percona_version}}|replace('.', '') %}"     # want to remove the period in 5.6 so as to get 56

The above gives error while running playbook

fatal: [x.x.x.x] => Failed to template {{percona_pckg_version}}: Failed to template {% percona_version|replace('.', '') %}: template error while templating string: Encountered unknown tag 'percona_version'.


Any ideas?

Matt Martz

unread,
Mar 27, 2016, 12:19:02 PM3/27/16
to ansible...@googlegroups.com
What you want is something like:

percona_pckg_version: "{{ percona_version|replace('.', '') }}"

You might want to read up on jinja2 a little at http://jinja.pocoo.org/docs/dev/templates/

{% %} are used for control structures such as `for` and `if`, where as {{ }} are used to denote "expressions to print"

--
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/7a37a87f-5cd1-4d53-947b-70f5731c3ddd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages