ansible_user with backslash does not work when used in task #20381
Labels
affects_2.2
This issue/PR affects Ansible v2.2
bug
This issue/PR relates to a bug.
c:plugins/connection/ssh
Milestone
ISSUE TYPE
COMPONENT NAME
ansible core
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Red Hat Enterprise Linux 7.3
SUMMARY
When running a playbook with
ansible_user
set to something likedom\user
the use of{{ansible_user}}
in any task is failing.If
ansible_user
is defined like the following exampleansible_user: 'dom\user'
thessh
connectivity is working but runningid -g {{ansible_user}}
will fail due to the escaping of the\
On the client we have:
Note the
/usr/bin/id -g dom\\\\user
No matter how I set the variable it either fails to login via
ssh
or then when runningid -g
. The only way it's working is, when the variable in the task is escaped:The
command.py
in this case looks like the below example:Certainly, fixing this in the playbook is one option. But this option is not always possible, if somebody gets a playbook provided by a vendor or similar. It would therefore be nice, if
ansible_user
and be set in formatdom\user
and then work viassh
and also when used in atask
as variable.STEPS TO REPRODUCE
Setup account
dom\user
on client.example.com or even better connect the system to Windows or similar that does require to login viadom\user
. We are also aware that@
is a valid delimiter but in certain cases it can not be used/configured.Create
hosts
andgroup_vars/all
as below and run the below command:EXPECTED RESULTS
/usr/bin/id -g {{ ansible_ssh_user }}
should return the UID of theansible_user
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: