Ansible - ansible_user_id fact
by
Jeremy Canfield |
Updated: October 06 2022
| Ansible articles
The ansible_user_id variable can be used to display the user being used in the SSH connection to each managed nodes. For example, let's say john.doe may be invoking the ansible-playbook command but the --user command line option or the remote_user parameter may be used so that some other user (e.g. jane.doe) is being used in the SSH connection to each managed node.
---
- hosts: localhost
remote_user: jane.doe
tasks:
- debug:
var: ansible_user_id
...
Running this play should return the following.
TASK [debug]
ok: [localhost] => {
"msg": "jane.doe"
}
Did you find this article helpful?
If so, consider buying me a coffee over at