Bootstrap FreeKB - Ansible - ansible_user_id fact
Ansible - ansible_user_id fact

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter a08294 in the box below so that we can be sure you are a human.