In my role I have one step which sets up some pathing:
- name: Set consul folder var
set_fact:
consul_folder: "{{ ansible_env['DatafilesPath'] }}\\apps\\consul"
This works in Ansible and I can use the 'consul_folder' variable in other
plays and all is good.
I also need to set this path in a config file which gets templated onto the
target server. The relevant parts of the json looks like this:
{
"datacenter": "{{ consul_dc_name }}",
"data_dir": "{{ consul_folder }}\\data",
As far as I'm in ansible the data_dir is a valid path, as all backslashes
get normalized into their "real" value. However, on the target node this
file ends up like this:
{
"datacenter": "default",
"data_dir": "C:\apps\consul\\data",
>From this I gather that Ansible does _not_ normalize json data.
The problem I have is that I need the target json to contain the "double
backslash" so that it's a valid json file.
The alternative I see right now is to double-double the backslashes but
that will get incredibly messy incredibly fast.
I have tried using a jinja2 filter in my template json:
{
"datacenter": "{{ consul_dc_name }}",
"data_dir": "{{ consul_folder | win_dirname}}\\data",
but the result is the same.
Is there a way for me to get around this so that the double quotes are
retained and thus the template json kept valid?
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/5c8281af-894b-470a-a153-79fa42f594cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.