I have a specific use that requires the Domain\User Windows format.
My assumption was
`
- set_fact:
my_login: “{{ ansible_env[‘USERDOMAIN’] }}{{ ansible_env[‘USERNAME’] }}”
`
This doesn’t seem to work however. How do I combine the two envrionmental variable with a \ between them?
When you are inside double quotes, you usually need double backslashes. I’ve not used the ansible_env syntax but hopefully the following should do the trick.
- set_fact:
my_login: “{{ ansible_env[‘USERDOMAIN’] }}\{{ ansible_env[‘USERNAME’] }}”
Hope this helps,
Jon
Hi Jon, good call on the \ , it does now set the fact. However if I run a debug I see it is now set as domain\user.
Not tried, but worth trying single quotes and a single backslash
Just a guess - but wouldn’t debug use python pprint and hence why you see \ in debug?
I just had a quick look, all log output in ansible is done via python Logger objects. So, I’m not sure if the \ is actually the representation of you data structure of if the \ is a result of outputting the data structure via debug.