I have an ansible task where I make use of shell module to run a custom bash script. This bash script expects an optional parameter which could be a multiline string. Example

```
~/myScript.sh -e "Each \nword \nin \nnew \nline"

```

This works perfectly fine when I run it in the bash shell. However, I have tried several ways but haven't made it run via the ansible task. The value being a variable itself. The task below -

```
- name: Sample Task
  shell:
    cmd: "{{ home_dir }}/myScript.sh -e '{{ string_with_escaped_newlines }}'"

```

Here, the value of variable `string_with_escaped_newlines` is set to `Each \nword \nin \nnew \nline` programmatically by other tasks. The output of the task confirms this.
I had put an echo in my shell script to debug & I observe that the echo would print 2 different sequences in the 2 cases(running directly via shell & running via ansible).

Debug output via shell-

```
Each 
word 
in 
new 
line

```

Debug output via ansible -

```
Each  word  in  new  line

```

Notice that there is an extra space introduced in the value in place on `\n`. I do not understand why this happens and how do I stop this. I have checked/tried shell as well as command modules of ansible.