Visibility of facts/variables when using "become"

11 views
Skip to first unread message

thok...@gmail.com

unread,
Oct 13, 2016, 11:10:32 AM10/13/16
to Ansible Project
Hi, 
I ran into the issue that I wanted to include a role based on a fact.
Specifically, I wanted the firewall role (configuring iptables) to not be included when the playbook is run locally against a Vagrant VM.

I noticed that the facts are not available (= empty string) when I do it like that, i.e. using become. Is this by design?

Closely related question: The variable ansible_hostname is available. In which way is it different from the other facts?

Thanks and regards, 
Thomas

Brian Coca

unread,
Oct 13, 2016, 8:15:17 PM10/13/16
to ansible...@googlegroups.com
The only difference with become, is the user the facts are gathered as. Without become, the login user gathers facts and if there are ones that require privileges that user lacks, those won't be populated. 

With become, you turn into another user and the same things apply, you can gather the facts you have privileges to see.


----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages