I dump variables set by gather_facts with the setup module, using

ansible -u centos -m setup

But how can I use this on the command line?

This show nothing,

ansible -u centos -b -m debug -a "msg='{{ansible_facts}}'"

And, neither does

ansible -u centos -b -m gather_facts -m debug -a "msg='{{ansible_facts}}'"
ansible -u centos -b -m setup -m debug -a "msg='{{ansible_facts}}'"

1 Answer 1


You can't run multiple modules at once with the not-playbook ansible command.

Either write a short play that gathers facts, and also does things with them.

Or gather facts with an ad-hoc command, but filter it.

ansible -m gather_facts  -a filter=ansible_hostname hostpattern

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .