煞氣a倫:
why using
country_name: USA
is correct
using
country_name: 'USA'
is not correct ?
Andrei Andriushin:
Hi!
Both are correct, except tasks examples. Using string without quotes is simplier and saves your time.
Quotes should be used in case of possible exceptions. For example, you want to use a colon in string:
windows_path: c:\windows
which will not work, so you need to use quotes or double quotes:
windows_drive: 'c:'
Double quotes allows you to use escapes and should be used with expressions:
vars:
app_path: "{{ base_path }}/22"
foo: "a \t TAB and a \n NEWLINE"
Check this article, and find special characters: https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html
煞氣a倫:
got it !
I will read article , thank you!
Andrei Andriushin:
Glad to help!)
Found a mistype: c:\windows
cannot be used with double quotes because of escape symbol \w
. It can be used only with single quotes: 'c:\windows'