Single quotes inside Jinja2 string literals

723 views
Skip to first unread message

Christian Thiemann

unread,
Jan 27, 2016, 4:52:49 AM1/27/16
to Ansible Project
How can I include single quotes in single-quoted Jinja2 string literals in Ansible 2.0?

Minimal test case:

---
- hosts: localhost
  tasks
:
   
- debug: msg="{{ 'foo\'bar\'baz' }}"

Ansible 1.9.4:

ok: [localhost] => {
   
"msg": "foo'bar'baz"
}

Ansible devel:

fatal: [localhost]: FAILED! => {"failed": true, "msg": "template error while templating string: expected token 'end of print statement', got 'bar'"}

Deepali Mittal

unread,
Jun 28, 2016, 4:22:53 PM6/28/16
to Ansible Project
I am getting the same error using ansible 2.1 stable branch. Did you find a work around for this? 

- name: Set ELB variables
  set_fact
:
    host
: "{{ elb_ins.elb.dns_name }}"
    url
: 'http//{{ elb_ins.elb.dns_name }}/Server/'

Christian Thiemann

unread,
Jun 30, 2016, 6:12:27 AM6/30/16
to Ansible Project
Hi Deepali,

Sadly, I haven't found a work-around and am still using Ansible 1.9 since this bug is a big blocker for me...

If you want, you could post a comment on the GitHub issue I've created for this some time ago, to let the Ansible team know this affects not just me: https://github.com/ansible/ansible/issues/14172

Cheers,
  Christian
Reply all
Reply to author
Forward
0 new messages