title: How to escape backslash and double quote in Ansible (script module)
body: <p>I'm very new to Ansible (2.x) and I am having trouble using the script module and passing parameters with double quotes and backslashes.</p>
  
  <p>Assuming we have a set variable <code>{{foo}}</code> which contains a string "foo", I have a task like this:</p>
  
  <pre><code>set_fact:
     arg: \(-name "{{foo}}" \)
  name: call shell module
  script: path/somescript.sh "{{arg}}"
  </code></pre>
  
  <p>My script needs the following structure of the argument in order to work:</p>
  
  <pre><code>\(-name "foo" \)
  </code></pre>
  
  <p>I tried several things such as:</p>
  
  <pre><code>arg: \(-name \""{{foo}}"\" \)           result: \\(-name \"foo\" \\)
  
  arg: '\(-name \""{{foo}}"\" \)'         result: \\(-name \"foo\" \\)
  
  arg: \\(-name \""{{foo}}"\" \\)           result: \\(-name \"foo\" \\)
  </code></pre>
  
  <p>Is it possible to escape backslashes and double quotes in Ansible?</p>