title: Can a value in a variable and a string with backslashes be combined in ansible?
body: <p>I have an ansible playbook in which one variable I am passing from the command. I am trying to append a windows folder path to it. One way I am able to find out is to add the path to another variable and then join the two variable. I would like to know if it is possible to avoid the variable and put the path like this:
  "{{ variable2 }} \build\dist\package\ui.msi"</p>
  
  <p>variable1 has value "d:\install"
  var_build_file_name is entered by the user
  variable2 is formed by combining variable1 and var_build_number.</p>
  
  <p>This is the actual content in the playbook which works:</p>
  
  <pre><code>  vars:
      installerFolder: "{{ UploadFolder }}{{ var_build_file_name | regex_replace('(\\.zip)','\') }}"
      packagePath: '\build\dist\package\UI.msi'
  
    - name: Install new version.
      debug:
        msg: "{{ installerFolder }}{{ packagePath }}"
  </code></pre>
  
  <p>And this is the playbook command:</p>
  
  <pre><code>ansible-playbook Install.yml -i ../inventory/hosts.ini --extra-vars "target=servername var_build_file_name=16.3.0.zip UploadFolder=D:\Install\\"
  </code></pre>
  
  <p>The output I am getting is:</p>
  
  <p>"msg": "D:\\Install\\16.3.0\\build\\dist\\package\\UI.msi"</p>
  
  <p>In the above output, how come two backslashes are showing instead of one?</p>
  
  <p>Is it possible to do</p>
  
  <pre><code>msg: "{{ installerFolder }} '\build\dist\package\UI.msi' "
  </code></pre>
  
  <p>I have tried many combinations but the backslashes are not getting properly escaped for above. If it is not possible then can someone enlighten on the reason.</p>
  
  <p>Thanks.</p>