Thank You Jordan.

 

I tried first without quotes and was getting an error…I usually try without 
quotes…  anyway, then I tried it as with double quotes and escaping the \’s and 
it worked… very curious will have to try without quotes at all again and see if 
perhaps I had some other error and was misinterpreting it as it is my first 
time using system variables in anger.  

 

Bill

 

From: [email protected] <[email protected]> On 
Behalf Of Jordan Borean
Sent: Wednesday, May 23, 2018 4:08 PM
To: Ansible Project <[email protected]>
Subject: [ansible-project] Re: inventory_hostname in path to create directory 
with win_file grief..

 

Hi

 

You seem to be close, one thing to remember when dealing with Windows paths in 
double quotes is that you needs to properly escape the backslashes. E.g. your 
path could be one of the following (they all are the same after yaml parsing)

 

# when not using quotes, no need to escape anything
path: C:\working\{{ inventory_hostname }}

# when using single quotes, you don't need to escape backslashes
path: 'C:\working\{{ inventory_hostname }}'

# when using double quotes, you need to escape backslashes, e.g. \n is newline 
with \\n <file://n>  is "\n" as text
path: "C:\\working\\{{ inventory_hostname }}"

 

We have some guides around this here 
https://docs.ansible.com/ansible/latest/user_guide/windows_usage.html#path-formatting-for-windows
 but ultimately I try to avoid quotes if possiible and if I need to use them, 
then I favor single quotes.

 

Thanks

 

Jordan

-- 
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] 
<mailto:[email protected]> .
To post to this group, send email to [email protected] 
<mailto:[email protected]> .
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/54b57262-6739-4488-8c83-4203640849dd%40googlegroups.com
 
<https://groups.google.com/d/msgid/ansible-project/54b57262-6739-4488-8c83-4203640849dd%40googlegroups.com?utm_medium=email&utm_source=footer>
 .
For more options, visit https://groups.google.com/d/optout.

-- 
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/391701d3f363%2444b5bfb0%24ce213f10%24%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to