Strange thing with Jinja2 expressions evaluation

62 views
Skip to first unread message

Andrew Pashkin

unread,
Sep 12, 2014, 10:07:52 AM9/12/14
to ansible...@googlegroups.com
With this playbook:
- name: test playbook
  hosts: 127.0.0.1
  connection: local
  gather_facts: no
  tasks:
    - debug: msg="{{ 'ansible'|replace('a', 'b') }}"
Output will be:
"bnsible"
But with this:

- name: test playbook
  hosts: 127.0.0.1
  connection: local
  gather_facts: no
  tasks:
    - debug: msg="{{ 'ansible'|regex_replace('a', 'b') }}"

Output will be:
"{{'ansible'|regex_replace('a', 'b')}}"

Why in the last example expression is not evaluated?

ps
I use Ansible 1.5.4




-- 
With kind regards, Andrew Pashkin.
cell phone - +7 (985) 898 57 59
Skype - waves_in_fluids
e-mail - andrew....@gmx.co.uk

Michael Peters

unread,
Sep 12, 2014, 10:13:00 AM9/12/14
to ansible...@googlegroups.com
That's a pretty old version of ansible. I suspect that the
regex_replace filter didn't exist then. You should definitely upgrade
since it works on 1.7.1.
> --
> 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/5412FE30.1060308%40gmx.co.uk.
> For more options, visit https://groups.google.com/d/optout.

Michael DeHaan

unread,
Sep 12, 2014, 11:37:31 AM9/12/14
to ansible...@googlegroups.com
Yep yep.

(You're also missing some security upgrades, so I would strongly recommend using 1.7.1 even if you don't need this)

We try to note in the docs every time there's a feature added in a specific version, but I see we didn't do that for regex_replace, so I'll add the note about it.

Thanks very much for the report!



Andrew Pashkin

unread,
Sep 13, 2014, 6:35:50 AM9/13/14
to ansible...@googlegroups.com
Yes indeed, I forgot to add Ansible PPA. Thanks!

For more options, visit https://groups.google.com/d/optout.

-- 
With kind regards, Andrew Pashkin.
cell phone - +7 (985) 898 57 59
Reply all
Reply to author
Forward
0 new messages