Would be nice to have a "host.fact.user" fact
See original GitHub issueIs your feature request related to a problem? Please describe. Right now, if I want to get the user that is being used to connect to a given remote machine I have the following options:
- Add group data that specifies the
user
for a given remote. - Use
host.data.ssh_user
(assuming an ssh connection). - Grab the
host.fact.home
fact and then split out the user. - Write a custom fact that does the above.
When running adhoc commands, the first two methods don’t work, and the last two methods require duplicate code in all operations that happen to need the “user,” which works but is not ideal.
Describe the solution you’d like
It would be great to have a built-in host.fact.user
. The host.fact.home
fact is almost what I need, but falls short when it comes to running adhoc commands.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Ansible Facts and How to use them - Ansible Variable list
In this post, we are going to see, What is ansible facts (or) playbook variables and how to use these facts various types...
Read more >Here's how to access facts from other hosts (advanced feature)
first calling the dbservers to load up their data. I suspect most people won't need this, but the fact that we can do...
Read more >facts and magic variables — Ansible Documentation
Variables related to remote systems are called facts. With facts, you can use the behavior or state of one system as configuration on...
Read more >ansible set global fact · Issue #16049 - GitHub
Is there any way of making the set_facts global for all hosts, so that it sets the fact once and use the same...
Read more >4. Variables and Facts - Ansible: Up and Running [Book]
However, if the task fails, then Ansible will stop executing tasks for the failed host. We can use the ignore_errors clause, as shown...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I like this idea; to get the current user right? Could be implemented by executing
whoami
, but that would mean calling it withsudo
would returnroot
(or thesudo_user
), which I think is useful. Ie:vs:
This would be the same behaviour we have the
host.fact.home
. I think to get the SSH user (or winrm user, etc, etc) that is something specific to the connection type, and makes sense to be retrieved from there.Now released in v1.3!