Discussion:
[ansible-project] Use of "|" in a variable
Steve Malenfant
2015-07-28 00:47:10 UTC
Permalink
I'm running into a little problem trying to register a variable with a "|"
in it. Anybody know how to escape those?

I've got this template :

{% for sections in transforms_conf %}

[{{ sections.section }}]

{% for options in sections.options %}

{% for option, value in options.iteritems() %}

{{ option }} = {{ value }}

{% endfor %}

{% endfor %}


{% endfor %}


With the following variables :


transforms_conf:

- section: setnull

options:

- REGEX: "\\b/exclude1/\\b|\\b/exclude2/\\b"

- DEST_KEY: queue

- FORMAT: nullQueue


Which I'm trying to get this as output :



[setnull]

REGEX = \b/exclude1/\b|\b/exclude2/\b

DEST_KEY = queue

FORMAT = nullQueue


Although I only get this in the results :


[setnull]

REGEX = \b/exclude1/\b

DEST_KEY = queue

FORMAT = nullQueue


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-project+***@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/71211ed5-aa0b-4dfb-bce9-e5871bcea123%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Toshio Kuratomi
2015-07-28 16:04:39 UTC
Permalink
I'm not able to replicate this:

---
- hosts: localhost
vars:
transforms_conf:
- section: setnull
options:
- REGEX: "\\b/exclude1/\\b|\\b/exclude2/\\b"
- DEST_KEY: queue
- FORMAT: nullQueue
tasks:
- template:
dest: /var/tmp/output
src: /var/tmp/input.j2

$ grep REGEX /var/tmp/output *[devel] (09:03:38)
REGEX = \b/exclude1/\b|\b/exclude2/\b

Tried with ansible 1.9.2 and with the current devel branch.

Are you using a different version of ansible? Or setting the variable
in a different manner?

-Toshio
Post by Steve Malenfant
I'm running into a little problem trying to register a variable with a "|"
in it. Anybody know how to escape those?
{% for sections in transforms_conf %}
[{{ sections.section }}]
{% for options in sections.options %}
{% for option, value in options.iteritems() %}
{{ option }} = {{ value }}
{% endfor %}
{% endfor %}
{% endfor %}
- section: setnull
- REGEX: "\\b/exclude1/\\b|\\b/exclude2/\\b"
- DEST_KEY: queue
- FORMAT: nullQueue
[setnull]
REGEX = \b/exclude1/\b|\b/exclude2/\b
DEST_KEY = queue
FORMAT = nullQueue
[setnull]
REGEX = \b/exclude1/\b
DEST_KEY = queue
FORMAT = nullQueue
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/71211ed5-aa0b-4dfb-bce9-e5871bcea123%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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-project+***@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/CAG9juEpO%3DubLwEDetp2wLDxTXGgcibA-GC0Du_kEzznQdWROQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...