I have difficulties to get the differences between the following syntaxes when I set vars or facts in a YAML role:
vars:
app_path1: "{{ (ansible_facts.env.ProgramFiles + '\\\\' + item.installation_directory) if item.executable else root_dir }}"
app_path2: >
{{ (ansible_facts.env.ProgramFiles + '\\' + item.installation_directory) if item.executable else root_dir }}
app_path3: |
{{ (ansible_facts.env.ProgramFiles + '\\' + item.installation_directory) if item.executable else root_dir }}
Here is the result:
{
"app_path1": "C:\\Program Files\\\\MyCompany\\TheAppName",
"app_path2": "C:\\Program Files\\\\MyCompany\\TheAppName\n",
"app_path3": "C:\\Program Files\\\\MyCompany\\TheAppName\n"
}
Why app_path2 and app_path3 added a mysterious \n at the end? And why must I escape twice the backslashes in app_path1? It's a kind of black magic for me.